-
Notifications
You must be signed in to change notification settings - Fork 837
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
Consider returning noop/non-recording span instead of undefined in the case of no active span #3316
Comments
For additional context on what prompted me to open the original otep, the current behavior means whenever we retrieve a span from the context, we need to check if we're not getting nil.
We are migrating a pretty big codebase from opentracing to opentelemetry, and we are being hit quite frequently by context loss.
|
You could use a simple wrapper or optional chaining ( I wonder also a bit about your usecase. To my understanding spans should usually describe some operation but it seems you use it as general purpose container to add attributes without knowing who/where/why a span was created and what it describes. If you use child spans to describe the inner operations above verbose code is not needed as |
Our spans have arbitrarily wide events. And the more data/context they have, they more we're able to figure things out from them. So yes, we add lots of attributes on them on middlewares (which are expected not to create child spans, so we always write on the main HTTP span, but that's another story), so we have the entire context as we know about it. |
I'm not sure the error handling spec is relevant as it is not an error for there not to be an active span. The method signature clearly states there could be an undefined return. Null checks are also not what I think they refer to when they say "significant change" of behavior. |
IMO a stronger argument is to unify the behavior with other SDKs, but I worry this may be considered a breaking change. Currently, you can check if there is an active span by null checking. If we return a valid spanlike object, then that assumption is broken. There are ways we could do this in a backwards compatible way (introduce new method, default-false config, optional argument, or similar mechanism), but we have to decide if that is worth the maintenance cost. |
This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 14 days. |
This issue was closed because it has been stale for 14 days with no activity. |
Just as a datapoint: I ran into an issue with that in the demo application while trying to disable instrumentation: |
Seems like this issue is still valuable to be tracked. Reopening. |
There are several instrumentations which use the existence of a span to decide if they should create a new span (option |
This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 14 days. |
This issue was closed because it has been stale for 14 days with no activity. |
Original discussion here: open-telemetry/opentelemetry-js-api#175
Related otep discussion: open-telemetry/opentelemetry-specification#4304
The user who opened this PR wanted us to return a valid span object any time there is no active span. The related otep discussion shows that other languages are doing this:
I'm opening this issue so that we can discuss the merits and decide what to do. I don't have a strong opinion either way here, but I do think it might be considered a breaking change in behavior.
The text was updated successfully, but these errors were encountered: