lib/opentelemetry/sdk/resources/resource.rb in opentelemetry-sdk-1.0.0.rc1 vs lib/opentelemetry/sdk/resources/resource.rb in opentelemetry-sdk-1.0.0.rc2

- old
+ new

@@ -29,11 +29,11 @@ new(frozen_attributes) end def default - @default ||= create(Constants::SERVICE_RESOURCE[:name] => 'unknown_service').merge(process).merge(telemetry_sdk) + @default ||= create(Constants::SERVICE_RESOURCE[:name] => 'unknown_service').merge(process).merge(telemetry_sdk).merge(service_name_from_env) end def telemetry_sdk resource_attributes = { Constants::TELEMETRY_SDK_RESOURCE[:name] => 'opentelemetry', @@ -61,9 +61,16 @@ Constants::PROCESS_RUNTIME_RESOURCE[:version] => RUBY_VERSION, Constants::PROCESS_RUNTIME_RESOURCE[:description] => RUBY_DESCRIPTION } create(resource_attributes) + end + + private + + def service_name_from_env + service_name = ENV['OTEL_SERVICE_NAME'] + create(Constants::SERVICE_RESOURCE[:name] => service_name) unless service_name.nil? end end # @api private # The constructor is private and only for use internally by the class.