otel

package
v0.1.102 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2026 License: Apache-2.0 Imports: 25 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

View Source
const TracePaused paused = "trace-paused"

Variables

This section is empty.

Functions

func NewPlugin

func NewPlugin(opts ...Option) gorm.Plugin

func WithSkipSpan

func WithSkipSpan(ctx context.Context) context.Context

Types

type CounterSampler

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

CounterSampler samples spans based on a counter, ensuring a percentage of spans are sampled.

func NewCounterSampler

func NewCounterSampler(percentage float64) *CounterSampler

NewCounterSampler creates a new CounterSampler. `percentage` should be a value between 0 and 100, representing the percentage of spans to sample.

func (*CounterSampler) Description

func (cs *CounterSampler) Description() string

Description returns the description of the sampler.

func (*CounterSampler) ShouldSample

func (cs *CounterSampler) ShouldSample(params trace.SamplingParameters) trace.SamplingResult

ShouldSample decides whether a span should be sampled based on a counter.

type CustomSampler

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

CustomSampler struct holds different samplers.

func NewCustomSampler

func NewCustomSampler(defaultSampler trace.Sampler, samplers map[string]trace.Sampler) *CustomSampler

NewCustomSampler creates a new instance of CustomSampler. `defaultSampler` is used when no specific sampler is found for a span name. `samplers` is a map where keys are span names and values are the specific samplers for those span names.

func (*CustomSampler) Description

func (cs *CustomSampler) Description() string

Description returns a description of the sampler.

func (*CustomSampler) ShouldSample

func (cs *CustomSampler) ShouldSample(params trace.SamplingParameters) trace.SamplingResult

ShouldSample implements the Sampler interface. It delegates the decision to a sampler based on the span name.

type Option

type Option func(p *otelPlugin)

func WithAttributes

func WithAttributes(attrs ...attribute.KeyValue) Option

WithAttributes configures attributes that are used to create a span.

func WithDBName

func WithDBName(name string) Option

WithDBName configures a db.name attribute.

func WithQueryFormatter

func WithQueryFormatter(queryFormatter func(query string) string) Option

WithQueryFormatter configures a query formatter

func WithTracerProvider

func WithTracerProvider(provider trace.TracerProvider) Option

WithTracerProvider configures a tracer provider that is used to create a tracer.

func WithoutMetrics

func WithoutMetrics() Option

WithoutMetrics prevents DBStats metrics from being reported.

func WithoutQueryVariables

func WithoutQueryVariables() Option

WithoutQueryVariables configures the db.statement attribute to exclude query variables

type Tracer

type Tracer struct {
	ServiceName    string
	CollectorURL   string
	Insecure       bool
	Samplers       map[string]sdktrace.Sampler
	SpanProcessors []sdktrace.SpanProcessor
	Exporter       sdktrace.SpanExporter
	// Sampler is the root sampler for spans no entry in Samplers matches; nil samples every span.
	Sampler sdktrace.Sampler
}

func TracerFromEnv added in v0.1.101

func TracerFromEnv(service, collector string, getenv func(string) string) (tracer Tracer, ok bool, err error)

TracerFromEnv resolves a Tracer from an explicit collector (e.g. a --otel-collector flag) or the standard OTEL_* environment. ok is false when no collector is configured.

func (Tracer) Init

func (tracer Tracer) Init() (func(), error)

func (Tracer) Sample

func (tracer Tracer) Sample(name string, perc float64) Tracer

func (Tracer) Start added in v0.1.69

func (tracer Tracer) Start(ctx context.Context) (func(context.Context) error, error)

Start installs the global SDK tracer provider and returns a shutdown that flushes buffered spans before closing the exporter. An empty CollectorURL installs the provider without an exporter, so only SpanProcessors see spans.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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