Module: OpenTelemetry::Instrumentation::AwsSdk::HandlerHelper
- Defined in:
- lib/opentelemetry/instrumentation/aws_sdk/handler_helper.rb
Overview
Utility module that contains shared methods between AwsSdk and Telemetry handlers
Class Method Summary collapse
- .client_method(service_id, context) ⇒ Object
- .instrumentation_config ⇒ Object
- .service_id(context, legacy: false) ⇒ Object
- .skip_internal_instrumentation? ⇒ Boolean
- .span_attributes(context, client_method, service_id, legacy: false) ⇒ Object
- .span_kind(client_method, service_id) ⇒ Object
- .span_name(context, client_method, service_id, legacy: false) ⇒ Object
Class Method Details
.client_method(service_id, context) ⇒ Object
21 22 23 |
# File 'lib/opentelemetry/instrumentation/aws_sdk/handler_helper.rb', line 21 def client_method(service_id, context) "#{service_id}.#{context.operation.name}".delete(' ') end |
.instrumentation_config ⇒ Object
13 14 15 |
# File 'lib/opentelemetry/instrumentation/aws_sdk/handler_helper.rb', line 13 def instrumentation_config AwsSdk::Instrumentation.instance.config end |
.service_id(context, legacy: false) ⇒ Object
63 64 65 66 67 68 69 70 71 |
# File 'lib/opentelemetry/instrumentation/aws_sdk/handler_helper.rb', line 63 def service_id(context, legacy: false) if legacy legacy_service_id(context) else context.config.api.['serviceId'] || context.config.api.['serviceAbbreviation'] || context.config.api.['serviceFullName'] end end |
.skip_internal_instrumentation? ⇒ Boolean
17 18 19 |
# File 'lib/opentelemetry/instrumentation/aws_sdk/handler_helper.rb', line 17 def skip_internal_instrumentation? instrumentation_config[:enable_internal_instrumentation] == false end |
.span_attributes(context, client_method, service_id, legacy: false) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/opentelemetry/instrumentation/aws_sdk/handler_helper.rb', line 25 def span_attributes(context, client_method, service_id, legacy: false) { 'aws.region' => context.config.region, OpenTelemetry::SemanticConventions::Trace::CODE_FUNCTION => context.operation_name.to_s, OpenTelemetry::SemanticConventions::Trace::CODE_NAMESPACE => 'Aws::Plugins::Telemetry', OpenTelemetry::SemanticConventions::Trace::RPC_METHOD => context.operation.name, OpenTelemetry::SemanticConventions::Trace::RPC_SERVICE => service_id, 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) end end |
.span_kind(client_method, service_id) ⇒ Object
41 42 43 44 45 46 47 48 |
# File 'lib/opentelemetry/instrumentation/aws_sdk/handler_helper.rb', line 41 def span_kind(client_method, service_id) case service_id when *MessagingHelper::SUPPORTED_SERVICES MessagingHelper.span_kind(client_method) else OpenTelemetry::Trace::SpanKind::CLIENT end end |
.span_name(context, client_method, service_id, legacy: false) ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/opentelemetry/instrumentation/aws_sdk/handler_helper.rb', line 50 def span_name(context, client_method, service_id, legacy: false) case service_id when *MessagingHelper::SUPPORTED_SERVICES if legacy MessagingHelper.legacy_span_name(context, client_method) else MessagingHelper.span_name(context, client_method) end else client_method end end |