Documentation ¶
Index ¶
- func ContextWithGatherer(ctx context.Context, gatherer prometheus.Gatherer) context.Context
- func ContextWithRegistrer(ctx context.Context, registrer prometheus.Registerer) context.Context
- func ContextWithRegistry(ctx context.Context, registry *prometheus.Registry) context.Context
- func GathererFromContext(ctx context.Context) prometheus.Gatherer
- func NewAddXHeadersHandlerMiddleware(next http.Handler) http.Handler
- func NewLogOtelMiddleware(next slog.Handler) slog.Handler
- func NewMetricsHTTPHandler(ctx context.Context) http.Handler
- func NewMetricsHandlerMiddleware(next http.Handler, ctx context.Context, service string) http.Handler
- func NewMetricsRegistry() *prometheus.Registry
- func NewOtelHandlerMiddleware(handler http.Handler, operation string) http.Handler
- func NewTraceparentHandlerMiddleware(next http.Handler) http.Handler
- func RegistrerFromContext(ctx context.Context) prometheus.Registerer
- func SetupOtelSDK(ctx context.Context) (func(context.Context) error, error)
- type AddXHeadersMiddleware
- type TraceparentHandlerMiddleware
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ContextWithGatherer ¶
ContextWithGatherer returns a new context with the given registry.
func ContextWithRegistrer ¶
func ContextWithRegistrer(ctx context.Context, registrer prometheus.Registerer) context.Context
ContextWithRegistrer returns a new context with the given registry.
func ContextWithRegistry ¶
ContextWithRegistry returns a new context with the given registry.
func GathererFromContext ¶
func GathererFromContext(ctx context.Context) prometheus.Gatherer
GathererFromContext returns the gatherer from the given context.
func NewAddXHeadersHandlerMiddleware ¶
NewAddXHeadersHandlerMiddleware creates a new AddXHeadersMiddleware. It adds the trace ID as rthe "X-Trace-Id" response headers if a trace is active.
func NewLogOtelMiddleware ¶
NewLogOtelMiddleware wraps the provided slog.Handler with OpenTelemetry logging middleware.
func NewMetricsHTTPHandler ¶
NewMetricsHTTPHandler returns a new HTTP handler that exposes the metrics.
func NewMetricsRegistry ¶
func NewMetricsRegistry() *prometheus.Registry
func NewOtelHandlerMiddleware ¶
NewOtelHandlerMiddleware returns an HTTP handler with OpenTelemetry instrumentation. The handler parameter is the original HTTP handler to be instrumented. The second parameter is unused. It adds middleware to handle tracing and span name formatting. The span name formatter uses the HTTP method and URL path.
func NewTraceparentHandlerMiddleware ¶
NewTraceparentHandlerMiddleware creates a new TraceparentHandlerMiddleware. It injects the "traceparent" header into the response headers according to w3c trace context specification.
func RegistrerFromContext ¶
func RegistrerFromContext(ctx context.Context) prometheus.Registerer
RegistrerFromContext returns the registrer from the given context.
Types ¶
type AddXHeadersMiddleware ¶
type AddXHeadersMiddleware struct {
// contains filtered or unexported fields
}
func (*AddXHeadersMiddleware) ServeHTTP ¶
func (h *AddXHeadersMiddleware) ServeHTTP(w http.ResponseWriter, req *http.Request)
type TraceparentHandlerMiddleware ¶
type TraceparentHandlerMiddleware struct {
// contains filtered or unexported fields
}
func (*TraceparentHandlerMiddleware) ServeHTTP ¶
func (h *TraceparentHandlerMiddleware) ServeHTTP(w http.ResponseWriter, req *http.Request)