Skip to content

Commit

Permalink
Merge branch 'mysql2-prepare-statement' of github.com:xuan-cao-swi/op…
Browse files Browse the repository at this point in the history
…entelemetry-ruby-contrib into mysql2-prepare-statement
  • Loading branch information
xuan-cao-swi committed Feb 9, 2024
2 parents f7c6d1e + bd78fe7 commit b97e72d
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 2 deletions.
4 changes: 4 additions & 0 deletions instrumentation/aws_sdk/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
module OpenTelemetry
module Instrumentation
module AwsSdk
VERSION = '0.5.0'
VERSION = '0.5.1'
end
end
end
20 changes: 20 additions & 0 deletions instrumentation/aws_sdk/test/opentelemetry/instrumentation_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit b97e72d

Please sign in to comment.