yabeda-rails 0.8.0 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 107b2a512068172c19c08b18dc0f452d9ee1794c4894979b1a88c459a8dcf5c5
4
- data.tar.gz: 686e32000199bc29bb8096d09aa336b4cf67d9cfe789e44b91653467caee5524
3
+ metadata.gz: 57391802b01a1ba8d7957b6aa3a41ebda6fcf3663587fd1cfdb87dcda3735ac7
4
+ data.tar.gz: 13db9080e69a1dc4d110ee49f38610990b1c025c3bbc1d1151ec43cd67ed2520
5
5
  SHA512:
6
- metadata.gz: f59dd373f43b40e47b03cecef02ad47ce8fdcf49661430fddf003007f60d69895a26e538d23bd829e664aaa27145789f2a934ed401d6c593ca314ff3271d65d2
7
- data.tar.gz: 6de6d25b29ef13f07f9a1e008999577c18891ceaede127a99ac541235442ed72f3b74316e6f7b16950169fd5309e6d1fcc86cf2b4999106ff08a46349db27e0b
6
+ metadata.gz: 2e7fc9992fa76b68825e1ff0f35073fee8f18e8bee4fe564de15d6ed7a38ae0e17617c061594760ae92585866f214798635c2866264f25963e588ffc7bb1eba0
7
+ data.tar.gz: 478201adab47ddb487f12d5ec61fe55fc02b86d3bc779fe088d9bca7a13568468c310ac4dd46497e5a222e1eeeb604da43a5b0b1d270b22cffe0bc5cb559f318
@@ -18,16 +18,14 @@ jobs:
18
18
  fail-fast: false
19
19
  matrix:
20
20
  include:
21
- - ruby: "3.1"
21
+ - ruby: "3.2"
22
22
  rails: "HEAD"
23
- - ruby: "3.0"
23
+ - ruby: "3.1"
24
24
  rails: "7.0"
25
- - ruby: "2.7"
25
+ - ruby: "3.0"
26
26
  rails: "6.1"
27
- - ruby: "2.6"
27
+ - ruby: "2.7"
28
28
  rails: "6.0"
29
- - ruby: "2.5"
30
- rails: "5.2"
31
29
  container:
32
30
  image: ruby:${{ matrix.ruby }}
33
31
  env:
@@ -42,8 +40,6 @@ jobs:
42
40
  restore-keys: |
43
41
  bundle-${{ matrix.ruby }}-${{ hashFiles('**/*.gemspec') }}-${{ hashFiles('**/Gemfile') }}
44
42
  bundle-${{ matrix.ruby }}-
45
- - name: Upgrade Bundler to 2.0 (for older Rubies)
46
- run: gem install bundler -v '~> 2.0'
47
43
  - name: Bundle install
48
44
  run: |
49
45
  bundle config path vendor/bundle
data/.rubocop.yml CHANGED
@@ -3,7 +3,7 @@ require:
3
3
  - rubocop-rspec
4
4
 
5
5
  AllCops:
6
- TargetRubyVersion: 2.4
6
+ TargetRubyVersion: 2.5
7
7
 
8
8
  Metrics/BlockLength:
9
9
  Exclude:
data/CHANGELOG.md CHANGED
@@ -5,6 +5,22 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
6
6
  and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## 0.9.0 - 2023-08-03
