yabeda-rails 0.8.1 → 0.10.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/lint.yml +2 -2
- data/.github/workflows/{build-release.yml → release.yml} +9 -5
- data/.github/workflows/test.yml +19 -25
- data/.rubocop.yml +1 -1
- data/CHANGELOG.md +24 -0
- data/Gemfile +1 -1
- data/README.md +9 -0
- data/lib/yabeda/rails/config.rb +4 -0
- data/lib/yabeda/rails/event.rb +72 -0
- data/lib/yabeda/rails/railtie.rb +5 -1
- data/lib/yabeda/rails/version.rb +1 -1
- data/lib/yabeda/rails.rb +17 -29
- data/yabeda-rails.gemspec +1 -1
- metadata +6 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e922a45967dbc75c255c7bf6453e796e13157be68ba0c0c6813e8eb80633db8f
|
4
|
+
data.tar.gz: f4bf58df8b7a6904f40a4e47c7fdeab0756ffbab4f59910e90dab01f77e47886
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 256b563227886fadd1def58675cd7160e2ffadd8b1b7dd0951bdc203b7a3c0f97e298fde9640c4006187e9a202db8267498a8d2185a3f0b4100f77782555aa94
|
7
|
+
data.tar.gz: 62c3b89bf1fd7f7bb48a5bfeddd63f1d9cf86540db6b49d80075b00b94116471db59d6c7577554e4aff84f8063eacb094839c6789264cb380a6d0f585022cf1f
|
data/.github/workflows/lint.yml
CHANGED
@@ -15,10 +15,10 @@ jobs:
|
|
15
15
|
name: RuboCop
|
16
16
|
runs-on: ubuntu-latest
|
17
17
|
steps:
|
18
|
-
- uses: actions/checkout@
|
18
|
+
- uses: actions/checkout@v4
|
19
19
|
- uses: ruby/setup-ruby@v1
|
20
20
|
with:
|
21
|
-
ruby-version: "3.
|
21
|
+
ruby-version: "3.4"
|
22
22
|
bundler-cache: true
|
23
23
|
- name: Lint Ruby code with RuboCop
|
24
24
|
run: |
|
@@ -1,4 +1,4 @@
|
|
1
|
-
name: Build and release gem
|
1
|
+
name: Build and release gem
|
2
2
|
|
3
3
|
on:
|
4
4
|
push:
|
@@ -8,13 +8,17 @@ on:
|
|
8
8
|
jobs:
|
9
9
|
release:
|
10
10
|
runs-on: ubuntu-latest
|
11
|
+
permissions:
|
12
|
+
contents: write
|
13
|
+
id-token: write
|
14
|
+
packages: write
|
11
15
|
steps:
|
12
|
-
- uses: actions/checkout@
|
16
|
+
- uses: actions/checkout@v4
|
13
17
|
with:
|
14
18
|
fetch-depth: 0 # Fetch current tag as annotated. See https://github.com/actions/checkout/issues/290
|
15
19
|
- uses: ruby/setup-ruby@v1
|
16
20
|
with:
|
17
|
-
ruby-version:
|
21
|
+
ruby-version: "3.4"
|
18
22
|
- name: "Extract data from tag: version, message, body"
|
19
23
|
id: tag
|
20
24
|
run: |
|
@@ -75,8 +79,8 @@ jobs:
|
|
75
79
|
GEM_HOST_API_KEY: Bearer ${{ secrets.GITHUB_TOKEN }}
|
76
80
|
run: |
|
77
81
|
gem push yabeda-rails-${{ steps.tag.outputs.version }}.gem --host https://rubygems.pkg.github.com/${{ github.repository_owner }}
|
82
|
+
- name: Configure RubyGems Credentials
|
83
|
+
uses: rubygems/configure-rubygems-credentials@main
|
78
84
|
- name: Publish to RubyGems
|
79
|
-
env:
|
80
|
-
GEM_HOST_API_KEY: "${{ secrets.RUBYGEMS_API_KEY }}"
|
81
85
|
run: |
|
82
86
|
gem push yabeda-rails-${{ steps.tag.outputs.version }}.gem
|
data/.github/workflows/test.yml
CHANGED
@@ -14,40 +14,34 @@ jobs:
|
|
14
14
|
# Skip running tests for local pull requests (use push event instead), run only for foreign ones
|
15
15
|
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.owner.login != github.event.pull_request.base.repo.owner.login
|
16
16
|
runs-on: ubuntu-latest
|
17
|
+
continue-on-error: ${{ matrix.optional || false }}
|
17
18
|
strategy:
|
18
19
|
fail-fast: false
|
19
20
|
matrix:
|
20
21
|
include:
|
21
|
-
- ruby:
|
22
|
+
- ruby: "head"
|
22
23
|
rails: "HEAD"
|
23
|
-
|
24
|
+
optional: true
|
25
|
+
- ruby: "3.4"
|
26
|
+
rails: "8.0"
|
27
|
+
- ruby: "3.3"
|
28
|
+
rails: "7.2"
|
29
|
+
- ruby: "3.2"
|
30
|
+
rails: "7.1"
|
31
|
+
- ruby: "3.1"
|
24
32
|
rails: "7.0"
|
25
|
-
- ruby: "
|
33
|
+
- ruby: "3.0"
|
26
34
|
rails: "6.1"
|
27
|
-
- ruby: "2.
|
35
|
+
- ruby: "2.7"
|
28
36
|
rails: "6.0"
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
image: ruby:${{ matrix.ruby }}
|
33
|
-
env:
|
34
|
-
CI: true
|
35
|
-
RAILS_VERSION: ${{ matrix.rails }}
|
37
|
+
env:
|
38
|
+
CI: true
|
39
|
+
RAILS_VERSION: ${{ matrix.rails }}
|
36
40
|
steps:
|
37
|
-
- uses: actions/checkout@
|
38
|
-
- uses:
|
41
|
+
- uses: actions/checkout@v4
|
42
|
+
- uses: ruby/setup-ruby@v1
|
39
43
|
with:
|
40
|
-
|
41
|
-
|
42
|
-
restore-keys: |
|
43
|
-
bundle-${{ matrix.ruby }}-${{ hashFiles('**/*.gemspec') }}-${{ hashFiles('**/Gemfile') }}
|
44
|
-
bundle-${{ matrix.ruby }}-
|
45
|
-
- name: Upgrade Bundler to 2.0 (for older Rubies)
|
46
|
-
run: gem install bundler -v '~> 2.0'
|
47
|
-
- name: Bundle install
|
48
|
-
run: |
|
49
|
-
bundle config path vendor/bundle
|
50
|
-
bundle install
|
51
|
-
bundle update
|
44
|
+
ruby-version: ${{ matrix.ruby }}
|
45
|
+
bundler-cache: true
|
52
46
|
- name: Run RSpec
|
53
47
|
run: bundle exec rspec
|
data/.rubocop.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -5,6 +5,25 @@ 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.10.0 - 2025-09-09
|
9
|
+
|
10
|
+
### Added
|
11
|
+
|
12
|
+
- Add Passenger server to auto register list [@mabrikan][] in [#28](https://github.com/yabeda-rb/yabeda-rails/pull/28)
|
13
|
+
- Allow defining default_tags only for rails group [@magec][] in [#30](https://github.com/yabeda-rb/yabeda-rails/pull/30)
|
14
|
+
- Ability to customize the bucket sizing for histograms [@skateman][] in [#32](https://github.com/yabeda-rb/yabeda-rails/pull/32)
|
15
|
+
- Ability to ignore certain controller#actions [@zzip][] in [#33](https://github.com/yabeda-rb/yabeda-rails/pull/33)
|
16
|
+
|
17
|
+
## 0.9.0 - 2023-08-03
|
18
|
+
|
19
|
+
### Added
|
20
|
+
|
21
|
+
- 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)
|
22
|
+
|
23
|
+
## Changed
|
24
|
+
|
25
|
+
- Minimal Ruby version increased to 2.5. [@Envek][]
|
26
|
+
|
8
27
|
## 0.8.1 - 2022-06-06
|
9
28
|
|
10
29
|
### Fixed
|
@@ -85,3 +104,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
|
|
85
104
|
[@liaden]: https://github.com/liaden "Joel Johnson"
|
86
105
|
[@lautis]: https://github.com/lautis "Ville Lautanala"
|
87
106
|
[@dks17]: https://github.com/dks17 "Konstantin"
|
107
|
+
[@lewispb]: https://github.com/lewispb "Lewis Buckley"
|
108
|
+
[@mabrikan]: https://github.com/mabrikan "Musaed Albrikan"
|
109
|
+
[@magec]: https://github.com/magec "Jose Fernández"
|
110
|
+
[@skateman]: https://github.com/skateman "Halász Dávid"
|
111
|
+
[@zzip]: https://github.com/zzip "Dale Hofkens"
|
data/Gemfile
CHANGED
@@ -7,7 +7,7 @@ git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
|
|
7
7
|
# Specify your gem's dependencies in yabeda-rails.gemspec
|
8
8
|
gemspec
|
9
9
|
|
10
|
-
rails_version = ENV.fetch("RAILS_VERSION", "~>
|
10
|
+
rails_version = ENV.fetch("RAILS_VERSION", "~> 8.0")
|
11
11
|
case rails_version
|
12
12
|
when "HEAD"
|
13
13
|
git "https://github.com/rails/rails.git" do
|
data/README.md
CHANGED
@@ -76,6 +76,15 @@ end
|
|
76
76
|
```
|
77
77
|
`append_info_to_payload` is a method from [ActionController::Instrumentation](https://api.rubyonrails.org/classes/ActionController/Instrumentation.html#method-i-append_info_to_payload)
|
78
78
|
|
79
|
+
## Configuration
|
80
|
+
|
81
|
+
Configuration is handled by [anyway_config] gem. With it you can load settings from environment variables (upcased and prefixed with `YABEDA_RAILS_`), YAML files, and other sources. See [anyway_config] docs for details.
|
82
|
+
|
83
|
+
| Config key | Type | Default | Description |
|
84
|
+
| ---------------------- | ------- | ------- | ----------------------------------------------------------------------------------------------------------------------------------------------------- |
|
85
|
+
| `apdex_target` | integer | nil | Tolerable time for Apdex in seconds, exposed as gauge if set. |
|
86
|
+
| `controller_name_case` | symbol | :snake | Defines whether controller name is reported in camel case (:camel) or snake case (:snake). |
|
87
|
+
| `ignore_actions` | array | [] | array of controller#action strings that should be ignored, controller should be in camel case, example `['HealthCheck::HealthCheckController#index']` |
|
79
88
|
|
80
89
|
## Development
|
81
90
|
|
data/lib/yabeda/rails/config.rb
CHANGED
@@ -4,10 +4,14 @@ 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 :buckets
|
13
|
+
attr_config controller_name_case: :snake
|
14
|
+
attr_config ignore_actions: []
|
11
15
|
end
|
12
16
|
end
|
13
17
|
end
|
@@ -0,0 +1,72 @@
|
|
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 + Yabeda.rails.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
|
+
def controller_action
|
33
|
+
"#{payload[:controller]}##{payload[:action]}"
|
34
|
+
end
|
35
|
+
|
36
|
+
private
|
37
|
+
|
38
|
+
def controller
|
39
|
+
case Yabeda::Rails.config.controller_name_case
|
40
|
+
when :camel
|
41
|
+
payload[:controller]
|
42
|
+
else
|
43
|
+
payload[:params]["controller"]
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def action
|
48
|
+
payload[:action]
|
49
|
+
end
|
50
|
+
|
51
|
+
def status
|
52
|
+
if payload[:status].nil? && payload[:exception].present?
|
53
|
+
ActionDispatch::ExceptionWrapper.status_code_for_exception(payload[:exception].first)
|
54
|
+
else
|
55
|
+
payload[:status]
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
def format
|
60
|
+
payload[:format]
|
61
|
+
end
|
62
|
+
|
63
|
+
def method
|
64
|
+
payload[:method].downcase
|
65
|
+
end
|
66
|
+
|
67
|
+
def ms2s(milliseconds)
|
68
|
+
(milliseconds.to_f / 1000).round(3)
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
data/lib/yabeda/rails/railtie.rb
CHANGED
@@ -19,8 +19,12 @@ module Yabeda
|
|
19
19
|
::Rails.const_defined?("Unicorn::Launcher")
|
20
20
|
end
|
21
21
|
|
22
|
+
def passenger_server?
|
23
|
+
::Rails.const_defined?("PhusionPassenger")
|
24
|
+
end
|
25
|
+
|
22
26
|
initializer "yabeda-rails.metrics" do
|
23
|
-
::Yabeda::Rails.install! if rails_server? || puma_server? || unicorn_server?
|
27
|
+
::Yabeda::Rails.install! if rails_server? || puma_server? || unicorn_server? || passenger_server?
|
24
28
|
end
|
25
29
|
end
|
26
30
|
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,8 @@ 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
|
32
|
+
buckets = config.buckets || LONG_RUNNING_REQUEST_BUCKETS
|
31
33
|
|
32
34
|
group :rails
|
33
35
|
|
@@ -36,14 +38,14 @@ module Yabeda
|
|
36
38
|
|
37
39
|
histogram :request_duration, tags: %i[controller action status format method],
|
38
40
|
unit: :seconds,
|
39
|
-
buckets:
|
41
|
+
buckets: buckets,
|
40
42
|
comment: "A histogram of the response latency."
|
41
43
|
|
42
|
-
histogram :view_runtime, unit: :seconds, buckets:
|
44
|
+
histogram :view_runtime, unit: :seconds, buckets: buckets,
|
43
45
|
comment: "A histogram of the view rendering time.",
|
44
46
|
tags: %i[controller action status format method]
|
45
47
|
|
46
|
-
histogram :db_runtime, unit: :seconds, buckets:
|
48
|
+
histogram :db_runtime, unit: :seconds, buckets: buckets,
|
47
49
|
comment: "A histogram of the activerecord execution time.",
|
48
50
|
tags: %i[controller action status format method]
|
49
51
|
|
@@ -54,39 +56,25 @@ module Yabeda
|
|
54
56
|
end
|
55
57
|
|
56
58
|
ActiveSupport::Notifications.subscribe "process_action.action_controller" do |*args|
|
57
|
-
event =
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
labels.merge!(event.payload.slice(*Yabeda.default_tags.keys - labels.keys))
|
66
|
-
|
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]))
|
59
|
+
event = Yabeda::Rails::Event.new(*args)
|
60
|
+
|
61
|
+
next if event.controller_action.in?(config.ignore_actions)
|
62
|
+
|
63
|
+
rails_requests_total.increment(event.labels)
|
64
|
+
rails_request_duration.measure(event.labels, event.duration)
|
65
|
+
rails_view_runtime.measure(event.labels, event.view_runtime)
|
66
|
+
rails_db_runtime.measure(event.labels, event.db_runtime)
|
71
67
|
|
72
68
|
Yabeda::Rails.controller_handlers.each do |handler|
|
73
|
-
handler.call(event, labels)
|
69
|
+
handler.call(event, event.labels)
|
74
70
|
end
|
75
71
|
end
|
76
72
|
end
|
77
73
|
end
|
78
74
|
# rubocop: enable Metrics/MethodLength, Metrics/BlockLength, Metrics/AbcSize
|
79
75
|
|
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
|
76
|
+
def config
|
77
|
+
@config ||= Config.new
|
90
78
|
end
|
91
79
|
end
|
92
80
|
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,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: yabeda-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.10.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrey Novikov
|
8
|
-
autorequire:
|
9
8
|
bindir: exe
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
13
12
|
- !ruby/object:Gem::Dependency
|
14
13
|
name: activesupport
|
@@ -121,8 +120,8 @@ executables: []
|
|
121
120
|
extensions: []
|
122
121
|
extra_rdoc_files: []
|
123
122
|
files:
|
124
|
-
- ".github/workflows/build-release.yml"
|
125
123
|
- ".github/workflows/lint.yml"
|
124
|
+
- ".github/workflows/release.yml"
|
126
125
|
- ".github/workflows/test.yml"
|
127
126
|
- ".gitignore"
|
128
127
|
- ".rspec"
|
@@ -136,6 +135,7 @@ files:
|
|
136
135
|
- bin/setup
|
137
136
|
- lib/yabeda/rails.rb
|
138
137
|
- lib/yabeda/rails/config.rb
|
138
|
+
- lib/yabeda/rails/event.rb
|
139
139
|
- lib/yabeda/rails/railtie.rb
|
140
140
|
- lib/yabeda/rails/version.rb
|
141
141
|
- yabeda-rails-logo.png
|
@@ -144,7 +144,6 @@ homepage: https://github.com/yabeda-rb/yabeda-rails
|
|
144
144
|
licenses:
|
145
145
|
- MIT
|
146
146
|
metadata: {}
|
147
|
-
post_install_message:
|
148
147
|
rdoc_options: []
|
149
148
|
require_paths:
|
150
149
|
- lib
|
@@ -152,15 +151,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
152
151
|
requirements:
|
153
152
|
- - ">="
|
154
153
|
- !ruby/object:Gem::Version
|
155
|
-
version: '2.
|
154
|
+
version: '2.5'
|
156
155
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
157
156
|
requirements:
|
158
157
|
- - ">="
|
159
158
|
- !ruby/object:Gem::Version
|
160
159
|
version: '0'
|
161
160
|
requirements: []
|
162
|
-
rubygems_version: 3.
|
163
|
-
signing_key:
|
161
|
+
rubygems_version: 3.6.9
|
164
162
|
specification_version: 4
|
165
163
|
summary: Extensible metrics for monitoring Ruby on Rails application
|
166
164
|
test_files: []
|