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
- .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
17 18 19 |
# File 'lib/opentelemetry/instrumentation/aws_sdk/handler_helper.rb', line 17 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
59 60 61 62 63 64 65 66 67 |
# File 'lib/opentelemetry/instrumentation/aws_sdk/handler_helper.rb', line 59 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 |
.span_attributes(context, client_method, service_id, legacy: false) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/opentelemetry/instrumentation/aws_sdk/handler_helper.rb', line 21 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
37 38 39 40 41 42 43 44 |
# File 'lib/opentelemetry/instrumentation/aws_sdk/handler_helper.rb', line 37 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
46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/opentelemetry/instrumentation/aws_sdk/handler_helper.rb', line 46 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 |