diff --git a/CHANGELOG.md b/CHANGELOG.md index 646297e..b68f0f3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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. diff --git a/README.md b/README.md index ca59587..654041d 100644 --- a/README.md +++ b/README.md @@ -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: diff --git a/lib/influxdb/rails/middleware/request_subscriber.rb b/lib/influxdb/rails/middleware/request_subscriber.rb index fa1f635..6da467f 100644 --- a/lib/influxdb/rails/middleware/request_subscriber.rb +++ b/lib/influxdb/rails/middleware/request_subscriber.rb @@ -19,6 +19,7 @@ def tags(payload) status: payload[:status], format: payload[:format], http_method: payload[:method], + exception: payload[:exception]&.first, } end diff --git a/spec/requests/action_controller_metrics_spec.rb b/spec/requests/action_controller_metrics_spec.rb index 953d2ad..84031a9 100644 --- a/spec/requests/action_controller_metrics_spec.rb +++ b/spec/requests/action_controller_metrics_spec.rb @@ -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