Skip to content

Commit

Permalink
Stop memoizing the span name
Browse files Browse the repository at this point in the history
  • Loading branch information
erichmachado committed Dec 10, 2024
1 parent b1d707f commit b8c0fca
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
)
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down

0 comments on commit b8c0fca

Please sign in to comment.