diff --git a/sdk/lib/opentelemetry/sdk/resources/resource.rb b/sdk/lib/opentelemetry/sdk/resources/resource.rb index c6a77ba66..45497bbac 100644 --- a/sdk/lib/opentelemetry/sdk/resources/resource.rb +++ b/sdk/lib/opentelemetry/sdk/resources/resource.rb @@ -4,6 +4,8 @@ # # SPDX-License-Identifier: Apache-2.0 +require 'uri' + module OpenTelemetry module SDK module Resources @@ -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? } diff --git a/sdk/test/opentelemetry/sdk/configurator_test.rb b/sdk/test/opentelemetry/sdk/configurator_test.rb index 3a8462785..d57b35ae4 100644 --- a/sdk/test/opentelemetry/sdk/configurator_test.rb +++ b/sdk/test/opentelemetry/sdk/configurator_test.rb @@ -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