-
Notifications
You must be signed in to change notification settings - Fork 650
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Offer a specific/static no-op Span
instance.
#41
Comments
Yeah, a designated instance would be nice, if only to improve performance. If we want to enforce that there can be only one instance of plain We could even override |
👍 for having our own designated default span singleton. One argument for making this a module-level constant is that it means one less concrete method in the API class (assuming you're saying we'd implement @Oberon00 you think it's worth locking down instantiation of |
If you think that it is always a mistake to create a new Span then yes. It's easy after all: class Span:
""""..."""
INVALID_SPAN = Span()
def _init_span(self):
if type(self) is Span: raise RuntimeError("Cannot create a new plain Span")
Span.__init__ = _init_span Then there is also always the argument that allowing something later is a new feature but banning something later is a breaking change. |
At least in Java, a few |
Closed by #63. |
In Java, we have a
DefaultSpan
which does nothing by default (it can propagateSpanContext
too, but that's more of additional stuff), and can be used as both a no-op object.Specifically,
DefaultSpan.getInvalid()
offers a static instance that can also be used when setting parent (throughSpanBuilder.serParent()
) and also forTracer.getCurrentSpan()
(so the user doesn't have to do anull
check).As
Span
at this moment already has this no-op functionality, maybe it makes sense to add a class field? This way we could do:The text was updated successfully, but these errors were encountered: