Skip to content
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

tracing: trace_call returns None if opentelemetry is not enabled or if no session but that makes it awkward to seamlessly use library, it should return a NoopSpan #1200

Open
1 task
odeke-em opened this issue Sep 11, 2024 · 0 comments
Assignees
Labels
api: spanner Issues related to the googleapis/python-spanner API.

Comments

@odeke-em
Copy link
Contributor

If we examine the code for trace_call it returns None

def trace_call(name, session, extra_attributes=None):
if not HAS_OPENTELEMETRY_INSTALLED or not session:
# Empty context manager. Users will have to check if the generated value is None or a span
yield None
return

and when we try to perform what should be a simple thing like add annotations, we have to awkwardly check if span is not None and that's not a good user experience.

Remedy

  • Let's implement a NoopSpan which has all the methods for a Span but does nothing
@product-auto-label product-auto-label bot added the api: spanner Issues related to the googleapis/python-spanner API. label Sep 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: spanner Issues related to the googleapis/python-spanner API.
Projects
None yet
Development

No branches or pull requests

3 participants