MCPcopy Create free account
hub / github.com/coder/aibridge / TestTracePassthrough

Function TestTracePassthrough

internal/integrationtest/trace_test.go:752–782  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

750}
751
752func TestTracePassthrough(t *testing.T) {
753 t.Parallel()
754
755 fix := fixtures.Parse(t, fixtures.OaiChatFallthrough)
756
757 upstream := newMockUpstream(t.Context(), t, newFixtureResponse(fix))
758
759 sr, tracer := setupTracer(t)
760
761 bridgeServer := newBridgeTestServer(t.Context(), t, upstream.URL,
762 withTracer(tracer),
763 )
764
765 resp, err := bridgeServer.makeRequest(t, http.MethodGet, "/openai/v1/models", nil)
766 require.NoError(t, err)
767 defer resp.Body.Close()
768 require.Equal(t, http.StatusOK, resp.StatusCode)
769 bridgeServer.Close()
770
771 spans := sr.Ended()
772 require.Len(t, spans, 1)
773
774 assert.Equal(t, spans[0].Name(), "Passthrough")
775 want := []attribute.KeyValue{
776 attribute.String(tracing.PassthroughMethod, "GET"),
777 attribute.String(tracing.PassthroughUpstreamURL, upstream.URL+"/models"),
778 attribute.String(tracing.PassthroughURL, "/models"),
779 }
780 got := slices.SortedFunc(slices.Values(spans[0].Attributes()), cmpAttrKeyVal)
781 require.Equal(t, want, got)
782}
783
784func TestNewServerProxyManagerTraces(t *testing.T) {
785 t.Parallel()

Callers

nothing calls this directly

Calls 9

ParseFunction · 0.92
newMockUpstreamFunction · 0.85
newFixtureResponseFunction · 0.85
setupTracerFunction · 0.85
newBridgeTestServerFunction · 0.85
withTracerFunction · 0.85
makeRequestMethod · 0.80
NameMethod · 0.65
CloseMethod · 0.45

Tested by

no test coverage detected