From 85c7f5cff8ba1684167671198dc00b16cdd082b2 Mon Sep 17 00:00:00 2001 From: Yohei Kitamura <3087402+yoheyk@users.noreply.github.com> Date: Thu, 8 Feb 2024 09:55:38 -0500 Subject: [PATCH 1/2] fix: return nil for non-existant key in AwsSdk::MessageAttributeGetter (#853) Co-authored-by: Ariel Valentin --- .../aws_sdk/message_attributes.rb | 3 ++- .../opentelemetry/instrumentation_test.rb | 20 +++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/instrumentation/aws_sdk/lib/opentelemetry/instrumentation/aws_sdk/message_attributes.rb b/instrumentation/aws_sdk/lib/opentelemetry/instrumentation/aws_sdk/message_attributes.rb index 4a4519f02..40598b977 100644 --- a/instrumentation/aws_sdk/lib/opentelemetry/instrumentation/aws_sdk/message_attributes.rb +++ b/instrumentation/aws_sdk/lib/opentelemetry/instrumentation/aws_sdk/message_attributes.rb @@ -29,7 +29,8 @@ def self.set(carrier, key, value) # OpenTelemetry.propagation.extract(message, getter: MessageAttributeGetter) class MessageAttributeGetter def self.get(carrier, key) - carrier[key][:string_value] if carrier[key][:data_type] == 'String' + message_attribute = carrier[key] + message_attribute[:string_value] if message_attribute && message_attribute[:data_type] == 'String' end end end diff --git a/instrumentation/aws_sdk/test/opentelemetry/instrumentation_test.rb b/instrumentation/aws_sdk/test/opentelemetry/instrumentation_test.rb index 1917da5e0..f44e81bc5 100644 --- a/instrumentation/aws_sdk/test/opentelemetry/instrumentation_test.rb +++ b/instrumentation/aws_sdk/test/opentelemetry/instrumentation_test.rb @@ -246,5 +246,25 @@ OpenTelemetry::Instrumentation::AwsSdk::MessageAttributeSetter.set(metadata_attributes, 'new10', 'value') _(metadata_attributes.keys).must_equal(%w[existingKey0 existingKey1 existingKey2 existingKey3 existingKey4 existingKey5 existingKey6 existingKey7 existingKey8 existingKey9]) end + + describe 'MessageAttributeGetter' do + let(:getter) { OpenTelemetry::Instrumentation::AwsSdk::MessageAttributeGetter } + let(:carrier) do + { + 'traceparent' => { data_type: 'String', string_value: 'tp' }, + 'tracestate' => { data_type: 'String', string_value: 'ts' }, + 'x-source-id' => { data_type: 'String', string_value: '123' } + } + end + + it 'reads key from carrier' do + _(getter.get(carrier, 'traceparent')).must_equal('tp') + _(getter.get(carrier, 'x-source-id')).must_equal('123') + end + + it 'returns nil for non-existant key' do + _(getter.get(carrier, 'not-here')).must_be_nil + end + end end end From c048b149faa1898377b275f015b29f5cad1bef33 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 8 Feb 2024 11:00:34 -0600 Subject: [PATCH 2/2] release: Release opentelemetry-instrumentation-aws_sdk 0.5.1 (was 0.5.0) (#861) * release: Release opentelemetry-instrumentation-aws_sdk 0.5.1 (was 0.5.0) * ci: Force --------- Co-authored-by: OpenTelemetry Bot <107717825+opentelemetrybot@users.noreply.github.com> Co-authored-by: Ariel Valentin --- instrumentation/aws_sdk/CHANGELOG.md | 4 ++++ .../lib/opentelemetry/instrumentation/aws_sdk/version.rb | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/instrumentation/aws_sdk/CHANGELOG.md b/instrumentation/aws_sdk/CHANGELOG.md index 686a7708a..6ef39ea6a 100644 --- a/instrumentation/aws_sdk/CHANGELOG.md +++ b/instrumentation/aws_sdk/CHANGELOG.md @@ -1,5 +1,9 @@ # Release History: opentelemetry-instrumentation-aws_sdk +### v0.5.1 / 2024-02-08 + +* FIXED: Return nil for non-existant key in AwsSdk::MessageAttributeGetter + ### v0.5.0 / 2023-09-07 * FIXED: Align messaging instrumentation operation names diff --git a/instrumentation/aws_sdk/lib/opentelemetry/instrumentation/aws_sdk/version.rb b/instrumentation/aws_sdk/lib/opentelemetry/instrumentation/aws_sdk/version.rb index d40079038..bd5d2d66f 100644 --- a/instrumentation/aws_sdk/lib/opentelemetry/instrumentation/aws_sdk/version.rb +++ b/instrumentation/aws_sdk/lib/opentelemetry/instrumentation/aws_sdk/version.rb @@ -7,7 +7,7 @@ module OpenTelemetry module Instrumentation module AwsSdk - VERSION = '0.5.0' + VERSION = '0.5.1' end end end