otel

package
v0.10.14 Latest Latest
Warning

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

Go to latest
Published: May 18, 2026 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Overview

Package otel provides OpenTelemetry tracing integration using OTLP exporters.

Note: This package was originally designed for Jaeger integration, but since OpenTelemetry dropped support for the Jaeger exporter in July 2023, it now uses OTLP (OpenTelemetry Protocol) exporters instead. Jaeger officially accepts and recommends using OTLP for sending traces.

Supported exporter types:

  • otlp-http: OTLP over HTTP (recommended for most use cases)
  • otlp-grpc: OTLP over gRPC (for high-performance scenarios)

The package maintains backward compatibility by keeping the same configuration structure and API, but internally uses OTLP exporters to send traces to Jaeger or other OTLP-compatible backends like Uptrace.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrOTELIsDisabled = errors.New("otel is disabled")
)

Functions

func AddSpanEvent

func AddSpanEvent(span trace.Span, name string, attrs ...attribute.KeyValue)

AddSpanEvent adds an event to the current span

func AddSpanTags

func AddSpanTags(span trace.Span, tags map[string]any)

AddSpanTags adds tags to the current span

func Close

func Close() error

Close closes the Jaeger tracer

func GetTracer

func GetTracer() trace.Tracer

GetTracer returns the global tracer

func Init

func Init() error

Init initializes the OpenTelemetry tracer with OTLP exporters. This function replaces the deprecated Jaeger exporter with OTLP exporters that are compatible with Jaeger and other tracing backends.

func IsEnabled

func IsEnabled() bool

IsEnabled returns whether Jaeger tracing is enabled

func RecordError

func RecordError(span trace.Span, err error)

RecordError records an error in the current span

func SpanFromContext

func SpanFromContext(ctx context.Context) trace.Span

SpanFromContext returns the span from the context

func StartSpan

func StartSpan(ctx context.Context, name string, opts ...trace.SpanStartOption) (context.Context, trace.Span)

StartSpan starts a new span with the given name and options

Types

This section is empty.

Jump to

Keyboard shortcuts

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