55# --------------------------------------------------------------------------
66import logging
77from typing import Dict , Optional
8- from .._models import VariantAssignmentReason , EvaluationEvent , TargetingContext
8+ from .._models import VariantAssignmentReason , EvaluationEvent
99
1010try :
1111 from azure .monitor .events .extension import track_event as azure_monitor_track_event # type: ignore
@@ -109,6 +109,7 @@ def publish_telemetry(evaluation_event: EvaluationEvent) -> None:
109109
110110 track_event (EVENT_NAME , evaluation_event .user , event_properties = event )
111111
112+
112113def attach_targeting_info (targeting_id : str ):
113114 """
114115 Attaches the targeting ID to the current span and baggage.
@@ -118,18 +119,19 @@ def attach_targeting_info(targeting_id: str):
118119 context .attach (baggage .set_baggage (MICROSOFT_TARGETING_ID , targeting_id ))
119120 trace .get_current_span ().set_attribute (TARGETING_ID , targeting_id )
120121
121- """
122- This class is a custom SpanProcessor that attaches the targeting ID to the span and baggage when a new span is started.
123- """
122+
124123class TargetingSpanProcessor (SpanProcessor ):
124+ """
125+ A custom SpanProcessor that attaches the targeting ID to the span and baggage when a new span is started.
126+ """
125127
126- def on_start (self , span : Span , parent_context = None ):
128+ def on_start (self , span : Span , parent_context = None ):
127129 """
128130 Attaches the targeting ID to the span and baggage when a new span is started.
129-
131+
130132 :param Span span: The span that was started.
131133 :param parent_context: The parent context of the span.
132134 """
133135 target_baggage = baggage .get_baggage (MICROSOFT_TARGETING_ID , parent_context )
134- if ( target_baggage != None ) :
136+ if target_baggage is not None :
135137 span .set_attribute (TARGETING_ID , target_baggage )
0 commit comments