Skip to content

Commit

Permalink
Reduce code surface when in trace_call
Browse files Browse the repository at this point in the history
  • Loading branch information
odeke-em committed Nov 14, 2024
1 parent 3df53de commit a316d0a
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions google/cloud/spanner_v1/_opentelemetry_tracing.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,17 +79,12 @@ def trace_call(name, session, extra_attributes=None):
try:
yield span
except Exception as error:
set_span_error_and_record_exception(span, error)
raise
span.set_status(Status(StatusCode.ERROR, str(error)))
span.record_exception(error)
raise error
else:
span.set_status(Status(StatusCode.OK))


def set_span_error_and_record_exception(span, exc):
if exc and span:
span.set_status(Status(StatusCode.ERROR, str(exc)))
span.record_exception(exc)


def get_current_span():
return trace.get_current_span()

0 comments on commit a316d0a

Please sign in to comment.