(t *testing.T)
| 779 | } |
| 780 | |
| 781 | func 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 | |
| 819 | func TestInfer_TracingDisabledDoesNotEmitTrace(t *testing.T) { |
| 820 | cfg := testConfig(100, true) |
nothing calls this directly
no test coverage detected