@@ -137,9 +137,9 @@ def extract_firehose_agent_attrs(instance, *args, **kwargs):
137137 region = instance ._client_config .region_name
138138 if account_id and region :
139139 agent_attrs ["cloud.platform" ] = "aws_kinesis_delivery_streams"
140- agent_attrs [
141- "cloud.resource_id "
142- ] = f"arn:aws:firehose: { region } : { account_id } :deliverystream/ { stream_name } "
140+ agent_attrs ["cloud.resource_id" ] = (
141+ f"arn:aws:firehose: { region } : { account_id } :deliverystream/ { stream_name } "
142+ )
143143 except Exception as e :
144144 _logger .debug ("Failed to capture AWS Kinesis Delivery Stream (Firehose) info." , exc_info = True )
145145 return agent_attrs
@@ -497,18 +497,8 @@ def extract_bedrock_cohere_model_streaming_response(response_body, bedrock_attrs
497497
498498NULL_EXTRACTOR = lambda * args : {} # Empty extractor that returns nothing
499499MODEL_EXTRACTORS = [ # Order is important here, avoiding dictionaries
500- (
501- "amazon.titan-embed" ,
502- extract_bedrock_titan_embedding_model_request ,
503- NULL_EXTRACTOR ,
504- NULL_EXTRACTOR ,
505- ),
506- (
507- "cohere.embed" ,
508- extract_bedrock_cohere_embedding_model_request ,
509- NULL_EXTRACTOR ,
510- NULL_EXTRACTOR ,
511- ),
500+ ("amazon.titan-embed" , extract_bedrock_titan_embedding_model_request , NULL_EXTRACTOR , NULL_EXTRACTOR ),
501+ ("cohere.embed" , extract_bedrock_cohere_embedding_model_request , NULL_EXTRACTOR , NULL_EXTRACTOR ),
512502 (
513503 "amazon.titan" ,
514504 extract_bedrock_titan_text_model_request ,
@@ -547,11 +537,7 @@ def handle_bedrock_exception(
547537 exc , is_embedding , model , span_id , trace_id , request_extractor , request_body , ft , transaction
548538):
549539 try :
550- bedrock_attrs = {
551- "model" : model ,
552- "span_id" : span_id ,
553- "trace_id" : trace_id ,
554- }
540+ bedrock_attrs = {"model" : model , "span_id" : span_id , "trace_id" : trace_id }
555541 try :
556542 request_extractor (request_body , bedrock_attrs )
557543 except json .decoder .JSONDecodeError :
@@ -572,9 +558,7 @@ def handle_bedrock_exception(
572558 notice_error_attributes .update ({"completion_id" : str (uuid .uuid4 ())})
573559
574560 if ft :
575- ft .notice_error (
576- attributes = notice_error_attributes ,
577- )
561+ ft .notice_error (attributes = notice_error_attributes )
578562
579563 ft .__exit__ (* sys .exc_info ())
580564 error_attributes ["duration" ] = ft .duration * 1000
@@ -866,9 +850,7 @@ def record_error(self, transaction, exc):
866850 }
867851 notice_error_attributes .update ({"completion_id" : str (uuid .uuid4 ())})
868852
869- ft .notice_error (
870- attributes = notice_error_attributes ,
871- )
853+ ft .notice_error (attributes = notice_error_attributes )
872854
873855 ft .__exit__ (* sys .exc_info ())
874856 error_attributes ["duration" ] = ft .duration * 1000
@@ -983,13 +965,7 @@ def handle_chat_completion_event(transaction, bedrock_attrs):
983965
984966
985967def dynamodb_datastore_trace (
986- product ,
987- target ,
988- operation ,
989- host = None ,
990- port_path_or_id = None ,
991- database_name = None ,
992- async_wrapper = None ,
968+ product , target , operation , host = None , port_path_or_id = None , database_name = None , async_wrapper = None
993969):
994970 @function_wrapper
995971 def _nr_dynamodb_datastore_trace_wrapper_ (wrapped , instance , args , kwargs ):
@@ -1076,9 +1052,9 @@ def _nr_dynamodb_datastore_trace_wrapper_(wrapped, instance, args, kwargs):
10761052 partition = "aws-us-gov"
10771053
10781054 if partition and region and account_id and _target :
1079- agent_attrs [
1080- "cloud.resource_id "
1081- ] = f"arn: { partition } :dynamodb: { region } : { account_id :012d } :table/ { _target } "
1055+ agent_attrs ["cloud.resource_id" ] = (
1056+ f"arn: { partition } :dynamodb: { region } : { account_id :012d } :table/ { _target } "
1057+ )
10821058 agent_attrs ["db.system" ] = "DynamoDB"
10831059
10841060 except Exception as e :
@@ -1119,14 +1095,7 @@ def _nr_aws_function_trace_wrapper_(wrapped, instance, args, kwargs):
11191095 _destination_name = destination_name (* args , ** kwargs ) if destination_name is not None else None
11201096 name = f"{ operation } /{ _destination_name } " if _destination_name else operation
11211097
1122- trace = FunctionTrace (
1123- name = name ,
1124- group = library ,
1125- params = params ,
1126- terminal = terminal ,
1127- parent = parent ,
1128- source = wrapped ,
1129- )
1098+ trace = FunctionTrace (name = name , group = library , params = params , terminal = terminal , parent = parent , source = wrapped )
11301099
11311100 # Attach extracted agent attributes.
11321101 _agent_attrs = extract_agent_attrs (instance , * args , ** kwargs ) if extract_agent_attrs is not None else {}
0 commit comments