(t *testing.T)
| 329 | } |
| 330 | |
| 331 | func Test_telemetryMiddleware(t *testing.T) { |
| 332 | otel.SetTracerProvider(sdktrace.NewTracerProvider()) |
| 333 | |
| 334 | router := mux.NewRouter() |
| 335 | router.Use(NewHTTPMiddleware(context.Background(), WithTelemetry("svc", attribute.Bool("foo-bar", false)))...) |
| 336 | router.HandleFunc("/test-with-telemetry", func(rw http.ResponseWriter, r *http.Request) { |
| 337 | // Pull the span from the context should be a noop |
| 338 | tSpan := trace.SpanFromContext(r.Context()) |
| 339 | assert.True(t, tSpan.SpanContext().HasSpanID()) |
| 340 | }) |
| 341 | router.HandleFunc(httpHealthRoutePath, func(rw http.ResponseWriter, r *http.Request) { |
| 342 | // Pull the span from the context should be a noop |
| 343 | tSpan := trace.SpanFromContext(r.Context()) |
| 344 | assert.False(t, tSpan.SpanContext().HasSpanID()) |
| 345 | }) |
| 346 | |
| 347 | r := httptest.NewRequest("GET", "/test-with-telemetry", nil) |
| 348 | router.ServeHTTP(httptest.NewRecorder(), r) |
| 349 | |
| 350 | r = httptest.NewRequest("GET", httpHealthRoutePath, nil) |
| 351 | router.ServeHTTP(httptest.NewRecorder(), r) |
| 352 | } |
| 353 | |
| 354 | func Test_recordingResponseWriter(t *testing.T) { |
| 355 | // make sure the recordingResponseWriter preserves interfaces implemented by the wrapped writer |
nothing calls this directly
no test coverage detected