MCPcopy Index your code
hub / github.com/coder/coder / TestTraceOpenAI

Function TestTraceOpenAI

aibridge/internal/integrationtest/trace_internal_test.go:432–588  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

430}
431
432func TestTraceOpenAI(t *testing.T) {
433 t.Parallel()
434
435 cases := []struct {
436 name string
437 fixture []byte
438 streaming bool
439 path string
440
441 expect []expectTrace
442 }{
443 {
444 name: "trace_openai_chat_streaming",
445 fixture: fixtures.OaiChatSimple,
446 streaming: true,
447 path: pathOpenAIChatCompletions,
448 expect: []expectTrace{
449 {"Intercept", 1, codes.Unset},
450 {"Intercept.CreateInterceptor", 1, codes.Unset},
451 {"Intercept.RecordInterception", 1, codes.Unset},
452 {"Intercept.ProcessRequest", 1, codes.Unset},
453 {"Intercept.RecordInterceptionEnded", 1, codes.Unset},
454 {"Intercept.RecordPromptUsage", 1, codes.Unset},
455 {"Intercept.RecordTokenUsage", 1, codes.Unset},
456 {"Intercept.ProcessRequest.Upstream", 1, codes.Unset},
457 },
458 },
459 {
460 name: "trace_openai_chat_blocking",
461 fixture: fixtures.OaiChatSimple,
462 streaming: false,
463 path: pathOpenAIChatCompletions,
464 expect: []expectTrace{
465 {"Intercept", 1, codes.Unset},
466 {"Intercept.CreateInterceptor", 1, codes.Unset},
467 {"Intercept.RecordInterception", 1, codes.Unset},
468 {"Intercept.ProcessRequest", 1, codes.Unset},
469 {"Intercept.RecordInterceptionEnded", 1, codes.Unset},
470 {"Intercept.RecordPromptUsage", 1, codes.Unset},
471 {"Intercept.RecordTokenUsage", 1, codes.Unset},
472 {"Intercept.ProcessRequest.Upstream", 1, codes.Unset},
473 },
474 },
475 {
476 name: "trace_openai_responses_streaming",
477 fixture: fixtures.OaiResponsesStreamingSimple,
478 streaming: true,
479 path: pathOpenAIResponses,
480 expect: []expectTrace{
481 {"Intercept", 1, codes.Unset},
482 {"Intercept.CreateInterceptor", 1, codes.Unset},
483 {"Intercept.RecordInterception", 1, codes.Unset},
484 {"Intercept.ProcessRequest", 1, codes.Unset},
485 {"Intercept.RecordInterceptionEnded", 1, codes.Unset},
486 {"Intercept.RecordPromptUsage", 1, codes.Unset},
487 {"Intercept.RecordTokenUsage", 1, codes.Unset},
488 {"Intercept.ProcessRequest.Upstream", 1, codes.Unset},
489 },

Callers

nothing calls this directly

Calls 15

ParseFunction · 0.92
setupTracerFunction · 0.85
newFixtureResponseFunction · 0.85
newBridgeTestServerFunction · 0.85
withTracerFunction · 0.85
verifyTracesFunction · 0.85
RecordedInterceptionsMethod · 0.80
newMockUpstreamFunction · 0.70
RunMethod · 0.65
ContextMethod · 0.65
CleanupMethod · 0.65
CloseMethod · 0.65

Tested by

no test coverage detected