Documentation
¶
Index ¶
- Constants
- func Enabled() bool
- func InitializeHTTP(ctx context.Context, serviceName, instanceID string) (func(context.Context) error, error)
- func NewHTTPHandler(handler http.Handler, operation string) http.Handler
- func NewSlogHandler(name string, level slog.Leveler) slog.Handler
- func RouteMiddleware(next http.Handler) http.Handler
- func SetErrorLogger(logger *slog.Logger, interval time.Duration)
- func SetNodeName(name string)
Constants ¶
const NodeNameKey = "realm.node.name"
NodeNameKey is the attribute carrying the node name on exported logs and spans
Variables ¶
This section is empty.
Functions ¶
func Enabled ¶
func Enabled() bool
Enabled reports whether an OTLP collector endpoint has been configured through the OTEL_EXPORTER_OTLP_ENDPOINT env variable
func InitializeHTTP ¶
func InitializeHTTP(ctx context.Context, serviceName, instanceID string) (func(context.Context) error, error)
Initialize OpenTelemetry HTTP providers for traces, log and metrics Configure destination URL with OTEL_EXPORTER_OTLP_ENDPOINT env variable. serviceName identifies the kind of service and instanceID the running instance of it, so all instances can be grouped under the same service
func NewHTTPHandler ¶
NewHTTPHandler wraps handler to record a span and metrics for every request
func NewSlogHandler ¶
NewSlogHandler returns a slog handler that forwards records at or above the given level to the global OpenTelemetry logger provider. The level filter is needed as the otelslog handler accepts every record the logger provider is enabled for
func RouteMiddleware ¶
RouteMiddleware names the request span after the matched mux route template (e.g. "GET /nodes/{name}"), keeping span names low cardinality
func SetNodeName ¶
func SetNodeName(name string)
SetNodeName sets the node name added to every log record and span from now on. The node name is only known once a node config is loaded so it can not be part of the resource. An empty name stops adding it
Types ¶
This section is empty.