-
Notifications
You must be signed in to change notification settings - Fork 274
Open
Labels
Description
def current_span(context = nil) |
I need to know if there is a valid span or not.
Is the best we can do:
::OpenTelemetry::Trace.current_span == ::OpenTelemetry::Trace::Span::INVALID
This seems pretty clunky to me.
Maybe we can fix this:
- Introduce
::OpenTelemetry::Trace.current_span?
which returns nil if no context/current span (?
suffix means optional). - Introduce a keyword argument
def current_span(default: Span::INVALID)
so we could invokecurrent_span(default: nil)
. - Introduce
Span#valid?
or something like that, e.g.::OpenTelemetry::Trace.current_span.valid?
.
For now, I'll use ::OpenTelemetry::Trace.current_span == ::OpenTelemetry::Trace::Span::INVALID
because that's the best option that currently works, but I think using a sentinel value is a bit ugly.