trace

package
v3.15.0 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2026 License: Apache-2.0 Imports: 14 Imported by: 1 module, 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

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Generate

func Generate() string

func Get

func Get(ctx context.Context) (t string)

func GetJob added in v3.14.0

func GetJob(ctx context.Context) (job string)

GetJob returns the name of the background job that caused the request.

func InitProvider added in v3.7.0

func InitProvider(ctx context.Context, cfg ProviderConfig) (func(context.Context) error, error)

InitProvider sets up the global OTel TracerProvider and W3C TraceContext propagator.

If tracing is disabled or no endpoint is configured, the provider returned is just a nop.

The returned shutdown function must be called (e.g. via defer) to flush and stop the exporter.

func Set

func Set(ctx context.Context, trace string) context.Context

ContextSetTrace stores the trace in the context.

func SetJob added in v3.14.0

func SetJob(ctx context.Context, job string) context.Context

SetJob stores the name of the background job in the context. It goes to other services with the trace id, so their logs can be filtered by job.

Types

type ProviderConfig added in v3.7.0

type ProviderConfig struct {
	Enabled     bool
	Endpoint    string // OTLP/gRPC endpoint, e.g. "localhost:4317"
	Collector   string // OTLP/HTTP collector URL, e.g. "http://localhost:4318"
	ServiceName string
	Log         *zerolog.Logger
}

ProviderConfig holds the tracing configuration.

Jump to

Keyboard shortcuts

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