opttrace

package
v0.13.2 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2024 License: BSD-3-Clause Imports: 12 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Option

type Option func(*config) error

Option provides Tracer configuration options

func WithBatchOptions

func WithBatchOptions(opts []sdktrace.BatchSpanProcessorOption) Option

WithBatchOptions allows overriding the default span batch processing options.

func WithExporter

func WithExporter(exp sdktrace.SpanExporter) Option

WithExporter sets a span exporter other than standard one provided by WithOTLPExporter.

func WithOTLPExporter

func WithOTLPExporter(endpointURI string) Option

WithOTLPExporter configured an OTLP trace exporter

func WithSampler

func WithSampler(sampler sdktrace.Sampler) Option

WithSampler sets the sampler to be used by the underlying tracing provider. If not set, it takes the default of sampling based on whether the parent span was sampled.

func WithSyncExport

func WithSyncExport() Option

WithSyncExport can be used in tests and disables batch span processing.

type Tracer

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

Tracer provides a tracing interface that generates traces only if configured with a trace exporter

func New

func New(ctx context.Context, serviceName string, opts ...Option) (*Tracer, error)

New creates a Tracer that will create spans if configured with an exporter. If not, the Span method will use a no-op tracing provider. When enabled, the spans will have the supplied service name. The context is used to initialize a configured OTLP exporter, if any.

func (Tracer) SetGlobalTracer added in v0.13.1

func (t Tracer) SetGlobalTracer()

SetGlobalTracer sets the global tracer provider to this tracer instance

func (Tracer) Shutdown

func (t Tracer) Shutdown(ctx context.Context) error

Shutdown releases all resources allocated by the tracing provider.

func (Tracer) Span

func (t Tracer) Span(ctx context.Context, spanName string, opts ...trace.SpanStartOption) (context.Context, trace.Span)

Span creates a new trace span and returns the supplied context with span added. The returned span must be ended to avoid leaking resources.

Jump to

Keyboard shortcuts

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