We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
sys.exit(0)
SystemExit
OS: (e.g, Ubuntu) Python version: (e.g., Python 3.13.2) SDK version: (e.g., 1.31.0) API version: (e.g., 1.31.0)
After upgrade from 1.30.0 to 1.31.0 this code started producing a span with SystemExit error:
with tracer.start_as_current_span("test-exit-code"): sys.exit(0)
Related to #4406
def main(): resource = Resource(attributes={SERVICE_NAME: "test-exit-code"}) tracerProvider = TracerProvider(resource=resource) stream = StringIO() processor = BatchSpanProcessor(ConsoleSpanExporter(out=stream)) tracerProvider.add_span_processor(processor) trace.set_tracer_provider(tracerProvider) tracer = trace.get_tracer(__name__) try: with tracer.start_as_current_span("test-exit-code"): sys.exit(0) except SystemExit: pass while stream.getvalue() == "": time.sleep(0.5) span = json.loads(stream.getvalue()) print(span)
{ "name": "test-exit-code", "context": { "trace_id": "0x644b4d5832f13a490133e4b44d72a476", "span_id": "0x34b0785025ce90ab", "trace_state": "[]" }, "kind": "SpanKind.INTERNAL", "parent_id": null, "start_time": "2025-03-18T13:02:28.415717Z", "end_time": "2025-03-18T13:02:28.415733Z", "status": { "status_code": "UNSET" }, "attributes": {}, "events": [], "links": [], "resource": { "attributes": { "service.name": "test-exit-code" }, "schema_url": "" } }
{ "name": "test-exit-code", "context": { "trace_id": "0xaa4145b80399a253002020b3afc45226", "span_id": "0xe492dbcd05893ead", "trace_state": "[]" }, "kind": "SpanKind.INTERNAL", "parent_id": null, "start_time": "2025-03-18T13:03:48.253080Z", "end_time": "2025-03-18T13:03:48.254344Z", "status": { "status_code": "ERROR", "description": "SystemExit: 0" }, "attributes": {}, "events": [ { "name": "exception", "timestamp": "2025-03-18T13:03:48.254331Z", "attributes": { "exception.type": "SystemExit", "exception.message": "0", "exception.stacktrace": "Traceback (most recent call last):\n File \"/home/grihabor/.cache/pants/named_caches/pex_root/venvs/1/s/7156ea6e/venv/lib/python3.11/site-packages/opentelemetry/ace/__init__.py\", line 587, in use_span\n yield span\n File \"/home/grihabor/.cache/pants/named_caches/pex_root/venvs/1/s/7156ea6e/venv/lib/python3.11/site-packages/opentelemetry/sdk/trace/__init__.\", line 1105, in start_as_current_span\n yield span\n File \"src/python/observability/otel/exit_test.py\", line 21, in test_exit_code\n sys.exit(0)\nSystemExit: 0\n", "exception.escaped": "False" } } ], "links": [], "resource": { "attributes": { "service.name": "test-exit-code" }, "schema_url": "" } }
No response
None
The text was updated successfully, but these errors were encountered:
sys.exit(1)
Successfully merging a pull request may close this issue.
Describe your environment
OS: (e.g, Ubuntu)
Python version: (e.g., Python 3.13.2)
SDK version: (e.g., 1.31.0)
API version: (e.g., 1.31.0)
What happened?
After upgrade from 1.30.0 to 1.31.0 this code started producing a span with
SystemExit
error:Related to #4406
Steps to Reproduce
Expected Result
Actual Result
Additional context
No response
Would you like to implement a fix?
None
The text was updated successfully, but these errors were encountered: