Skip to content

Commit

Permalink
Merge pull request #121 from hennevogel/feature/status_500
Browse files Browse the repository at this point in the history
Record exception class name
  • Loading branch information
hennevogel authored Jul 21, 2020
2 parents 35b4f2b + fa151dc commit 4deaf6e
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ For the full commit log, [see here](https://github.com/influxdata/influxdb-rails
- Implement `perform_start.active_job` subscriber (https://guides.rubyonrails.org/active_support_instrumentation.html#perform-start-active-job)
- Implement `perform.active_job` subscriber (https://guides.rubyonrails.org/active_support_instrumentation.html#perform-active-job)
- Implement block instrumentation `InfluxDB::Rails.instrument do; 1 + 1; end`
- Record unhandled exceptions as tags for process_action.action_controller

## v1.0.0, released 2019-10-23
The Final release, no code changes.
Expand Down
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,15 @@ Reported tags:
method: "PostsController#index",
http_method: "GET",
format: "html",
status: "200"
status: ["200", ""]
exception: ["", "ArgumentError"]
}
```

*Note*: If an exception happens during that particular instrumentation the
`status` will be blank and the tag `exception` will contain the name of the
exception class.

### Action View

Reported ActiveSupport instrumentation hooks:
Expand Down
1 change: 1 addition & 0 deletions lib/influxdb/rails/middleware/request_subscriber.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ def tags
status: payload[:status],
format: payload[:format],
http_method: payload[:method],
exception: payload[:exception]&.first,
}
end

Expand Down
5 changes: 3 additions & 2 deletions spec/requests/action_controller_metrics_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,9 @@

expect_metric(
tags: a_hash_including(
method: "ExceptionsController#index",
hook: "process_action"
method: "ExceptionsController#index",
hook: "process_action",
exception: "ZeroDivisionError"
)
)
end
Expand Down

0 comments on commit 4deaf6e

Please sign in to comment.