Documentation
¶
Overview ¶
Package sdktrace mirrors Ruby's OpenTelemetry::SDK::Trace — the configurable tracing implementation from the opentelemetry-sdk gem.
It is a Ruby-faithful facade over go.opentelemetry.io/otel/sdk/trace: the TracerProvider wires span processors, samplers and exporters exactly as the Ruby SDK does, while delegating all recording, sampling and batching to the real Go SDK. The exporter is an injectable seam; an in-memory exporter is provided for tests and in-process use (OTLP/stdout wiring is a follow-up).
Index ¶
- type Event
- type FinishedSpan
- func (s FinishedSpan) Attributes() map[string]any
- func (s FinishedSpan) EndTimestamp() time.Time
- func (s FinishedSpan) Events() []Event
- func (s FinishedSpan) HexParentSpanID() string
- func (s FinishedSpan) HexTraceID() string
- func (s FinishedSpan) Kind() rbtrace.SpanKind
- func (s FinishedSpan) Name() string
- func (s FinishedSpan) ParentSpanContext() rbtrace.SpanContext
- func (s FinishedSpan) Sampled() bool
- func (s FinishedSpan) SpanContext() rbtrace.SpanContext
- func (s FinishedSpan) StartTimestamp() time.Time
- func (s FinishedSpan) Status() rbtrace.Status
- type InMemorySpanExporter
- type Option
- type Sampler
- type SpanExporter
- type SpanProcessor
- type TracerProvider
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FinishedSpan ¶
type FinishedSpan struct {
// contains filtered or unexported fields
}
FinishedSpan mirrors an OpenTelemetry::SDK::Trace::SpanData — the read-only snapshot of a finished span as seen by an exporter.
func (FinishedSpan) Attributes ¶
func (s FinishedSpan) Attributes() map[string]any
Attributes mirrors SpanData#attributes as a Ruby-style hash.
func (FinishedSpan) EndTimestamp ¶
func (s FinishedSpan) EndTimestamp() time.Time
EndTimestamp mirrors SpanData#end_timestamp (monotonic UTC).
func (FinishedSpan) HexParentSpanID ¶
func (s FinishedSpan) HexParentSpanID() string
HexParentSpanID mirrors SpanData#parent_span_id in W3C hex form.
func (FinishedSpan) HexTraceID ¶
func (s FinishedSpan) HexTraceID() string
HexTraceID mirrors SpanData#trace_id in W3C hex form.
func (FinishedSpan) Kind ¶
func (s FinishedSpan) Kind() rbtrace.SpanKind
Kind mirrors SpanData#kind.
func (FinishedSpan) ParentSpanContext ¶
func (s FinishedSpan) ParentSpanContext() rbtrace.SpanContext
ParentSpanContext returns the parent's SpanContext (invalid for a root span).
func (FinishedSpan) Sampled ¶
func (s FinishedSpan) Sampled() bool
Sampled reports whether the span was sampled.
func (FinishedSpan) SpanContext ¶
func (s FinishedSpan) SpanContext() rbtrace.SpanContext
SpanContext mirrors SpanData#context.
func (FinishedSpan) StartTimestamp ¶
func (s FinishedSpan) StartTimestamp() time.Time
StartTimestamp mirrors SpanData#start_timestamp (monotonic UTC).
func (FinishedSpan) Status ¶
func (s FinishedSpan) Status() rbtrace.Status
Status mirrors SpanData#status.
type InMemorySpanExporter ¶
type InMemorySpanExporter struct {
*tracetest.InMemoryExporter
}
InMemorySpanExporter mirrors OpenTelemetry::SDK::Trace::Export::InMemorySpanExporter — a SpanExporter that keeps finished spans in memory instead of shipping them anywhere. It is the injectable exporter seam used for tests and in-process inspection, so the core works with zero network.
func NewInMemorySpanExporter ¶
func NewInMemorySpanExporter() *InMemorySpanExporter
NewInMemorySpanExporter returns a fresh in-memory exporter.
func (*InMemorySpanExporter) FinishedSpans ¶
func (e *InMemorySpanExporter) FinishedSpans() []FinishedSpan
FinishedSpans mirrors #finished_spans: the spans exported so far, in export order, as Ruby-faithful read-only handles.
type Option ¶
type Option func(*config)
Option configures a TracerProvider, mirroring the keyword configuration of OpenTelemetry::SDK.configure.
func WithSampler ¶
WithSampler sets the sampler (the SDK's :sampler config).
func WithSpanProcessor ¶
func WithSpanProcessor(p SpanProcessor) Option
WithSpanProcessor registers a span processor (add_span_processor).
type Sampler ¶
type Sampler = otelsdktrace.Sampler
Sampler mirrors OpenTelemetry::SDK::Trace::Samplers — the per-span decision to record and sample.
func AlwaysOff ¶
func AlwaysOff() Sampler
AlwaysOff mirrors OpenTelemetry::SDK::Trace::Samplers::ALWAYS_OFF.
func AlwaysOn ¶
func AlwaysOn() Sampler
AlwaysOn mirrors OpenTelemetry::SDK::Trace::Samplers::ALWAYS_ON.
func ParentBased ¶
ParentBased mirrors OpenTelemetry::SDK::Trace::Samplers.parent_based(root:): it honours the parent's sampling decision and falls back to root for local roots.
func TraceIDRatioBased ¶
TraceIDRatioBased mirrors OpenTelemetry::SDK::Trace::Samplers.trace_id_ratio_based(ratio).
type SpanExporter ¶
type SpanExporter = otelsdktrace.SpanExporter
SpanExporter mirrors OpenTelemetry::SDK::Trace::Export::SpanExporter — the injectable sink a batch/simple processor flushes finished spans to.
type SpanProcessor ¶
type SpanProcessor = otelsdktrace.SpanProcessor
SpanProcessor mirrors OpenTelemetry::SDK::Trace::SpanProcessor — the hook that receives spans as they start and finish. Simple and Batch implementations are provided by NewSimpleSpanProcessor and NewBatchSpanProcessor.
func NewBatchSpanProcessor ¶
func NewBatchSpanProcessor(exporter SpanExporter) SpanProcessor
NewBatchSpanProcessor mirrors OpenTelemetry::SDK::Trace::Export::BatchSpanProcessor — it buffers spans and exports them in batches.
func NewSimpleSpanProcessor ¶
func NewSimpleSpanProcessor(exporter SpanExporter) SpanProcessor
NewSimpleSpanProcessor mirrors OpenTelemetry::SDK::Trace::Export::SimpleSpanProcessor — it exports each span synchronously as it finishes.
type TracerProvider ¶
type TracerProvider struct {
// contains filtered or unexported fields
}
TracerProvider mirrors OpenTelemetry::SDK::Trace::TracerProvider.
func NewTracerProvider ¶
func NewTracerProvider(opts ...Option) *TracerProvider
NewTracerProvider mirrors OpenTelemetry::SDK::Trace::TracerProvider.new: it builds a provider from the given processors and sampler.
func (*TracerProvider) AddSpanProcessor ¶
func (p *TracerProvider) AddSpanProcessor(sp SpanProcessor)
AddSpanProcessor mirrors #add_span_processor.
func (*TracerProvider) ForceFlush ¶
func (p *TracerProvider) ForceFlush() error
ForceFlush mirrors #force_flush: it flushes all registered processors.
func (*TracerProvider) Shutdown ¶
func (p *TracerProvider) Shutdown() error
Shutdown mirrors #shutdown: it flushes and shuts down all processors.