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

Fix EH typing for tracing #31432

Merged
merged 1 commit into from
Aug 2, 2023
Merged
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
Fix EH typing for tracing
  • Loading branch information
lmazuel committed Aug 2, 2023
commit 03dbb8fa1ac6a3ab296a4355746981fad0e9b1a3
8 changes: 4 additions & 4 deletions sdk/eventhub/azure-eventhub/azure/eventhub/_tracing.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def is_tracing_enabled():
@contextmanager
def send_context_manager(client: Optional[ClientBase], links: Optional[List[Link]] = None) -> Iterator[None]:
"""Tracing for message sending."""
span_impl_type: Type[AbstractSpan] = settings.tracing_implementation()
span_impl_type: Optional[Type[AbstractSpan]] = settings.tracing_implementation()
if span_impl_type is not None:
links = links or []
with span_impl_type(name="EventHubs.send", kind=SpanKind.CLIENT, links=links) as span:
Expand All @@ -92,7 +92,7 @@ def receive_context_manager(
client: Optional[ClientBase], links: Optional[List[Link]] = None, start_time: Optional[int] = None
) -> Iterator[None]:
"""Tracing for message receiving."""
span_impl_type: Type[AbstractSpan] = settings.tracing_implementation()
span_impl_type: Optional[Type[AbstractSpan]] = settings.tracing_implementation()
if span_impl_type is not None:
links = links or []
with span_impl_type(
Expand All @@ -109,7 +109,7 @@ def process_context_manager(
client: Optional[ClientBase], links: Optional[List[Link]] = None, is_batch: bool = False
) -> Iterator[None]:
"""Tracing for message processing."""
span_impl_type: Type[AbstractSpan] = settings.tracing_implementation()
span_impl_type: Optional[Type[AbstractSpan]] = settings.tracing_implementation()
if span_impl_type is not None:
context = None
links = links or []
Expand All @@ -136,7 +136,7 @@ def trace_message(
Will open and close an message span, and add trace context to the app properties of the message.
"""
try:
span_impl_type: Type[AbstractSpan] = settings.tracing_implementation()
span_impl_type: Optional[Type[AbstractSpan]] = settings.tracing_implementation()
if span_impl_type is not None:
with span_impl_type(name="EventHubs.message", kind=SpanKind.PRODUCER) as message_span:
headers = message_span.to_header()
Expand Down