lib/opentelemetry/instrumentation/aws_sdk/handler.rb in aspecto-opentelemetry-instrumentation-aws_sdk-0.1.6 vs lib/opentelemetry/instrumentation/aws_sdk/handler.rb in aspecto-opentelemetry-instrumentation-aws_sdk-0.1.7
- old
+ new
@@ -15,11 +15,11 @@
SNS_PUBLISH = 'SNS.Publish'
def call(context) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
return super unless context
- service_name = context.client.class.to_s.split('::')[1]
+ service_name = context.client.class.api.metadata['serviceId'] || context.client.class.to_s.split('::')[1]
operation = context.operation&.name
client_method = "#{service_name}.#{operation}"
attributes = {
'aws.region' => context.config.region,
OpenTelemetry::SemanticConventions::Trace::RPC_SYSTEM => 'aws-api',
@@ -55,9 +55,10 @@
AwsSdk::Instrumentation.instance.config
end
def inject_context(context, client_method)
return unless [SQS_SEND_MESSAGE, SQS_SEND_MESSAGE_BATCH, SNS_PUBLISH].include? client_method
+ return unless instrumentation_config[:inject_messaging_context]
if client_method == SQS_SEND_MESSAGE_BATCH
context.params[:entries].each do |entry|
entry[:message_attributes] ||= {}
OpenTelemetry.propagation.inject(entry[:message_attributes], setter: MessageAttributeSetter)