From b8c0fca1a6c44d1800b67639a975eb36a5d117c3 Mon Sep 17 00:00:00 2001 From: Erich Soares Machado Date: Tue, 10 Dec 2024 13:00:37 -0500 Subject: [PATCH] Stop memoizing the span name --- .../instrumentation/active_support/span_subscriber.rb | 11 +---------- .../active_support/span_subscriber_test.rb | 5 ----- 2 files changed, 1 insertion(+), 15 deletions(-) diff --git a/instrumentation/active_support/lib/opentelemetry/instrumentation/active_support/span_subscriber.rb b/instrumentation/active_support/lib/opentelemetry/instrumentation/active_support/span_subscriber.rb index 8a98e3efb..736600342 100644 --- a/instrumentation/active_support/lib/opentelemetry/instrumentation/active_support/span_subscriber.rb +++ b/instrumentation/active_support/lib/opentelemetry/instrumentation/active_support/span_subscriber.rb @@ -75,7 +75,7 @@ def initialize(name:, tracer:, notification_payload_transform: nil, disallowed_n # rubocop:enable Metrics/ParameterLists def start(name, id, payload) - span = @tracer.start_span(span_name(name).dup.freeze, kind: @kind) + span = @tracer.start_span(safe_span_name_for(name), kind: @kind) token = OpenTelemetry::Context.attach( OpenTelemetry::Trace.context_with_span(span) ) @@ -138,15 +138,6 @@ def sanitized_value(value) end end - def span_name(name) - case @name - when Regexp - safe_span_name_for(name) - else - @span_name ||= safe_span_name_for(@name) - end - end - # Helper method to try an shield the span name formatter from errors # # It wraps the user supplied formatter in a rescue block and returns the original name if a StandardError is raised by the formatter diff --git a/instrumentation/active_support/test/opentelemetry/instrumentation/active_support/span_subscriber_test.rb b/instrumentation/active_support/test/opentelemetry/instrumentation/active_support/span_subscriber_test.rb index 0e2c75269..79e97d99f 100644 --- a/instrumentation/active_support/test/opentelemetry/instrumentation/active_support/span_subscriber_test.rb +++ b/instrumentation/active_support/test/opentelemetry/instrumentation/active_support/span_subscriber_test.rb @@ -35,11 +35,6 @@ def finish(name, id, payload) instrumentation.install({}) end - it 'memoizes the span name' do - span, = subscriber.start('oh.hai', 'abc', {}) - _(span.name).must_equal(notification_name) - end - it 'uses the provided tracer' do subscriber = OpenTelemetry::Instrumentation::ActiveSupport::SpanSubscriber.new( name: 'oh.hai',