insights

package
v0.0.54 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 27, 2024 License: MIT Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ContextWithGatherer

func ContextWithGatherer(ctx context.Context, gatherer prometheus.Gatherer) context.Context

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

func ContextWithRegistry(ctx context.Context, registry *prometheus.Registry) context.Context

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

func NewAddXHeadersHandlerMiddleware(next http.Handler) http.Handler

NewAddXHeadersHandlerMiddleware creates a new AddXHeadersMiddleware. It adds the trace ID as rthe "X-Trace-Id" response headers if a trace is active.

func NewLogOtelMiddleware

func NewLogOtelMiddleware(next slog.Handler) slog.Handler

NewLogOtelMiddleware wraps the provided slog.Handler with OpenTelemetry logging middleware.

func NewMetricsHTTPHandler

func NewMetricsHTTPHandler(ctx context.Context) http.Handler

NewMetricsHTTPHandler returns a new HTTP handler that exposes the metrics.

func NewMetricsHandlerMiddleware

func NewMetricsHandlerMiddleware(next http.Handler, ctx context.Context, service string) http.Handler

func NewMetricsRegistry

func NewMetricsRegistry() *prometheus.Registry

func NewOtelHandlerMiddleware

func NewOtelHandlerMiddleware(handler http.Handler, operation string) http.Handler

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

func NewTraceparentHandlerMiddleware(next http.Handler) http.Handler

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.

func SetupOtelSDK

func SetupOtelSDK(ctx context.Context) (func(context.Context) error, error)

SetupOtelSDK bootstraps the OpenTelemetry pipeline. If it does not return an error, make sure to call shutdown for proper cleanup.

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL