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

Re-raise errors caught in opentelemetry.sdk.trace.Tracer.use_span() #469

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion opentelemetry-sdk/src/opentelemetry/sdk/trace/__init__.py
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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