Module: RackExtension
- Defined in:
- lib/instrumentation/rails.rb
Class Method Summary collapse
-
.context_with_span(span, parent_context: OpenTelemetry::Context.current) ⇒ Object
Returns a context containing the span, derived from the optional parent context, or the current context if one was not provided.
-
.current_span(context = nil) ⇒ Object
Returns the current span from the current or provided context.
-
.with_span(span) {|span, context| ... } ⇒ Object
Activates/deactivates the Span within the current Context, which makes the “current span” available implicitly.
Class Method Details
.context_with_span(span, parent_context: OpenTelemetry::Context.current) ⇒ Object
Returns a context containing the span, derived from the optional parent context, or the current context if one was not provided.
32 33 34 |
# File 'lib/instrumentation/rails.rb', line 32 def context_with_span(span, parent_context: OpenTelemetry::Context.current) parent_context.set_value(CURRENT_SPAN_KEY, span) end |
.current_span(context = nil) ⇒ Object
Returns the current span from the current or provided context
22 23 24 25 |
# File 'lib/instrumentation/rails.rb', line 22 def current_span(context = nil) context ||= OpenTelemetry::Context.current context.value(CURRENT_SPAN_KEY) || OpenTelemetry::Trace::Span::INVALID end |
.with_span(span) {|span, context| ... } ⇒ Object
Activates/deactivates the Span within the current Context, which makes the “current span” available implicitly.
On exit, the Span that was active before calling this method will be reactivated.
43 44 45 |
# File 'lib/instrumentation/rails.rb', line 43 def with_span(span) OpenTelemetry::Context.with_value(CURRENT_SPAN_KEY, span) { |c, s| yield s, c } end |