Skip to content

Commit

Permalink
decode value
Browse files Browse the repository at this point in the history
  • Loading branch information
Hussein Jafferjee committed Nov 3, 2023
1 parent 14a4832 commit 9be4469
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion sdk/lib/opentelemetry/sdk/resources/resource.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
#
# SPDX-License-Identifier: Apache-2.0

require 'uri'

module OpenTelemetry
module SDK
module Resources
Expand Down Expand Up @@ -46,7 +48,7 @@ def telemetry_sdk

resource_pairs.split(',').each do |pair|
key, value = pair.split('=')
resource_attributes[key.strip] = value
resource_attributes[key.strip] = URI.decode_www_form_component(value).strip
end

resource_attributes.delete_if { |_key, value| value.nil? || value.empty? }
Expand Down
2 changes: 1 addition & 1 deletion sdk/test/opentelemetry/sdk/configurator_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
end

it 'cleans up whitespace in user provided resources' do
OpenTelemetry::TestHelpers.with_env('OTEL_RESOURCE_ATTRIBUTES' => 'important_foo=x, important_bar=y') do
OpenTelemetry::TestHelpers.with_env('OTEL_RESOURCE_ATTRIBUTES' => ' important_foo=x, important_bar=y ') do
configurator.resource = OpenTelemetry::SDK::Resources::Resource.create()
_(configurator_resource_attributes).must_equal(default_resource_attributes.merge('important_foo' => 'x', 'important_bar' => 'y'))
end
Expand Down

0 comments on commit 9be4469

Please sign in to comment.