MCPcopy Create free account
hub / github.com/InferCore/InferCore / TestInfer_EmitsTraceRecord

Function TestInfer_EmitsTraceRecord

internal/server/server_test.go:781–817  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

779}
780
781func TestInfer_EmitsTraceRecord(t *testing.T) {
782 exporter := &captureTelemetryExporter{}
783 var sloEngine interfaces.SLOEngine = slo.NewMemoryEngine()
784 srv := NewWithDependencies(testConfig(100, true), sloEngine, exporter)
785 ts := httptest.NewServer(srv.Routes())
786 defer ts.Close()
787
788 status, _ := postInfer(t, ts.URL, map[string]any{
789 "tenant_id": "team-a",
790 "task_type": "simple",
791 "input": map[string]any{
792 "text": "hello",
793 },
794 "options": map[string]any{
795 "stream": false,
796 "max_tokens": 128,
797 },
798 })
799 if status != http.StatusOK {
800 t.Fatalf("expected 200, got %d", status)
801 }
802
803 traces := exporter.Traces()
804 if len(traces) == 0 {
805 t.Fatalf("expected at least one emitted trace record")
806 }
807 last := traces[len(traces)-1]
808 if last.Name != "infer_request" {
809 t.Fatalf("unexpected trace name: %s", last.Name)
810 }
811 if last.TraceID == "" || last.SpanID == "" {
812 t.Fatalf("trace and span id must be set")
813 }
814 if last.Labels["result"] != "success" {
815 t.Fatalf("expected success trace label, got %q", last.Labels["result"])
816 }
817}
818
819func TestInfer_TracingDisabledDoesNotEmitTrace(t *testing.T) {
820 cfg := testConfig(100, true)

Callers

nothing calls this directly

Calls 7

TracesMethod · 0.95
NewMemoryEngineFunction · 0.92
NewWithDependenciesFunction · 0.85
postInferFunction · 0.85
RoutesMethod · 0.80
testConfigFunction · 0.70
CloseMethod · 0.65

Tested by

no test coverage detected