Documentation
¶
Overview ¶
Package http provides HTTP server and client instrumentation using OpenTelemetry.
Server middleware creates spans for incoming requests:
mux := http.NewServeMux()
mux.HandleFunc("/api", handler)
instrumented := ionhttp.Handler(mux, "my-service")
http.ListenAndServe(":8080", instrumented)
Client instrumentation wraps an http.Client:
client := ionhttp.Client()
resp, err := client.Get("https://api.example.com")
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Client ¶
Client returns an HTTP client instrumented with OpenTelemetry. Each request creates a client span linked to the current trace context.
func Handler ¶
Handler wraps an http.Handler with OpenTelemetry instrumentation. It creates spans for each incoming request with attributes for: - HTTP method - URL path - Status code - Request/response size
func Transport ¶
func Transport(base http.RoundTripper) http.RoundTripper
Transport returns an http.RoundTripper instrumented with OpenTelemetry. Use this to instrument custom transports.
Types ¶
type Option ¶
type Option interface {
// contains filtered or unexported methods
}
Option configures HTTP instrumentation.
func WithFilter ¶
WithFilter sets a filter function to exclude requests from tracing. Return true to include the request, false to skip.
Example:
ionhttp.Handler(mux, "api", ionhttp.WithFilter(func(r *http.Request) bool {
return r.URL.Path != "/health"
}))