telemetry

package
v0.6.109 Latest Latest
Warning

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

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

Documentation

Overview

Package telemetry installs OpenTelemetry through xtrace's SDK bootstrap: resource from the build identity, exporters from the standard OTEL_* environment. A signal without an OTLP endpoint is not exported (xtrace decides per signal), so a service never retries a collector that does not exist.

Index

Constants

This section is empty.

Variables

View Source
var ErrHistogram = errors.New("telemetry: histogram rule")

ErrHistogram: a histogram rule is invalid.

View Source
var ErrSampler = errors.New("unknown sampler")

ErrSampler: an unknown sampler.

View Source
var MillisecondsBoundaries = []float64{5, 10, 25, 50, 75, 100, 250, 500, 750, 1000, 2500, 5000, 7500, 10000}

MillisecondsBoundaries are SecondsBoundaries in milliseconds.

View Source
var SecondsBoundaries = []float64{0.005, 0.01, 0.025, 0.05, 0.075, 0.1, 0.25, 0.5, 0.75, 1, 2.5, 5, 7.5, 10}

SecondsBoundaries are the buckets of a duration in seconds: OpenTelemetry's semantic conventions for request durations, 5 ms to 10 s.

Functions

func Builtin added in v0.6.16

func Builtin() []config.Histogram

Builtin are the rules after the configured ones: a duration gets buckets of its unit instead of OpenTelemetry's defaults (0 to 10000, made for milliseconds, useless for seconds).

func HistogramView added in v0.6.16

func HistogramView(rules []config.Histogram) (sdkmetric.View, error)

HistogramView is one view applying rules, then Builtin, to every histogram: the first rule matching its name (and unit) decides its aggregation. One view, not one per rule: OpenTelemetry exports a stream per matching view, so overlapping rules would duplicate the histogram.

func Sampler added in v0.6.27

func Sampler(t config.Traces) (sdktrace.Sampler, error)

Sampler is the sampler of traces.

Types

type Identity

type Identity struct {
	Service, Version, Instance, Environment string
}

Identity stamped into the resource.

type Telemetry

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

Telemetry is a lifecycle component; start it first, it stops last.

func New

func New(id Identity, cfg config.Telemetry, log *xlog.Logger) *Telemetry

New creates the component; the section was validated (HistogramView, Sampler).

func (*Telemetry) Start

func (t *Telemetry) Start(ctx context.Context) error

Start installs global providers and the propagator.

func (*Telemetry) Status

func (t *Telemetry) Status() (configured, up bool, err error)

Status of OTLP export for the instance state: configured when an OTEL_EXPORTER_OTLP_*ENDPOINT is set; up unless the setup failed (export errors after setup are not tracked).

func (*Telemetry) Stop

func (t *Telemetry) Stop(ctx context.Context) error

Stop flushes and shuts the providers down within ctx; a flush that fails is logged, never a stop failure.

Jump to

Keyboard shortcuts

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