Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

tracing: avoid returning None if OpenTelemetry is not installed; instead return a custom noop-span #15909

Copy link
Copy link

Description

@odeke-em
Issue body actions

Trying to uniformly instrument this library is really tricky in the case that OpenTelemetry is not installed.
Currently the code returns None in the case that the dependency wasn't imported.

Trying to invoke

with trace_call('foo') as span:
    if span:
         # Add code

and then in other cases where we need to add span annotations firstly having to check if span is not None is awkward such as in googleapis/python-spanner#1207

if span is not None:
    span.add_event(...)

we shouldn't labor ourselves with dependency implementation details which constitutes a leaky abstraction.

Suggestion

Let's implement a NoopSpan class that'll be returned on every invocation if not installed and that should make it clean for this package to freely add events.

/cc @harshachinta @surbhigarg92

Reactions are currently unavailable

Metadata

Metadata

Assignees

Labels

api: spannerIssues related to the Spanner API.Issues related to the Spanner API.

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    Morty Proxy This is a proxified and sanitized view of the page, visit original site.