Skip to content

Commit

Permalink
Merge pull request #1755 from newrelic/actionview-updates
Browse files Browse the repository at this point in the history
Use NewRelic::UNKNOWN const
  • Loading branch information
hannahramadan authored Jan 24, 2023
2 parents 1c6ddda + f7a252f commit ac8f980
Show file tree
Hide file tree
Showing 8 changed files with 8 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,12 @@ def metric_name(name, payload)
end

PATTERN = /\A([^\.]*)\.action_mailbox\z/
UNKNOWN = "unknown".freeze

METHOD_NAME_MAPPING = Hash.new do |h, k|
if PATTERN =~ k
h[k] = $1
else
h[k] = UNKNOWN
h[k] = NewRelic::UNKNOWN
end
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,13 @@ class ActionMailerSubscriber < NotificationsSubscriber
BASE_NAME = 'Ruby/ActionMailer'
PAYLOAD_KEYS = %i[action data key mailer message_id perform_deliveries subject]
PATTERN = /\A([^\.]+)\.action_mailer\z/
UNKNOWN = 'unknown'
UNKNOWN_MAILER = %r{^#{BASE_NAME}/#{UNKNOWN}/}

METHOD_NAME_MAPPING = Hash.new do |h, k|
if PATTERN =~ k
h[k] = $1
else
h[k] = UNKNOWN
h[k] = NewRelic::UNKNOWN
end
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def metric_action(name)
when RENDER_PARTIAL_EVENT_NAME then 'Partial'
when RENDER_COLLECTION_EVENT_NAME then 'Partial'
when RENDER_LAYOUT_EVENT_NAME then 'Layout'
else 'Unknown'
else NewRelic::UNKNOWN
end
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,12 @@ def metric_name(name, payload)
end

PATTERN = /\Aservice_([^\.]*)\.active_storage\z/
UNKNOWN = "unknown".freeze

METHOD_NAME_MAPPING = Hash.new do |h, k|
if PATTERN =~ k
h[k] = $1
else
h[k] = UNKNOWN
h[k] = NewRelic::UNKNOWN
end
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,12 @@ def metric_name(name, payload)
end

PATTERN = /\Acache_([^\.]*)\.active_support\z/
UNKNOWN = "unknown".freeze

METHOD_NAME_MAPPING = Hash.new do |h, k|
if PATTERN =~ k
h[k] = $1
else
h[k] = UNKNOWN
h[k] = NewRelic::UNKNOWN
end
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def test_start_with_exception_raised
end

def test_segment_naming_with_unknown_method
assert_equal 'Ruby/ActionMailer/mailer/unknown',
assert_equal 'Ruby/ActionMailer/mailer/Unknown',
SUBSCRIBER.send(:metric_name, 'indecipherable', {mailer: 'mailer'})
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def test_failsafe_if_event_does_not_match_expected_pattern
generate_event('wat?')
end

assert_metrics_recorded 'Ruby/ActiveStorage/DiskService/unknown'
assert_metrics_recorded 'Ruby/ActiveStorage/DiskService/Unknown'
end

def test_key_recorded_as_attribute_on_traces
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def test_failsafe_if_event_does_not_match_expected_pattern
generate_event('charcuterie_build_a_board_workshop')
end

assert_metrics_recorded "#{METRIC_PREFIX}#{DEFAULT_STORE}/unknown"
assert_metrics_recorded "#{METRIC_PREFIX}#{DEFAULT_STORE}/Unknown"
end

def test_key_recorded_as_attribute_on_traces
Expand Down

0 comments on commit ac8f980

Please sign in to comment.