|
1 | | -# type: ignore |
2 | 1 | """OpenTelemetry Tracing Utilities for A2A Python SDK. |
3 | 2 |
|
4 | 3 | This module provides decorators to simplify the integration of OpenTelemetry |
@@ -57,11 +56,15 @@ def internal_method(self): |
57 | 56 | import functools |
58 | 57 | import inspect |
59 | 58 | import logging |
| 59 | +import traceback |
60 | 60 |
|
61 | 61 | from opentelemetry import trace |
62 | | -from opentelemetry.trace import SpanKind, StatusCode |
| 62 | +from opentelemetry.trace import SpanKind as _SpanKind |
| 63 | +from opentelemetry.trace import StatusCode |
63 | 64 |
|
64 | 65 |
|
| 66 | +SpanKind = _SpanKind |
| 67 | +__all__ = ['SpanKind'] |
65 | 68 | INSTRUMENTING_MODULE_NAME = 'a2a-python-sdk' |
66 | 69 | INSTRUMENTING_MODULE_VERSION = '1.0.0' |
67 | 70 |
|
@@ -160,6 +163,10 @@ async def async_wrapper(*args, **kwargs) -> any: |
160 | 163 | except Exception as e: |
161 | 164 | exception = e |
162 | 165 | span.record_exception(e) |
| 166 | + formatted_traceback = ''.join( |
| 167 | + traceback.format_exception(type(e), e, e.__traceback__) |
| 168 | + ) |
| 169 | + print(formatted_traceback) |
163 | 170 | span.set_status(StatusCode.ERROR, description=str(e)) |
164 | 171 | raise |
165 | 172 | finally: |
@@ -211,8 +218,8 @@ def sync_wrapper(*args, **kwargs): |
211 | 218 |
|
212 | 219 |
|
213 | 220 | def trace_class( |
214 | | - include_list: list[str] = None, |
215 | | - exclude_list: list[str] = None, |
| 221 | + include_list: list[str] | None = None, |
| 222 | + exclude_list: list[str] | None = None, |
216 | 223 | kind=SpanKind.INTERNAL, |
217 | 224 | ): |
218 | 225 | """A class decorator to automatically trace specified methods of a class. |
|
0 commit comments