struct
OpenTelemetry::Context
- OpenTelemetry::Context
- Struct
- Value
- Object
Overview
An immutable set of typed values carried across execution scopes.
Spawned fibers inherit their creator's context. On Crystal 1.19 and 1.20,
an Isolated execution context starts at root. Use #wrap to pass a
captured context to an isolated or already-running fiber.
Concurrency: context bindings are immutable. Stored values must support the caller's sharing pattern. Attachment and activation are fiber-local.
Defined in:
api/context.crConstructors
Class Method Summary
- .attach(context : Context) : Token
- .create_key(name : String, type : T.class) : Key(T) forall T
-
.detach(token : Token) : Bool
Restores the previous context if token is the top attachment in this fiber.
- .suppress_instrumentation(& : -> U) : U forall U
-
.with(context : Context, & : -> U) : U forall U
Runs a block with context current and restores the previous attachment scope.
- .with_value(key : Key(T), value : T, & : -> U) : U forall T, U
Instance Method Summary
- #[]?(key : Key(T)) : T | Nil forall T
- #instrumentation_suppressed? : Bool
- #suppress_instrumentation : Context
- #with_value(key : Key(T), value : T) : Context forall T
- #without(key : Key) : Context
-
#wrap(&block : -> U) : Proc(U) forall U
Captures this context for a callback, including callbacks run on another fiber.
Constructor Detail
Class Method Detail
Restores the previous context if token is the top attachment in this fiber.
Runs a block with context current and restores the previous attachment scope.
Instance Method Detail
Captures this context for a callback, including callbacks run on another fiber.