From 8646ee53025129c4ef1faaf32e543d488850cc26 Mon Sep 17 00:00:00 2001 From: Henne Vogelsang Date: Thu, 9 Sep 2021 18:45:25 +0200 Subject: [PATCH 1/3] Polyfill rails/rails/pull/39880 --- lib/influxdb/rails/middleware/request_subscriber.rb | 10 +++++++++- spec/requests/action_controller_metrics_spec.rb | 3 ++- spec/support/rails5/app.rb | 2 +- spec/support/rails6/app.rb | 2 +- 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/lib/influxdb/rails/middleware/request_subscriber.rb b/lib/influxdb/rails/middleware/request_subscriber.rb index 8ab0ee9..41e5237 100644 --- a/lib/influxdb/rails/middleware/request_subscriber.rb +++ b/lib/influxdb/rails/middleware/request_subscriber.rb @@ -16,7 +16,7 @@ def tags { method: "#{payload[:controller]}##{payload[:action]}", hook: "process_action", - status: payload[:status], + status: status, format: payload[:format], http_method: payload[:method], exception: payload[:exception]&.first, @@ -38,6 +38,14 @@ def started configuration.client.time_precision ) end + + def status + if payload[:exception] && ::Rails::VERSION::MAJOR < 7 + ActionDispatch::ExceptionWrapper.status_code_for_exception(payload[:exception].first) + else + payload[:status] + end + end end end end diff --git a/spec/requests/action_controller_metrics_spec.rb b/spec/requests/action_controller_metrics_spec.rb index 15ac743..2820e66 100644 --- a/spec/requests/action_controller_metrics_spec.rb +++ b/spec/requests/action_controller_metrics_spec.rb @@ -89,7 +89,8 @@ tags: a_hash_including( method: "ExceptionsController#index", hook: "process_action", - exception: "ZeroDivisionError" + exception: "ActiveRecord::RecordNotFound", + status: 404 ) ) end diff --git a/spec/support/rails5/app.rb b/spec/support/rails5/app.rb index c900b98..f1b4cf2 100644 --- a/spec/support/rails5/app.rb +++ b/spec/support/rails5/app.rb @@ -76,7 +76,7 @@ def show class ExceptionsController < ApplicationController def index - 1 / 0 + raise ActiveRecord::RecordNotFound end end diff --git a/spec/support/rails6/app.rb b/spec/support/rails6/app.rb index c900b98..f1b4cf2 100644 --- a/spec/support/rails6/app.rb +++ b/spec/support/rails6/app.rb @@ -76,7 +76,7 @@ def show class ExceptionsController < ApplicationController def index - 1 / 0 + raise ActiveRecord::RecordNotFound end end From 55836b8dffb8d8a8395739082e8a6362a1e3faa0 Mon Sep 17 00:00:00 2001 From: Henne Vogelsang Date: Thu, 9 Sep 2021 18:46:28 +0200 Subject: [PATCH 2/3] We stopped testing on 2.4 a while ago Now rubocop also dropped support for 2.4, let's require 2.5. --- .rubocop.yml | 3 ++- influxdb-rails.gemspec | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index d95f178..d6debf3 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -11,7 +11,8 @@ AllCops: - 'vendor/bundle/**/*' DisplayCopNames: true StyleGuideCopsOnly: false - TargetRubyVersion: 2.4 + TargetRubyVersion: 2.5 + NewCops: enable Layout/EmptyLinesAroundArguments: Enabled: false diff --git a/influxdb-rails.gemspec b/influxdb-rails.gemspec index bd576a3..e651c49 100644 --- a/influxdb-rails.gemspec +++ b/influxdb-rails.gemspec @@ -22,7 +22,7 @@ Gem::Specification.new do |spec| spec.test_files = spec.files.grep(%r{^(test|spec|features|smoke)/}) spec.require_paths = ["lib"] - spec.required_ruby_version = ">= 2.4.0" + spec.required_ruby_version = ">= 2.5.0" spec.add_runtime_dependency "influxdb", "~> 0.6", ">= 0.6.4" spec.add_runtime_dependency "railties", ">= 5.0" From 6c5001a076c7f817d288b6af4ec10ff907795255 Mon Sep 17 00:00:00 2001 From: Henne Vogelsang Date: Wed, 15 Sep 2021 11:29:43 +0200 Subject: [PATCH 3/3] Release 1.0.3 --- CHANGELOG.md | 5 +++++ lib/influxdb/rails/version.rb | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1121bf8..490481d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,11 @@ For the full commit log, [see here](https://github.com/influxdata/influxdb-rails/commits/one-stable). +## v1.0.3, released 2021-09-15 + +- In case of unhandled exceptions, set status in measurements like Rails.logger does +- Require Ruby 2.5 + ## v1.0.2, released 2021-04-13 Fix passing booleans to custom tags. diff --git a/lib/influxdb/rails/version.rb b/lib/influxdb/rails/version.rb index 1c4a33e..f8d9fa3 100644 --- a/lib/influxdb/rails/version.rb +++ b/lib/influxdb/rails/version.rb @@ -1,5 +1,5 @@ module InfluxDB module Rails - VERSION = "1.0.2".freeze + VERSION = "1.0.3".freeze end end