(t *testing.T)
| 736 | } |
| 737 | |
| 738 | func TestMetrics_Success200(t *testing.T) { |
| 739 | srv := New(testConfig(100, true)) |
| 740 | ts := httptest.NewServer(srv.Routes()) |
| 741 | defer ts.Close() |
| 742 | |
| 743 | // Generate one non-metrics request so labeled HTTP counter is populated. |
| 744 | _, _ = http.Get(ts.URL + "/health") |
| 745 | |
| 746 | resp, err := http.Get(ts.URL + "/metrics") |
| 747 | if err != nil { |
| 748 | t.Fatalf("metrics request failed: %v", err) |
| 749 | } |
| 750 | defer resp.Body.Close() |
| 751 | |
| 752 | if resp.StatusCode != http.StatusOK { |
| 753 | t.Fatalf("expected 200, got %d", resp.StatusCode) |
| 754 | } |
| 755 | if !strings.Contains(resp.Header.Get("Content-Type"), "text/plain") { |
| 756 | t.Fatalf("expected text/plain content type, got %s", resp.Header.Get("Content-Type")) |
| 757 | } |
| 758 | |
| 759 | raw, err := io.ReadAll(resp.Body) |
| 760 | if err != nil { |
| 761 | t.Fatalf("read metrics body: %v", err) |
| 762 | } |
| 763 | metricsBody := string(raw) |
| 764 | if !strings.Contains(metricsBody, "infercore_requests_total") { |
| 765 | t.Fatalf("expected infercore_requests_total metric") |
| 766 | } |
| 767 | if !strings.Contains(metricsBody, "infercore_http_requests_total") { |
| 768 | t.Fatalf("expected infercore_http_requests_total metric") |
| 769 | } |
| 770 | if !strings.Contains(metricsBody, "infercore_scaling_ttft_degradation_ratio") { |
| 771 | t.Fatalf("expected infercore_scaling_ttft_degradation_ratio metric") |
| 772 | } |
| 773 | if !strings.Contains(metricsBody, "path=\"/health\"") { |
| 774 | t.Fatalf("expected /health labeled metric entry") |
| 775 | } |
| 776 | if !strings.Contains(metricsBody, "method=\"GET\"") { |
| 777 | t.Fatalf("expected GET method labeled metric entry") |
| 778 | } |
| 779 | } |
| 780 | |
| 781 | func TestInfer_EmitsTraceRecord(t *testing.T) { |
| 782 | exporter := &captureTelemetryExporter{} |
nothing calls this directly
no test coverage detected