class OpenTelemetry::Instrumentation::AwsSdk::Instrumentation
end
}
suppress_internal_instrumentation: false
inject_messaging_context: false,
c.use ‘OpenTelemetry::Instrumentation::AwsSdk’, {
OpenTelemetry::SDK.configure do |c|
@example An explicit default configuration
- ‘true` - Internal spans are not traced.
- `false` **(default)** - Internal spans are traced.
Disables tracing of spans of `internal` span kind.
### `:suppress_internal_instrumentation`
- `true` - Context key/value will be added.
- `false` **(default)** - Context key/value will not be added.
Allows adding of context key/value to Message Attributes for SQS/SNS messages.
### `:inject_messaging_context`
## Configuration keys and options
logic to detect and install the AwsSdk instrumentation.
The `OpenTelemetry::Instrumentation::AwsSdk::Instrumentation` class contains
def add_plugins(*targets)
def add_plugins(*targets) targets.each do |klass| next if supports_telemetry_plugin?(klass) klass.add_plugin(AwsSdk::Plugin) end end
def gem_version
def gem_version if Gem.loaded_specs['aws-sdk'] Gem.loaded_specs['aws-sdk'].version elsif Gem.loaded_specs['aws-sdk-core'] Gem.loaded_specs['aws-sdk-core'].version elsif defined?(::Aws::CORE_GEM_VERSION) Gem::Version.new(::Aws::CORE_GEM_VERSION) end end
def loaded_service?(constant, service_module)
but for V2, it is Aws::Client
note that Seahorse::Client::Base is a superclass for V3 clients
2 - Validates whether if is a service client
1 - Checks if the service client is autoload or not
This check does the following:
def loaded_service?(constant, service_module) !::Aws.autoload?(constant) && service_module.is_a?(Module) && service_module.const_defined?(:Client) && (service_module.const_get(:Client).superclass == Seahorse::Client::Base || service_module.const_get(:Client).superclass == Aws::Client) end
def loaded_service_clients
def loaded_service_clients ::Aws.constants.each_with_object([]) do |c, constants| m = ::Aws.const_get(c) next unless loaded_service?(c, m) begin constants << m.const_get(:Client) rescue StandardError => e OpenTelemetry.logger.warn("Constant could not be loaded: #{e}") end end end
def patch_telemetry_plugin
This patch supports configuration set by this gem and
Patches AWS SDK V3's telemetry plugin for integration
def patch_telemetry_plugin ::Aws::Plugins::Telemetry::Handler.prepend(Patches::Handler) end
def require_dependencies
def require_dependencies require_relative 'handler' require_relative 'handler_helper' require_relative 'message_attributes' require_relative 'messaging_helper' require_relative 'patches/telemetry' end
def supports_telemetry_plugin?(klass)
def supports_telemetry_plugin?(klass) telemetry_plugin? && klass.plugins.include?(Aws::Plugins::Telemetry) end
def telemetry_plugin?
def telemetry_plugin? ::Aws::Plugins.const_defined?(:Telemetry) end