telemetry

package module
v0.0.0-...-1ca2c95 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2026 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CLIFlagDebug = &cli.BoolFlag{
	Name:    "debug",
	Usage:   "Enable debug mode",
	Value:   false,
	EnvVars: []string{"DEBUG"},
}
View Source
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"},
}
View Source
var CLIFlagServiceName = &cli.StringFlag{
	Name:    "service-name",
	Usage:   "service name for tracing",
	Value:   "service",
	EnvVars: []string{"SERVICE_NAME"},
}
View Source
var CLIFlagTracingRootSampleRatios = &cli.StringSliceFlag{
	Name:    "tracing-root-sample-ratios",
	Usage:   "per-span-name sample ratios for root spans, e.g. HandleStreamEvent=0.01 (overrides tracing-sample-ratio for those roots)",
	EnvVars: []string{"TRACING_ROOT_SAMPLE_RATIOS"},
}
View Source
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

func StartTracing(cctx *cli.Context, opts ...TracingOption) (func(context.Context) error, error)

func WithoutChildSpans

func WithoutChildSpans(ctx context.Context) context.Context

WithoutChildSpans returns ctx with an unsampled current span, so spans started under it (by the ParentBased sampler) are dropped. For loops into library code that opens a span per item, such as indigo's per-record repo.GetRecord: with no traced parent each of those is its own root trace. The trace ID of ctx's span is kept so logs still correlate.

Types

type Logging

type Logging struct {
	// contains filtered or unexported fields
}

type LoggingOption

type LoggingOption func(*Logging)

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 Metrics

type Metrics struct {
	// contains filtered or unexported fields
}

type MetricsOption

type MetricsOption func(*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. An empty address disables the server, as an empty flag does.

func WithPath

func WithPath(path string) MetricsOption

WithPath sets the path for the metrics server. Defaults to "/metrics".

type Tracing

type Tracing struct {
	// contains filtered or unexported fields
}

type TracingOption

type TracingOption func(*Tracing)

func WithExporter

func WithExporter(exporter sdktrace.SpanExporter) TracingOption

func WithRootSpanRatio

func WithRootSpanRatio(name string, ratio float64) TracingOption

WithRootSpanRatio sets the sample ratio for root spans with this name. Entries from the tracing-root-sample-ratios flag take precedence.

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.

Directories

Path Synopsis
Package ops serves a service's operator endpoints, /metrics and net/http/pprof, on a listener of their own, apart from the service's API and its auth.
Package ops serves a service's operator endpoints, /metrics and net/http/pprof, on a listener of their own, apart from the service's API and its auth.
Package robusthttp is an HTTP client for talking to other services: sane timeouts and connection pooling, retries with exponential backoff for safe requests, and an OpenTelemetry span per attempt.
Package robusthttp is an HTTP client for talking to other services: sane timeouts and connection pooling, retries with exponential backoff for safe requests, and an OpenTelemetry span per attempt.

Jump to

Keyboard shortcuts

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