Sha256: ed7e3aafc413ac0f7925824b562122e0737ed45a9725c22f25b3177415de84fe

Contents?: true

Size: 945 Bytes

Versions: 6

Compression:

Stored size: 945 Bytes

Contents

# frozen_string_literal: true

# Copyright The OpenTelemetry Authors
#
# SPDX-License-Identifier: Apache-2.0

module OpenTelemetry
  module Instrumentation
    module AwsSdk
      # The MessageAttributeSetter class provides methods for writing tracing information to
      # SNS / SQS messages.
      #
      # @example
      #   OpenTelemetry.propagation.inject(context.params[:message_attributes], setter: MessageAttributeSetter)
      class MessageAttributeSetter
        def self.set(carrier, key, value)
          # https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-quotas.html
          if carrier.length < 10
            carrier[key] = { string_value: value, data_type: 'String' }
          else
            OpenTelemetry.logger.warn('aws-sdk instrumentation: cannot set context propagation on SQS/SNS message due to maximum amount of MessageAttributes')
          end
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
aspecto-opentelemetry-instrumentation-aws_sdk-0.1.6 lib/opentelemetry/instrumentation/aws_sdk/message_attribute_setter.rb
aspecto-opentelemetry-instrumentation-aws_sdk-0.1.5 lib/opentelemetry/instrumentation/aws_sdk/message_attribute_setter.rb
aspecto-opentelemetry-instrumentation-aws_sdk-0.1.4 lib/opentelemetry/instrumentation/aws_sdk/message_attribute_setter.rb
aspecto-opentelemetry-instrumentation-aws_sdk-0.1.3 lib/opentelemetry/instrumentation/aws_sdk/message_attribute_setter.rb
aspecto-opentelemetry-instrumentation-aws_sdk-0.1.2 lib/opentelemetry/instrumentation/aws_sdk/message_attribute_setter.rb
aspecto-opentelemetry-instrumentation-aws_sdk-0.1.1 lib/opentelemetry/instrumentation/aws_sdk/message_attribute_setter.rb