-
Notifications
You must be signed in to change notification settings - Fork 685
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
Move useSpan() out of Tracer #1630
Move useSpan() out of Tracer #1630
Comments
I can take this. To clarify, we want to move |
@owais |
Propagation module makes sense as it already contains I don't feel too strongly about it though so I'm fine either way. |
I don't feel too strongly either but I'd to not take on more work than necessary. |
|
Sure, @owais let's go with the above suggestion. |
I have a WIP branch for this but we might have a problem here. The use_span method implicitly depends on the SDK. It doesn't import or refer to anything in the SDK but the logic it contains depends on SDK's Span implementation: Lines 968, 974 and 975 here: https://github.com/open-telemetry/opentelemetry-python/blob/main/opentelemetry-sdk/src/opentelemetry/sdk/trace/__init__.py#L954 I got rid of 968 and 975 by making use_span accept While this works and doesn't add SDK as a dependency to API, it still embeds knowledge about the SDK Span implementation inside an API function. It means 3rd party Span implementations might not work as expected. I'm not sure if it is worth moving out of tracer at this point. The logic doesn't need tracer but it is implicitly bound to the span implementation. What do you think? @lzchen @carlosalberto @codeboten |
BTW what are your thoughts removing the check entirely and always setting status. How bad is it if a status is already set on span but If we move the check, we remove the implicit dependency. Thoughts? |
@owais |
I agree but the more I think about it, the more I'm convinced current behavior of def func():
with use_span(span, set_status_on_exception=True, end_on_exit=True):
result = some_operation()
if result.ok:
span.set_status(Status(StatusCode.OK))
return json.dumps(result) Intuitively user would expect span to have OK unless Span API allows overwriting status so looks like we are fine with that. If we "fix" this behavior, we can move forward with this change but even if we don't, I think use_span should still be updated to overwrite status when an exception is raised and |
The spec actually clarifies this at the very end in the following section.
So looks like this check is unnecessary and should actually be removed. I'll update the PR accordingly. |
Currently the Specification expects that the current Span handling happens in a single place, either module level functions or in a class, and whereas
set_span_in_context()
andget_current_span()
live in thetrace
module,useSpan()
exists in theTracer
.The text was updated successfully, but these errors were encountered: