otel

package
v0.2.8 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2026 License: AGPL-3.0 Imports: 26 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
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

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

NewHTTPHandler wraps handler to record a span and metrics for every request

func NewSlogHandler

func NewSlogHandler(name string, level slog.Leveler) slog.Handler

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

func RouteMiddleware(next http.Handler) http.Handler

RouteMiddleware names the request span after the matched mux route template (e.g. "GET /nodes/{name}"), keeping span names low cardinality

func SetErrorLogger

func SetErrorLogger(logger *slog.Logger, interval time.Duration)

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.

Jump to

Keyboard shortcuts

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