Skip to content

Commit

Permalink
Update based on feedbacks
Browse files Browse the repository at this point in the history
  • Loading branch information
jterapin committed Oct 2, 2024
1 parent 8000bd0 commit a88afb8
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
module OpenTelemetry
module Instrumentation
module AwsSdk
# Generates Spans for all interactions with AwsSdk
# This handler supports specifically supports V2 and V3
# prior to Observability support released on 2024-09-03.
class Handler < Seahorse::Client::Handler
def call(context)
return super unless context
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ def span_attributes(context, client_method, service_id, legacy: false)
OpenTelemetry::SemanticConventions::Trace::RPC_SYSTEM => 'aws-api'
}.tap do |attrs|
attrs[OpenTelemetry::SemanticConventions::Trace::CODE_NAMESPACE] = 'Aws::Plugins::AwsSdk' if legacy

attrs[SemanticConventions::Trace::DB_SYSTEM] = 'dynamodb' if service_id == 'DynamoDB'
MessagingHelper.apply_span_attributes(context, attrs, client_method, service_id) if MessagingHelper.supported_services.include?(service_id)

MessagingHelper.apply_span_attributes(context, attrs, client_method, service_id) if MessagingHelper::SUPPORTED_SERVICES.include?(service_id)
end
end

def span_kind(client_method, service_id)
case service_id
when *MessagingHelper.supported_services
when *MessagingHelper::SUPPORTED_SERVICES
MessagingHelper.span_kind(client_method)
else
OpenTelemetry::Trace::SpanKind::CLIENT
Expand All @@ -45,7 +45,7 @@ def span_kind(client_method, service_id)

def span_name(context, client_method, service_id, legacy: false)
case service_id
when *MessagingHelper.supported_services
when *MessagingHelper::SUPPORTED_SERVICES
if legacy
MessagingHelper.legacy_span_name(context, client_method)
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ module Instrumentation
module AwsSdk
# An utility class to help SQS/SNS-related span attributes/context injection
class MessagingHelper
SUPPORTED_SERVICES = %w[SQS SNS].freeze
class << self
SUPPORTED_SERVICES = %w[SQS SNS].freeze
SQS_SEND_MESSAGE = 'SQS.SendMessage'
SQS_SEND_MESSAGE_BATCH = 'SQS.SendMessageBatch'
SQS_RECEIVE_MESSAGE = 'SQS.ReceiveMessage'
Expand Down

0 comments on commit a88afb8

Please sign in to comment.