telemetry

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2026 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitSentry added in v0.4.0

func InitSentry(_ context.Context, serviceName, version string) (func(context.Context) error, bool, error)

InitSentry initializes Sentry when SENTRY_DSN is set.

func InitTelemetry

func InitTelemetry(ctx context.Context, serviceName, version string) (func(context.Context) error, error)

InitTelemetry initializes OpenTelemetry with OTLP exporters for metrics and traces. Configuration is read from environment variables:

  • OTEL_EXPORTER_OTLP_ENDPOINT: The OTLP endpoint (e.g., https://api.honeycomb.io)
  • OTEL_EXPORTER_OTLP_HEADERS: Headers for authentication (e.g., x-honeycomb-team=API_KEY)
  • OTEL_SERVICE_NAME: Service name override (defaults to serviceName parameter)

Returns a shutdown function that must be called on graceful shutdown. If OTEL_EXPORTER_OTLP_ENDPOINT is not set, returns a no-op immediately. If a provider fails to initialize, telemetry continues without it.

func NewSentryHTTPHandler added in v0.4.0

func NewSentryHTTPHandler() func(http.Handler) http.Handler

func NewSentrySlogHandler added in v0.4.0

func NewSentrySlogHandler(ctx context.Context) slog.Handler

func RecordRefreshTokenGrant added in v0.4.0

func RecordRefreshTokenGrant(ctx context.Context, outcome, reason string)

func Start added in v0.2.0

func Start(ctx context.Context, name string) (context.Context, trace.Span)

Types

type Metrics

type Metrics struct{}

Metrics holds OpenTelemetry metric instruments. Populated when instruments are added.

type OTelHandler

type OTelHandler struct {
	slog.Handler
}

OTelHandler wraps a slog.Handler and mirrors each log record as a span event on the active trace span. Only fires when the span is recording, so there is no overhead when tracing is disabled or no span is in context. Use InfoContext/ErrorContext (not Info/Error) so the span can be reached.

func NewOTelHandler

func NewOTelHandler(inner slog.Handler) *OTelHandler

func (*OTelHandler) Handle

func (h *OTelHandler) Handle(ctx context.Context, r slog.Record) error

func (*OTelHandler) WithAttrs

func (h *OTelHandler) WithAttrs(attrs []slog.Attr) slog.Handler

func (*OTelHandler) WithGroup

func (h *OTelHandler) WithGroup(name string) slog.Handler

Jump to

Keyboard shortcuts

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