9
+
10
+ ### Added
11
+
12
+ - Ability to switch controller name case in `controller` tag between `:snake` and `:camel` case. [@lewispb][] in [#26](https://github.com/yabeda-rb/yabeda-rails/pull/26)
13
+
14
+ ## Changed
15
+
16
+ - Minimal Ruby version increased to 2.5. [@Envek][]
17
+
18
+ ## 0.8.1 - 2022-06-06
19
+
20
+ ### Fixed
21
+
22
+ - Fill status codes for responses with unhandled exceptions. [@dks17][] in [#24](https://github.com/yabeda-rb/yabeda-rails/pull/24)
23
+
8
24
  ## 0.8.0 - 2022-05-30
9
25
 
10
26
  ### Added
@@ -78,3 +94,5 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
78
94
  [@Envek]: https://github.com/Envek "Andrey Novikov"
79
95
  [@liaden]: https://github.com/liaden "Joel Johnson"
80
96
  [@lautis]: https://github.com/lautis "Ville Lautanala"
97
+ [@dks17]: https://github.com/dks17 "Konstantin"
98
+ [@lewispb]: https://github.com/lewispb "Lewis Buckley"
@@ -4,10 +4,12 @@ require "anyway"
4
4
 
5
5
  module Yabeda
6
6
  module Rails
7
+ # yabeda-rails configuration
7
8
  class Config < ::Anyway::Config
8
9
  config_name :yabeda_rails
9
10
 
10
11
  attr_config :apdex_target
12
+ attr_config controller_name_case: :snake
11
13
  end
12
14
  end
13
15
  end
@@ -0,0 +1,68 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Yabeda
4
+ module Rails
5
+ # ActiveSupport Event with added logic for Yabeda tags formatting
6
+ class Event < ActiveSupport::Notifications::Event
7
+ def labels
8
+ @labels ||= begin
9
+ labels = {
10
+ controller: controller,
11
+ action: action,
12
+ status: status,
13
+ format: format,
14
+ method: method,
15
+ }
16
+ labels.merge(payload.slice(*Yabeda.default_tags.keys - labels.keys))
17
+ end
18
+ end
19
+
20
+ def duration
21
+ ms2s super
22
+ end
23
+
24
+ def view_runtime
25
+ ms2s payload[:view_runtime]
26
+ end
27
+
28
+ def db_runtime
29
+ ms2s payload[:db_runtime]
30
+ end
31
+
32
+ private
33
+
34
+ def controller
35
+ case Yabeda::Rails.config.controller_name_case
36
+ when :camel
37
+ payload[:controller]
38
+ else
39
+ payload[:params]["controller"]
40
+ end
41
+ end
42
+
43
+ def action
44
+ payload[:action]
45
+ end
46
+
47
+ def status
48
+ if payload[:status].nil? && payload[:exception].present?
49
+ ActionDispatch::ExceptionWrapper.status_code_for_exception(payload[:exception].first)
50
+ else
51
+ payload[:status]
52
+ end
53
+ end
54
+
55
+ def format
56
+ payload[:format]
57
+ end
58
+
59
+ def method
60
+ payload[:method].downcase
61
+ end
62
+
63
+ def ms2s(milliseconds)
64
+ (milliseconds.to_f / 1000).round(3)
65
+ end
66
+ end
67
+ end
68
+ end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Yabeda
4
4
  module Rails
5
- VERSION = "0.8.0"
5
+ VERSION = "0.9.0"
6
6
  end
7
7
  end
data/lib/yabeda/rails.rb CHANGED
@@ -5,6 +5,7 @@ require "active_support"
5
5
  require "rails/railtie"
6
6
  require "yabeda/rails/railtie"
7
7
  require "yabeda/rails/config"
8
+ require "yabeda/rails/event"
8
9
 
9
10
  module Yabeda
10
11
  # Minimal set of Rails-specific metrics for using with Yabeda
@@ -27,7 +28,7 @@ module Yabeda
27
28
  # rubocop: disable Metrics/MethodLength, Metrics/BlockLength, Metrics/AbcSize
28
29
  def install!
29
30
  Yabeda.configure do
30
- config = Config.new
31
+ config = ::Yabeda::Rails.config
31
32
 
32
33
  group :rails
33
34
 
@@ -54,31 +55,23 @@ module Yabeda
54
55
  end
55
56
 
56
57
  ActiveSupport::Notifications.subscribe "process_action.action_controller" do |*args|
57
- event = ActiveSupport::Notifications::Event.new(*args)
58
- labels = {
59
- controller: event.payload[:params]["controller"],
60
- action: event.payload[:params]["action"],
61
- status: event.payload[:status],
62
- format: event.payload[:format],
63
- method: event.payload[:method].downcase,
64
- }
65
- labels.merge!(event.payload.slice(*Yabeda.default_tags.keys - labels.keys))
58
+ event = Yabeda::Rails::Event.new(*args)
66
59
 
67
- rails_requests_total.increment(labels)
68
- rails_request_duration.measure(labels, Yabeda::Rails.ms2s(event.duration))
69
- rails_view_runtime.measure(labels, Yabeda::Rails.ms2s(event.payload[:view_runtime]))
70
- rails_db_runtime.measure(labels, Yabeda::Rails.ms2s(event.payload[:db_runtime]))
60
+ rails_requests_total.increment(event.labels)
61
+ rails_request_duration.measure(event.labels, event.duration)
62
+ rails_view_runtime.measure(event.labels, event.view_runtime)
63
+ rails_db_runtime.measure(event.labels, event.db_runtime)
71
64
 
72
65
  Yabeda::Rails.controller_handlers.each do |handler|
73
- handler.call(event, labels)
66
+ handler.call(event, event.labels)
74
67
  end
75
68
  end
76
69
  end
77
70
  end
78
71
  # rubocop: enable Metrics/MethodLength, Metrics/BlockLength, Metrics/AbcSize
79
72
 
80
- def ms2s(milliseconds)
81
- (milliseconds.to_f / 1000).round(3)
73
+ def config
74
+ @config ||= Config.new
82
75
  end
83
76
  end
84
77
  end
data/yabeda-rails.gemspec CHANGED
@@ -22,7 +22,7 @@ Gem::Specification.new do |spec|
22
22
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
23
23
  spec.require_paths = ["lib"]
24
24
 
25
- spec.required_ruby_version = ">= 2.4"
25
+ spec.required_ruby_version = ">= 2.5"
26
26
 
27
27
  spec.add_dependency "activesupport"
28
28
  spec.add_dependency "anyway_config", ">= 1.3", "< 3"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yabeda-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
4
+ version: 0.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrey Novikov
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-05-30 00:00:00.000000000 Z
11
+ date: 2023-08-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -136,6 +136,7 @@ files:
136
136
  - bin/setup
137
137
  - lib/yabeda/rails.rb
138
138
  - lib/yabeda/rails/config.rb
139
+ - lib/yabeda/rails/event.rb
139
140
  - lib/yabeda/rails/railtie.rb
140
141
  - lib/yabeda/rails/version.rb
141
142
  - yabeda-rails-logo.png
@@ -152,7 +153,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
152
153
  requirements:
153
154
  - - ">="
154
155
  - !ruby/object:Gem::Version
155
- version: '2.4'
156
+ version: '2.5'
156
157
  required_rubygems_version: !ruby/object:Gem::Requirement
157
158
  requirements:
158
159
  - - ">="