Documentation
¶
Overview ¶
Package otel provides thin OpenTelemetry middleware helpers for Loom HTTP servers and clients.
The package intentionally wraps the official OpenTelemetry contrib HTTP instrumentation instead of implementing tracing itself. Applications remain responsible for configuring the tracer provider, exporter, and resource attributes. Loom owns the transport seam so generated and hand-written handlers can share one instrumentation path.
Use Middleware with goahttp.NewMuxer so spans can inherit the matched METHOD-plus-route pattern from r.Pattern:
mux := goahttp.NewMuxer()
mux.Use(otel.Middleware("service"))
For generated HTTP clients, wrap an *http.Client before passing it anywhere a goa HTTP Doer is expected:
client := otel.WrapClient(&http.Client{})
Index ¶
- func Handler(handler http.Handler, service string, opts ...Option) http.Handler
- func Middleware(service string, opts ...Option) func(http.Handler) http.Handler
- func WrapClient(client *http.Client, opts ...Option) *http.Client
- func WrapTransport(rt http.RoundTripper, opts ...Option) http.RoundTripper
- type Option
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Middleware ¶
Middleware instruments an HTTP handler chain using the official OpenTelemetry HTTP middleware.
The provided service name is used as the fallback operation name. When the request carries a matched Loom route pattern in r.Pattern, the middleware uses that pattern as the span name so spans remain stable across path parameters.
func WrapClient ¶
WrapClient returns a shallow copy of client whose Transport is instrumented with OpenTelemetry.
If client is nil, WrapClient returns a new client using the default instrumented transport.
func WrapTransport ¶
func WrapTransport(rt http.RoundTripper, opts ...Option) http.RoundTripper
WrapTransport instruments an HTTP RoundTripper using the official OpenTelemetry HTTP transport wrapper.