A community based topic aggregation platform built on atproto
at main 21 lines 673 B view raw
1package observability 2 3import ( 4 "net/http" 5 6 "go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp" 7) 8 9// HTTPMiddleware returns an HTTP middleware that instruments requests with OpenTelemetry tracing. 10// If the provider is nil or tracing is not enabled, it returns nil (no middleware applied). 11// The middleware adds trace context to incoming requests and creates spans for each request. 12func HTTPMiddleware(p *Provider) func(http.Handler) http.Handler { 13 if p == nil || !p.Enabled() { 14 return nil 15 } 16 17 // Use otelhttp for standard net/http instrumentation 18 return func(next http.Handler) http.Handler { 19 return otelhttp.NewHandler(next, "coves-appview") 20 } 21}