yabeda-rails 0.8.1 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/test.yml +4 -8
- data/.rubocop.yml +1 -1
- data/CHANGELOG.md +11 -0
- data/lib/yabeda/rails/config.rb +2 -0
- data/lib/yabeda/rails/event.rb +68 -0
- data/lib/yabeda/rails/version.rb +1 -1
- data/lib/yabeda/rails.rb +10 -25
- data/yabeda-rails.gemspec +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 57391802b01a1ba8d7957b6aa3a41ebda6fcf3663587fd1cfdb87dcda3735ac7
|
4
|
+
data.tar.gz: 13db9080e69a1dc4d110ee49f38610990b1c025c3bbc1d1151ec43cd67ed2520
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2e7fc9992fa76b68825e1ff0f35073fee8f18e8bee4fe564de15d6ed7a38ae0e17617c061594760ae92585866f214798635c2866264f25963e588ffc7bb1eba0
|
7
|
+
data.tar.gz: 478201adab47ddb487f12d5ec61fe55fc02b86d3bc779fe088d9bca7a13568468c310ac4dd46497e5a222e1eeeb604da43a5b0b1d270b22cffe0bc5cb559f318
|
data/.github/workflows/test.yml
CHANGED
@@ -18,16 +18,14 @@ jobs:
|
|
18
18
|
fail-fast: false
|
19
19
|
matrix:
|
20
20
|
include:
|
21
|
-
- ruby: "3.
|
21
|
+
- ruby: "3.2"
|
22
22
|
rails: "HEAD"
|
23
|
-
- ruby: "3.
|
23
|
+
- ruby: "3.1"
|
24
24
|
rails: "7.0"
|
25
|
-
- ruby: "
|
25
|
+
- ruby: "3.0"
|
26
26
|
rails: "6.1"
|
27
|
-
- ruby: "2.
|
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
data/CHANGELOG.md
CHANGED
@@ -5,6 +5,16 @@ 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
|
+
|
8
18
|
## 0.8.1 - 2022-06-06
|
9
19
|
|
10
20
|
### Fixed
|
@@ -85,3 +95,4 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
|
|
85
95
|
[@liaden]: https://github.com/liaden "Joel Johnson"
|
86
96
|
[@lautis]: https://github.com/lautis "Ville Lautanala"
|
87
97
|
[@dks17]: https://github.com/dks17 "Konstantin"
|
98
|
+
[@lewispb]: https://github.com/lewispb "Lewis Buckley"
|
data/lib/yabeda/rails/config.rb
CHANGED
@@ -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
|
data/lib/yabeda/rails/version.rb
CHANGED
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 =
|
31
|
+
config = ::Yabeda::Rails.config
|
31
32
|
|
32
33
|
group :rails
|
33
34
|
|
@@ -54,39 +55,23 @@ module Yabeda
|
|
54
55
|
end
|
55
56
|
|
56
57
|
ActiveSupport::Notifications.subscribe "process_action.action_controller" do |*args|
|
57
|
-
event =
|
58
|
-
labels = {
|
59
|
-
controller: event.payload[:params]["controller"],
|
60
|
-
action: event.payload[:params]["action"],
|
61
|
-
status: Yabeda::Rails.event_status_code(event),
|
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,
|
69
|
-
rails_view_runtime.measure(labels,
|
70
|
-
rails_db_runtime.measure(labels,
|
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
|
81
|
-
|
82
|
-
end
|
83
|
-
|
84
|
-
def event_status_code(event)
|
85
|
-
if event.payload[:status].nil? && event.payload[:exception].present?
|
86
|
-
ActionDispatch::ExceptionWrapper.status_code_for_exception(event.payload[:exception].first)
|
87
|
-
else
|
88
|
-
event.payload[:status]
|
89
|
-
end
|
73
|
+
def config
|
74
|
+
@config ||= Config.new
|
90
75
|
end
|
91
76
|
end
|
92
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.
|
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.
|
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:
|
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.
|
156
|
+
version: '2.5'
|
156
157
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
157
158
|
requirements:
|
158
159
|
- - ">="
|