Skip to content

Commit

Permalink
Re-raise errors caught in opentelemetry.sdk.trace.Tracer.use_span()
Browse files Browse the repository at this point in the history
  • Loading branch information
David Grochowski committed Mar 7, 2020
1 parent 9ed98eb commit ff587a8
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
2 changes: 1 addition & 1 deletion opentelemetry-sdk/src/opentelemetry/sdk/trace/__init__.py
Expand Up @@ -524,7 +524,7 @@ def use_span(
)
)

raise
raise

finally:
if end_on_exit:
Expand Down
26 changes: 26 additions & 0 deletions opentelemetry-sdk/tests/trace/test_trace.py
Expand Up @@ -679,6 +679,32 @@ def error_status_test(context):
.start_as_current_span("root")
)

def test_override_error_status(self):
def error_status_test(context):
with self.assertRaises(AssertionError):
with context as root:
root.set_status(
trace_api.status.Status(
StatusCanonicalCode.UNAVAILABLE,
"Error: Unavailable",
)
)
raise AssertionError("unknown")

self.assertIs(
root.status.canonical_code, StatusCanonicalCode.UNAVAILABLE
)
self.assertEqual(root.status.description, "Error: Unavailable")

error_status_test(
trace.TracerProvider().get_tracer(__name__).start_span("root")
)
error_status_test(
trace.TracerProvider()
.get_tracer(__name__)
.start_as_current_span("root")
)


def span_event_start_fmt(span_processor_name, span_name):
return span_processor_name + ":" + span_name + ":start"
Expand Down

0 comments on commit ff587a8

Please sign in to comment.