telemetry

package
v0.0.0-...-5d187b5 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2026 License: Apache-2.0 Imports: 15 Imported by: 0 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

Overview

Package telemetry wires OpenTelemetry: traces and metrics exported over OTLP.

One SDK covers both signals and stays vendor-neutral — the collector decides where data actually goes, so switching backends is a collector config change rather than a code change.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Meter

func Meter(name string) metric.Meter

Meter returns a meter for a component.

func Tracer

func Tracer(name string) trace.Tracer

Tracer returns a tracer for a component, so callers do not repeat the instrumentation scope name.

Types

type Config

type Config struct {
	// Enabled turns exporting on. When false the service still runs and the
	// OTel API still works — it just resolves to no-ops, so local development
	// never requires a collector.
	Enabled bool `yaml:"Enabled"`

	ServiceName    string `yaml:"ServiceName"`
	ServiceVersion string `yaml:"ServiceVersion"`
	Environment    string `yaml:"Environment"`

	// Endpoint is the OTLP/gRPC collector address, e.g. localhost:4317.
	Endpoint string `yaml:"Endpoint"`
	// Insecure disables TLS to the collector. True for a local collector,
	// false anywhere the data crosses a network worth protecting.
	Insecure bool `yaml:"Insecure"`

	// SampleRatio is the fraction of traces recorded, 0..1. Payments volume is
	// low (plan.md Q6), so sampling everything is affordable and much more
	// useful when investigating a single customer's failed payment.
	SampleRatio float64 `yaml:"SampleRatio"`

	// MetricInterval is how often metrics are pushed to the collector.
	MetricInterval time.Duration `yaml:"MetricInterval"`
}

type Shutdown

type Shutdown func(ctx context.Context) error

Shutdown flushes pending telemetry. Call it on the way out, or the last spans before a crash — the interesting ones — are lost.

func Setup

func Setup(ctx context.Context, cfg *Config) (Shutdown, error)

Setup installs the global tracer and meter providers and returns a shutdown.

It never returns an error for a missing collector: telemetry must not be able to stop a payments service from starting. An unreachable collector shows up as export errors in the log, not as a failed boot.

Jump to

Keyboard shortcuts

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