Skip to content

Commit c612278

Browse files
committed
fixing mypy issues
1 parent 959081a commit c612278

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

featuremanagement/azuremonitor/_send_telemetry.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@
1010
try:
1111
from azure.monitor.events.extension import track_event as azure_monitor_track_event # type: ignore
1212
from opentelemetry import trace, baggage, context
13+
from opentelemetry.context.context import Context
1314
from opentelemetry.sdk.trace import Span, SpanProcessor
15+
from opentelemetry.util import types
1416

1517
HAS_AZURE_MONITOR_EVENTS_EXTENSION = True
1618
except ImportError:
@@ -110,7 +112,7 @@ def publish_telemetry(evaluation_event: EvaluationEvent) -> None:
110112
track_event(EVENT_NAME, evaluation_event.user, event_properties=event)
111113

112114

113-
def attach_targeting_info(targeting_id: str):
115+
def attach_targeting_info(targeting_id: str) -> None:
114116
"""
115117
Attaches the targeting ID to the current span and baggage.
116118
@@ -125,13 +127,13 @@ class TargetingSpanProcessor(SpanProcessor):
125127
A custom SpanProcessor that attaches the targeting ID to the span and baggage when a new span is started.
126128
"""
127129

128-
def on_start(self, span: Span, parent_context=None):
130+
def on_start(self, span: Span, parent_context: Optional[Context] =None) -> None:
129131
"""
130132
Attaches the targeting ID to the span and baggage when a new span is started.
131133
132134
:param Span span: The span that was started.
133135
:param parent_context: The parent context of the span.
134136
"""
135137
target_baggage = baggage.get_baggage(MICROSOFT_TARGETING_ID, parent_context)
136-
if target_baggage is not None:
138+
if target_baggage is not None and isinstance(target_baggage, str):
137139
span.set_attribute(TARGETING_ID, target_baggage)

tests/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
azure-monitor-opentelemetry
2-
azure-monitor-events-extension
2+
azure-monitor-events-extension

0 commit comments

Comments
 (0)