@@ -125,7 +125,8 @@ async def put_scope(
125
125
claims : JWTClaims = Depends (authenticator ),
126
126
):
127
127
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 )
129
130
return await _handle_put_scope (force_fetch , scope_in , claims )
130
131
131
132
async def _handle_put_scope (
@@ -273,7 +274,8 @@ async def get_scope_policy(
273
274
),
274
275
):
275
276
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 )
277
279
policy_bundle = await _handle_get_scope_policy (scope_id , base_hash )
278
280
policy_bundle_size_histogram = get_policy_bundle_size_histogram ()
279
281
if policy_bundle_size_histogram and policy_bundle .bundle :
@@ -380,7 +382,8 @@ async def publish_data_update_event(
380
382
scope_id : str = Path (..., description = "Scope ID" ),
381
383
):
382
384
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 )
384
387
await _handle_publish_data_update_event (update , claims , scope_id , span )
385
388
386
389
async def _handle_publish_data_update_event (
@@ -399,7 +402,7 @@ async def _handle_publish_data_update_event(
399
402
entry .topics = [f"data:{ topic } " for topic in entry .topics ]
400
403
all_topics .update (entry .topics )
401
404
402
- if span :
405
+ if span is not None :
403
406
span .set_attribute ("entries_count" , len (update .entries ))
404
407
span .set_attribute ("topics" , list (all_topics ))
405
408
0 commit comments