observability

package
v1.3.3 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2026 License: MIT Imports: 20 Imported by: 0

Documentation

Overview

Package observability provides factory functions to initialize the application's observability subsystems: structured logging (zap), Prometheus metrics, and OpenTelemetry tracing.

Each Init* function returns a shutdown function (func(context.Context) error) suitable for use with the closer package. Call Init* functions exactly once at application startup; repeated calls may leak resources.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitLogger

func InitLogger(cfg *config.Config) (*zap.Logger, error)

InitLogger creates and returns a zap.Logger configured for JSON output to stdout with ISO8601 timestamps and caller information. The logging level is parsed from cfg.Logging.Level. Stack traces are automatically attached at ErrorLevel and above.

func InitMetrics

func InitMetrics(cfg *config.Config, logger *zap.Logger) (func(context.Context) error, error)

InitMetrics starts a Prometheus metrics HTTP server on a separate port when cfg.Metrics.Enabled is true. It registers the default promhttp handler at the configured path (default: /metrics). Returns a shutdown function that gracefully stops the server. If metrics are disabled, returns a no-op shutdown function.

func InitTelemetry

func InitTelemetry(ctx context.Context, cfg *config.Config, logger *zap.Logger) (func(context.Context) error, error)

Types

This section is empty.

Directories

Path Synopsis
Package sentry provides Sentry error tracking initialization.
Package sentry provides Sentry error tracking initialization.
http
Package http provides Sentry HTTP middleware that wraps an http.Handler with Sentry's panic recovery and error reporting.
Package http provides Sentry HTTP middleware that wraps an http.Handler with Sentry's panic recovery and error reporting.
mock
Package mock provides a MockSentry test server that records HTTP requests made by the Sentry SDK.
Package mock provides a MockSentry test server that records HTTP requests made by the Sentry SDK.
zap
Package zap provides a zap.Logger wrapper that forwards log entries (ErrorLevel by default) to Sentry via a custom zapcore.Core.
Package zap provides a zap.Logger wrapper that forwards log entries (ErrorLevel by default) to Sentry via a custom zapcore.Core.

Jump to

Keyboard shortcuts

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