|
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
|
@@ -59,9 +58,12 @@ def internal_method(self):
|
59 | 58 | import logging
|
60 | 59 |
|
61 | 60 | from opentelemetry import trace
|
62 |
| -from opentelemetry.trace import SpanKind, StatusCode |
| 61 | +from opentelemetry.trace import SpanKind as _SpanKind |
| 62 | +from opentelemetry.trace import StatusCode |
63 | 63 |
|
64 | 64 |
|
| 65 | +SpanKind = _SpanKind |
| 66 | +__all__ = ['SpanKind'] |
65 | 67 | INSTRUMENTING_MODULE_NAME = 'a2a-python-sdk'
|
66 | 68 | INSTRUMENTING_MODULE_VERSION = '1.0.0'
|
67 | 69 |
|
@@ -210,7 +212,11 @@ def sync_wrapper(*args, **kwargs):
|
210 | 212 | return async_wrapper if is_async_func else sync_wrapper
|
211 | 213 |
|
212 | 214 |
|
213 |
| -def trace_class(include_list: list[str] = None, exclude_list: list[str] = None): |
| 215 | +def trace_class( |
| 216 | + include_list: list[str] | None = None, |
| 217 | + exclude_list: list[str] | None = None, |
| 218 | + kind=SpanKind.INTERNAL, |
| 219 | +): |
214 | 220 | """A class decorator to automatically trace specified methods of a class.
|
215 | 221 |
|
216 | 222 | This decorator iterates over the methods of a class and applies the
|
@@ -278,7 +284,11 @@ def decorator(cls):
|
278 | 284 | all_methods[name] = method
|
279 | 285 | span_name = f'{cls.__module__}.{cls.__name__}.{name}'
|
280 | 286 | # Set the decorator on the method.
|
281 |
| - setattr(cls, name, trace_function(span_name=span_name)(method)) |
| 287 | + setattr( |
| 288 | + cls, |
| 289 | + name, |
| 290 | + trace_function(span_name=span_name, kind=kind)(method), |
| 291 | + ) |
282 | 292 | return cls
|
283 | 293 |
|
284 | 294 | return decorator
|
0 commit comments