@@ -125,7 +125,8 @@ async def put_scope(
125125 claims : JWTClaims = Depends (authenticator ),
126126 ):
127127 async with start_span ("opal_server_policy_update" ) as span :
128- span .set_attribute ("scope_id" , scope_in .scope_id )
128+ if span is not None :
129+ span .set_attribute ("scope_id" , scope_in .scope_id )
129130 return await _handle_put_scope (force_fetch , scope_in , claims )
130131
131132 async def _handle_put_scope (
@@ -273,7 +274,8 @@ async def get_scope_policy(
273274 ),
274275 ):
275276 async with start_span ("opal_server_policy_bundle_request" ) as span :
276- span .set_attribute ("scope_id" , scope_id )
277+ if span is not None :
278+ span .set_attribute ("scope_id" , scope_id )
277279 policy_bundle = await _handle_get_scope_policy (scope_id , base_hash )
278280 policy_bundle_size_histogram = get_policy_bundle_size_histogram ()
279281 if policy_bundle_size_histogram and policy_bundle .bundle :
@@ -380,7 +382,8 @@ async def publish_data_update_event(
380382 scope_id : str = Path (..., description = "Scope ID" ),
381383 ):
382384 async with start_span ("opal_server_data_update" ) as span :
383- span .set_attribute ("scope_id" , scope_id )
385+ if span is not None :
386+ span .set_attribute ("scope_id" , scope_id )
384387 await _handle_publish_data_update_event (update , claims , scope_id , span )
385388
386389 async def _handle_publish_data_update_event (
@@ -399,7 +402,7 @@ async def _handle_publish_data_update_event(
399402 entry .topics = [f"data:{ topic } " for topic in entry .topics ]
400403 all_topics .update (entry .topics )
401404
402- if span :
405+ if span is not None :
403406 span .set_attribute ("entries_count" , len (update .entries ))
404407 span .set_attribute ("topics" , list (all_topics ))
405408
0 commit comments