Documentation
¶
Index ¶
- Variables
- func StartLogger(cctx *cli.Context, opts ...LoggingOption) *slog.Logger
- func StartMetrics(cctx *cli.Context, opts ...MetricsOption)
- func StartTracing(cctx *cli.Context, opts ...TracingOption) (func(context.Context) error, error)
- type Logging
- type LoggingOption
- type Metrics
- type MetricsOption
- type Tracing
- type TracingOption
Constants ¶
This section is empty.
Variables ¶
var CLIFlagDebug = &cli.BoolFlag{ Name: "debug", Usage: "Enable debug mode", Value: false, EnvVars: []string{"DEBUG"}, }
var CLIFlagMetricsListenAddress = &cli.StringFlag{ Name: "metrics-listen-address", Usage: "listen endpoint for metrics and pprof", Value: "0.0.0.0:8081", EnvVars: []string{"METRICS_LISTEN_ADDRESS"}, }
var CLIFlagServiceName = &cli.StringFlag{ Name: "service-name", Usage: "service name for tracing", Value: "service", EnvVars: []string{"SERVICE_NAME"}, }
var CLIFlagTracingSampleRatio = &cli.Float64Flag{ Name: "tracing-sample-ratio", Usage: "tracing sample ratio (0.0 to 1.0)", Value: 1.0, EnvVars: []string{"TRACING_SAMPLE_RATIO"}, }
Functions ¶
func StartLogger ¶
func StartLogger(cctx *cli.Context, opts ...LoggingOption) *slog.Logger
func StartMetrics ¶
func StartMetrics(cctx *cli.Context, opts ...MetricsOption)
func StartTracing ¶
Types ¶
type LoggingOption ¶
type LoggingOption func(*Logging)
LoggingOption is a functional option for configuring the Logger.
func WithHandler ¶
func WithHandler(handler slog.Handler) LoggingOption
WithHandler sets a custom slog.Handler for the logger.
func WithLevel ¶
func WithLevel(level slog.Level) LoggingOption
WithLevel sets the logging level for the logger. Defaults to slog.LevelInfo or slog.LevelDebug if debug is enabled.
func WithSource ¶
func WithSource(includeSource bool) LoggingOption
WithSource sets whether the logger should include source information. Defaults to true.
type MetricsOption ¶
type MetricsOption func(*Metrics)
MetricsOption is a functional option for configuring the Metrics.
func WithListenAddr ¶
func WithListenAddr(addr string) MetricsOption
WithListenAddr sets the listen address for the metrics server. Defaults to :8081 or whatever is set in the CLI flag.
func WithPath ¶
func WithPath(path string) MetricsOption
WithPath sets the path for the metrics server. Defaults to "/metrics".
type TracingOption ¶
type TracingOption func(*Tracing)
TracingOption is a functional option for configuring the Tracing.
func WithExporter ¶
func WithExporter(exporter sdktrace.SpanExporter) TracingOption
WithExporter sets a custom span exporter for tracing.
func WithSampleRatio ¶
func WithSampleRatio(ratio float64) TracingOption
WithSampleRatio sets the sample ratio for tracing. Defaults to 1.0 or whatever is set in the CLI flag.
func WithServiceName ¶
func WithServiceName(name string) TracingOption
WithServiceName sets the service name for tracing. Defaults to "service" or whatever is set in the CLI flag.