otel

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package otel bootstraps OpenTelemetry trace and metric pipelines for chassis-go services. It is the sole SDK consumer — all other chassis modules depend only on OTel API packages.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AlwaysSample

func AlwaysSample() sdktrace.Sampler

AlwaysSample returns a sampler that samples every trace.

func DetachContext

func DetachContext(ctx context.Context) context.Context

DetachContext returns a new context.Background() populated with the OTel SpanContext from the original context. Cancellation is detached; trace correlation is preserved. Use this when spawning goroutines from request handlers.

func RatioSample

func RatioSample(fraction float64) sdktrace.Sampler

RatioSample returns a sampler that samples a fraction of traces.

Types

type Config

type Config struct {
	ServiceName    string
	ServiceVersion string
	Endpoint       string           // OTLP gRPC endpoint, defaults to localhost:4317
	Sampler        sdktrace.Sampler // defaults to AlwaysSample
}

Config configures the OpenTelemetry bootstrap.

type ShutdownFunc

type ShutdownFunc func(ctx context.Context) error

ShutdownFunc drains and closes all OTel providers.

func Init

func Init(cfg Config) ShutdownFunc

Init initializes OpenTelemetry trace and metric pipelines. Returns a ShutdownFunc that must be called on process exit.

Jump to

Keyboard shortcuts

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