1010try :
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
1618except 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 )
0 commit comments