Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add reported_by tag to Rails error reporter errors #1309

Merged
merged 1 commit into from
Sep 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changesets/add-reported_by-tag-to-rails-error-reporter.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
bump: patch
type: change
---

Add the `reported_by` tag to errors reported by the Rails error reporter so the source of the error is easier to identify.
1 change: 1 addition & 0 deletions lib/appsignal/integrations/railtie.rb
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ def report(error, handled:, severity:, context: {}, source: nil) # rubocop:disab
transaction.set_action(action_name) if action_name
transaction.add_custom_data(custom_data) if custom_data

tags[:reported_by] = :rails_error_reporter
tags[:severity] = severity
tags[:source] = source.to_s if source
transaction.add_tags(tags)
Expand Down
13 changes: 12 additions & 1 deletion spec/lib/appsignal/integrations/railtie_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,7 @@ def subscribe(subscriber)
expect(transaction).to have_action("CustomAction")
expect(transaction).to have_error("ExampleStandardError", "error message")
expect(transaction).to include_tags(
"reported_by" => "rails_error_reporter",
"duplicated_tag" => "duplicated value",
"severity" => "warning"
)
Expand All @@ -317,11 +318,15 @@ def subscribe(subscriber)
current_transaction.complete
end.to change { created_transactions.count }.by(1)

expect(current_transaction)
.to_not include_tags("reported_by" => "rails_error_reporter")

transaction = last_transaction
expect(transaction).to have_namespace("custom")
expect(transaction).to have_action("CustomAction")
expect(transaction).to have_error("ExampleStandardError", "other message")
expect(transaction).to include_tags(
"reported_by" => "rails_error_reporter",
"duplicated_tag" => "duplicated value",
"severity" => "warning"
)
Expand Down Expand Up @@ -359,6 +364,7 @@ def subscribe(subscriber)
expect(transaction).to have_action("ContextAction")
expect(transaction).to have_error("ExampleStandardError", "other message")
expect(transaction).to include_tags(
"reported_by" => "rails_error_reporter",
"duplicated_tag" => "duplicated value",
"severity" => "warning"
)
Expand All @@ -382,6 +388,7 @@ def subscribe(subscriber)
current_transaction.complete

expect(current_transaction).to include_tags(
"reported_by" => "rails_error_reporter",
"tag1" => "value1",
"tag2" => "value2",
"severity" => "warning"
Expand Down Expand Up @@ -431,7 +438,10 @@ def subscribe(subscriber)
expect(transaction).to have_namespace("runner")
expect(transaction).to_not have_action
expect(transaction).to have_error("ExampleStandardError", "error message")
expect(transaction).to include_tags("source" => "application.runner.railties")
expect(transaction).to include_tags(
"reported_by" => "rails_error_reporter",
"source" => "application.runner.railties"
)
end
end

Expand All @@ -446,6 +456,7 @@ def subscribe(subscriber)
end

expect(last_transaction).to include_tags(
"reported_by" => "rails_error_reporter",
"tag1" => "value1",
"tag2" => "value2",
"severity" => "warning"
Expand Down
Loading