Skip to content

Commit

Permalink
feat: rm span_arg_name
Browse files Browse the repository at this point in the history
Signed-off-by: QuentinN42 <quentin@lieumont.fr>
  • Loading branch information
QuentinN42 committed Jan 12, 2024
1 parent 7b87e0f commit 2a76608
Showing 1 changed file with 3 additions and 17 deletions.
20 changes: 3 additions & 17 deletions opentelemetry-api/src/opentelemetry/trace/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ class Tracer(ABC):

def decorate(
self,
name: str = None,
name: str | None = None,
context: Optional[Context] = None,
kind: SpanKind = SpanKind.INTERNAL,
attributes: types.Attributes = None,
Expand All @@ -297,7 +297,6 @@ def decorate(
record_exception: bool = True,
set_status_on_exception: bool = True,
end_on_exit: bool = True,
span_arg_name: str | None = "span",
) -> Callable[[Callable[P, R]], Callable[P, R]]:
"""Decorate the function with a span.
Expand Down Expand Up @@ -328,9 +327,6 @@ def foo():
this mechanism if it was previously set manually.
end_on_exit: Whether to end the span automatically when leaving the
context manager.
span_arg_name: Lookup for this span in the function's kwargs to pass
the span to the function. If None, the span will not be passed
to the function.
"""

def __decorator(func: Callable[P, R]) -> Callable[P, R]:
Expand All @@ -349,12 +345,7 @@ async def __decorated(*args, **kwargs):
record_exception=record_exception,
set_status_on_exception=set_status_on_exception,
end_on_exit=end_on_exit,
) as span:
if (
span_arg_name in func.__annotations__
and span_arg_name not in kwargs
):
kwargs[span_arg_name] = span
):
return await func(*args, **kwargs)

else:
Expand All @@ -371,12 +362,7 @@ def __decorated(*args, **kwargs):
record_exception=record_exception,
set_status_on_exception=set_status_on_exception,
end_on_exit=end_on_exit,
) as span:
if (
span_arg_name in func.__annotations__
and span_arg_name not in kwargs
):
kwargs[span_arg_name] = span
):
return func(*args, **kwargs)

return __decorated
Expand Down

0 comments on commit 2a76608

Please sign in to comment.