Documentation
¶
Overview ¶
Package context mirrors Ruby's OpenTelemetry::Context — the immutable, key/value execution context that carries the current span, baggage and any user values across API boundaries.
It is a thin, Ruby-faithful facade over Go's standard context.Context: a Context wraps a Go context so that the OpenTelemetry Go SDK (go.opentelemetry.io/otel) can be driven underneath while callers use the method names and semantics of the opentelemetry-ruby gem.
Like MRI, a Context is immutable: Set returns a new Context and never mutates the receiver. The package also reproduces Ruby's process-wide "current" context managed through Attach/Detach tokens (OpenTelemetry::Context.current, .attach, .detach and .with_current).
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Clear ¶
func Clear()
Clear resets the current-context stack. It exists so tests (and long-lived hosts embedding the runtime) can return to a pristine state.
func Detach ¶
Detach mirrors OpenTelemetry::Context.detach(token). It pops back to the context that was current when tok was produced and reports whether the token matched the top of the stack (Ruby logs a warning on mismatch; here the mismatch is reported to the caller and the stack is left untouched).
Types ¶
type Context ¶
type Context struct {
// contains filtered or unexported fields
}
Context is the Ruby-faithful OpenTelemetry::Context. It wraps a Go context so values, spans and baggage stored by the backing SDK travel with it.
func Background ¶
func Background() *Context
Background returns the empty root Context (OpenTelemetry::Context::ROOT).
func Current ¶
func Current() *Context
Current mirrors OpenTelemetry::Context.current. It returns the most recently attached Context, or the empty root Context when none is attached.
func FromGo ¶
FromGo adapts a standard Go context into a Ruby-faithful Context. It is the seam through which the backing SDK's context (holding the active span and baggage) is surfaced to callers.
type Key ¶
type Key struct {
// contains filtered or unexported fields
}
Key identifies a value stored in a Context. Distinct Key values never collide even when they share a name, matching MRI's Context.create_key: identity is by the underlying pointer, not the descriptive name.