Class: OpenTelemetry::Instrumentation::AwsSdk::Handler
- Inherits:
-
Seahorse::Client::Handler
- Object
- Seahorse::Client::Handler
- OpenTelemetry::Instrumentation::AwsSdk::Handler
- Defined in:
- lib/opentelemetry/instrumentation/aws_sdk/handler.rb
Overview
Generates Spans for all interactions with AwsSdk
Constant Summary collapse
- SQS_SEND_MESSAGE =
'SQS.SendMessage'
- SQS_SEND_MESSAGE_BATCH =
'SQS.SendMessageBatch'
- SQS_RECEIVE_MESSAGE =
'SQS.ReceiveMessage'
- SNS_PUBLISH =
'SNS.Publish'
Instance Method Summary collapse
-
#call(context) ⇒ Object
rubocop:disable Metrics/AbcSize, Metrics/MethodLength, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity.
Instance Method Details
#call(context) ⇒ Object
rubocop:disable Metrics/AbcSize, Metrics/MethodLength, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/opentelemetry/instrumentation/aws_sdk/handler.rb', line 17 def call(context) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity return super unless context service_name = service_name(context) operation = context.operation&.name client_method = "#{service_name}.#{operation}" attributes = { 'aws.region' => context.config.region, OpenTelemetry::SemanticConventions::Trace::RPC_SYSTEM => 'aws-api', OpenTelemetry::SemanticConventions::Trace::RPC_METHOD => operation, OpenTelemetry::SemanticConventions::Trace::RPC_SERVICE => service_name } attributes[SemanticConventions::Trace::DB_SYSTEM] = 'dynamodb' if service_name == 'DynamoDB' MessagingHelper.apply_sqs_attributes(attributes, context, client_method) if service_name == 'SQS' MessagingHelper.apply_sns_attributes(attributes, context, client_method) if service_name == 'SNS' tracer.in_span(span_name(context, client_method), attributes: attributes, kind: span_kind(client_method)) do |span| inject_context(context, client_method) if instrumentation_config[:suppress_internal_instrumentation] OpenTelemetry::Common::Utilities.untraced { super } else super end.tap do |response| if (err = response.error) span.record_exception(err) span.status = Trace::Status.error(err.to_s) end end end end |