yabeda-hanami 0.1.0 → 0.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b1406f7e10b7a1f5b792b5b6ef97e5d6315a6f8fb09e29d5bc6b9950e11bda9c
4
- data.tar.gz: 63555bfe70adb4acf5a750b9ee5f3e99743945050068b05e62a0ad7ab549bcc7
3
+ metadata.gz: 58a6168aa194810a2f85b45a666a62eb22d36fb52d96b3374609b31cbb59eae8
4
+ data.tar.gz: bfc7d434f6e5c3f6d6edcc221c6f3ccf436f016f8259356704149d833ca28494
5
5
  SHA512:
6
- metadata.gz: dcacad87df056d8471f9f9667b219a33802d6d6de44388fdc631be3686e158aff9f87ba67fd2708fcdad7505956e9e2acb616c12e591c3639f3e3169e44f02fd
7
- data.tar.gz: 49ae81d3d62e3aaaedcab7134701a58546d882de5760fef579173cf9dd473a99ef0efdbe4dc0420ddd533036d0f3dbbf84b5a5996a6f6ced8a9ef65ac3ebee39
6
+ metadata.gz: a269518080c02df74e838dc4ded2f468020ffd98da5936915dd300fc6a153219efecb25168bffd303ee2f71e6b4a0894794b05fdfa294984887b0a4166f7107e
7
+ data.tar.gz: c5c9daa35ae37361a9fe9e20e61daf0e55466b05df2634178b716b7aaeb48a7e7f3560053b3b46991f6df05f894d00ce16ee10cdaa1adbaa2d758663760ca902
data/CHANGELOG.md ADDED
@@ -0,0 +1,15 @@
1
+ ## [Unreleased]
2
+
3
+ -
4
+
5
+ ## [0.2.0] - 2026-07-27
6
+
7
+ - Hanami 3.0 has been released, so we release a fresh version that supports it. The minimum supported Ruby version for Hanami 3 is 3.3, so we follow along here. The Yabeda dependency is left at 0.12, but you should use the newest available (currently 0.16).
8
+
9
+ ## [0.1.1] - 2024-04-05
10
+
11
+ - Yabeda::Prometheus::Adapter::UndeclaredMetricTags at Prometheus requires all used tags to be declared at metric registration time. Please add `tags` option to the declaration of metric `hanami_requests_total`. Error: labels must have the same signature (keys given: [:method, :path, :status, :remote_ip] vs. keys expected: [:method, :path, :remote_ip]
12
+
13
+ ## [0.1.0] - 2024-04-05
14
+
15
+ - Initial release
data/LICENSE.txt ADDED
@@ -0,0 +1,13 @@
1
+ Copyright 2026, Regents of the University of Michigan.
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
data/README.md ADDED
@@ -0,0 +1,174 @@
1
+ # Yabeda::Hanami
2
+
3
+ Built-in metrics for out of the box [Hanami](https://hanamirb.org/) applications monitoring.
4
+
5
+ [![Gem Version](https://badge.fury.io/rb/yabeda-hanami.svg)](https://badge.fury.io/rb/yabeda-hanami)
6
+
7
+ ## Metrics
8
+
9
+ ### Rack
10
+ | type | name | subscription[^1] | comment |
11
+ |-----------|-----------------------------|-----------------------|--------------------------------|
12
+ | counter | :hanami_requests_total | :"rack.request.start" | Total web requests received |
13
+ | counter | :hanami_responses_total | :"rack.request.stop" | Total web responses given |
14
+ | histogram | :hanami_processing_duration | :"rack.request.stop" | Processing duration in seconds |
15
+ | counter | :hanami_errors_total | :"rack.request.error" | Total rack errors |
16
+ [^1]: `id` of [Dry::Monitor::Notifications](https://www.rubydoc.info/gems/dry-monitor/Dry/Monitor/Notifications) declared in [Dry::Monitor::Rack::Middleware](https://www.rubydoc.info/gems/dry-monitor/Dry/Monitor/Rack/Middleware)
17
+
18
+ ## Installation
19
+
20
+ ### Gemfile
21
+ Add these lines to your application's Gemfile:
22
+
23
+ ```ruby
24
+ gem "yabeda-hanami", "~> 0.2"
25
+ # Then add monitoring system adapter, e.g.:
26
+ gem 'yabeda-prometheus'
27
+ ```
28
+
29
+ Alternatively, install from git:
30
+ ```ruby
31
+ gem "yabeda-hanami", "~> 0.2", git: "https://github.com/mlibrary/yabeda-hanami.git", tag: "v0.2.0"
32
+ # Then add monitoring system adapter, e.g.:
33
+ gem 'yabeda-prometheus'
34
+ ```
35
+
36
+ ### config.ru
37
+ Add these lines to your application's config.ru:
38
+
39
+ ```ruby
40
+ require "yabeda/prometheus"
41
+
42
+ # Use the monitoring system adapter, e.g.:
43
+ use Yabeda::Prometheus::Exporter #, path: "/metrics"
44
+ ```
45
+
46
+ ### config/providers/instrument.rb
47
+ Create an instrument provider for the application
48
+
49
+ ```ruby
50
+ # frozen_string_literal: true
51
+
52
+ require "yabeda/hanami"
53
+
54
+ Hanami.app.register_provider :instrument, namespace: true do
55
+ prepare do
56
+ Yabeda::Hanami.install!
57
+
58
+ config = Yabeda::Hanami.config
59
+
60
+ config.notifications = target["notifications"]
61
+
62
+ Yabeda.configure!
63
+ end
64
+
65
+ start do
66
+ _config = Yabeda::Hanami.config
67
+
68
+ Yabeda::Hanami.subscribe!
69
+ end
70
+ end
71
+ ```
72
+
73
+ ## Verification
74
+
75
+ In the above example the route `http://127.0.0.1:2300/metrics` returns the application's metrics.
76
+
77
+ ```shell
78
+ # TYPE hanami_requests_total counter
79
+ # HELP hanami_requests_total A counter of the total number of HTTP requests Hanami has processed.
80
+ hanami_requests_total{method="GET",path="/",status="",remote_ip="172.24.0.1"} 2.0
81
+ # TYPE hanami_responses_total counter
82
+ # HELP hanami_responses_total A counter of the total number of HTTP responses Hanami has processed.
83
+ hanami_responses_total{method="GET",path="/",status="200",remote_ip="172.24.0.1"} 2.0
84
+ # TYPE hanami_processing_duration_seconds histogram
85
+ # HELP hanami_processing_duration_seconds A histogram of the processing duration.
86
+ hanami_processing_duration_seconds_bucket{method="GET",path="/",status="200",remote_ip="172.24.0.1",le="0.005"} 0.0
87
+ hanami_processing_duration_seconds_bucket{method="GET",path="/",status="200",remote_ip="172.24.0.1",le="0.01"} 0.0
88
+ hanami_processing_duration_seconds_bucket{method="GET",path="/",status="200",remote_ip="172.24.0.1",le="0.025"} 0.0
89
+ hanami_processing_duration_seconds_bucket{method="GET",path="/",status="200",remote_ip="172.24.0.1",le="0.05"} 0.0
90
+ hanami_processing_duration_seconds_bucket{method="GET",path="/",status="200",remote_ip="172.24.0.1",le="0.1"} 1.0
91
+ hanami_processing_duration_seconds_bucket{method="GET",path="/",status="200",remote_ip="172.24.0.1",le="0.25"} 2.0
92
+ hanami_processing_duration_seconds_bucket{method="GET",path="/",status="200",remote_ip="172.24.0.1",le="0.5"} 2.0
93
+ hanami_processing_duration_seconds_bucket{method="GET",path="/",status="200",remote_ip="172.24.0.1",le="1"} 2.0
94
+ hanami_processing_duration_seconds_bucket{method="GET",path="/",status="200",remote_ip="172.24.0.1",le="2.5"} 2.0
95
+ hanami_processing_duration_seconds_bucket{method="GET",path="/",status="200",remote_ip="172.24.0.1",le="5"} 2.0
96
+ hanami_processing_duration_seconds_bucket{method="GET",path="/",status="200",remote_ip="172.24.0.1",le="10"} 2.0
97
+ hanami_processing_duration_seconds_bucket{method="GET",path="/",status="200",remote_ip="172.24.0.1",le="30"} 2.0
98
+ hanami_processing_duration_seconds_bucket{method="GET",path="/",status="200",remote_ip="172.24.0.1",le="60"} 2.0
99
+ hanami_processing_duration_seconds_bucket{method="GET",path="/",status="200",remote_ip="172.24.0.1",le="120"} 2.0
100
+ hanami_processing_duration_seconds_bucket{method="GET",path="/",status="200",remote_ip="172.24.0.1",le="300"} 2.0
101
+ hanami_processing_duration_seconds_bucket{method="GET",path="/",status="200",remote_ip="172.24.0.1",le="600"} 2.0
102
+ hanami_processing_duration_seconds_bucket{method="GET",path="/",status="200",remote_ip="172.24.0.1",le="+Inf"} 2.0
103
+ hanami_processing_duration_seconds_sum{method="GET",path="/",status="200",remote_ip="172.24.0.1"} 0.246
104
+ hanami_processing_duration_seconds_count{method="GET",path="/",status="200",remote_ip="172.24.0.1"} 2.0
105
+ # TYPE hanami_rack_errors_total counter
106
+ # HELP hanami_rack_errors_total A counter of the total number of rack errors.
107
+ ```
108
+
109
+
110
+ ## Development
111
+
112
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
113
+
114
+
115
+
116
+ To install this gem onto your local machine, run `bundle exec rake install`.
117
+
118
+ ## Docker Compose Development Environment (dcde)
119
+
120
+ After checking out the repo, run `docker-compose build` to build the **dcde** image. Once the image is built, run `docker-compose up -d` which will create the **dcde** container. Now run `docker-compose exec -- dcde bash` to get a bash shell inside the container.
121
+
122
+ From here on it is the same as above a.k.a. run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. etc...
123
+
124
+ **NOTE:** If you are using `docker-compose` on a non-linux machine you will need to run `bundle lock --add-platform x86_64-linux` otherwise the action workflows will fail when pushing your branch to GitHub.
125
+
126
+ ## Releasing
127
+
128
+ To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
129
+
130
+ 1. Bump version number in `lib/yabeda/hanami/version.rb`
131
+
132
+ In case of pre-releases keep in mind [rubygems/rubygems#3086](https://github.com/rubygems/rubygems/issues/3086) and check version with command like `Gem::Version.new(Yabeda::Hanami::VERSION).to_s`
133
+
134
+
135
+ 2. Fill `CHANGELOG.md` with missing changes, add header with version and date.
136
+
137
+
138
+ 3. Make a commit:
139
+ ```shell
140
+ git add lib/yabeda/hanami/version.rb CHANGELOG.md
141
+ version=$(ruby -r ./lib/yabeda/hanami/version.rb -e "puts Gem::Version.new(Yabeda::Hanami::VERSION)")
142
+ git commit --message="${version}: " --edit
143
+ ```
144
+
145
+ 4. Create annotated tag:
146
+ ```shell
147
+ git tag v${version} --annotate --message="${version}: " --edit --sign
148
+ ```
149
+
150
+
151
+ 5. Fill version name into subject line and (optionally) some description (list of changes will be taken from changelog and appended automatically)
152
+
153
+
154
+ 6. Push it:
155
+ ```shell
156
+ git push --follow-tags
157
+ ```
158
+
159
+ 7. You're done!
160
+
161
+ ## Contributing
162
+
163
+ Bug reports and pull requests are welcome on GitHub at https://github.com/mlibrary/yabeda-hanami. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/mlibrary/yabeda-hanami/blob/main/CODE_OF_CONDUCT.md).
164
+
165
+ ## Code of Conduct
166
+
167
+ Everyone interacting in the Yabeda::Hanami project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/mlibrary/yabeda-hanami/blob/main/CODE_OF_CONDUCT.md).
168
+
169
+ ## License
170
+
171
+ The gem is available as open source under the terms of the [Apache 2.0 License](https://opensource.org/license/apache-2-0).
172
+
173
+ ## Copyright Notice
174
+ Copyright 2026, Regents of the University of Michigan.
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RuboCop
4
+ module Cop
5
+ module Style
6
+ class MyFrozenStringLiteralComment < FrozenStringLiteralComment
7
+ minimum_target_ruby_version 2.3
8
+ end
9
+ end
10
+ end
11
+ end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Yabeda
4
4
  module Hanami
5
- VERSION = "0.1.0"
5
+ VERSION = "0.2.0"
6
6
  end
7
7
  end
data/lib/yabeda/hanami.rb CHANGED
@@ -22,11 +22,11 @@ module Yabeda
22
22
 
23
23
  group :hanami do
24
24
  counter :requests_total,
25
- comment: "A counter of the total number of HTTP requests hanami processed.",
26
- tags: %i[method path remote_ip]
25
+ comment: "A counter of the total number of HTTP requests Hanami has processed.",
26
+ tags: %i[method path remote_ip status]
27
27
 
28
28
  counter :responses_total,
29
- comment: "A counter of the total number of HTTP requests hanami processed.",
29
+ comment: "A counter of the total number of HTTP responses Hanami has processed.",
30
30
  tags: %i[method path remote_ip status]
31
31
 
32
32
  histogram :processing_duration,
@@ -36,7 +36,7 @@ module Yabeda
36
36
  tags: %i[method path remote_ip status]
37
37
 
38
38
  counter :rack_errors_total,
39
- comment: "A counter of the total number of rack errors.",
39
+ comment: "A counter of the total number of Rack errors.",
40
40
  tags: %i[method path remote_ip status]
41
41
  end
42
42
  end
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yabeda-hanami
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Greg Kostin
8
- autorequire:
9
- bindir: exe
8
+ bindir: bin
10
9
  cert_chain: []
11
- date: 2024-04-05 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: hanami
@@ -16,14 +15,14 @@ dependencies:
16
15
  requirements:
17
16
  - - "~>"
18
17
  - !ruby/object:Gem::Version
19
- version: '2.1'
18
+ version: '3.0'
20
19
  type: :runtime
21
20
  prerelease: false
22
21
  version_requirements: !ruby/object:Gem::Requirement
23
22
  requirements:
24
23
  - - "~>"
25
24
  - !ruby/object:Gem::Version
26
- version: '2.1'
25
+ version: '3.0'
27
26
  - !ruby/object:Gem::Dependency
28
27
  name: yabeda
29
28
  requirement: !ruby/object:Gem::Requirement
@@ -44,77 +43,98 @@ dependencies:
44
43
  requirements:
45
44
  - - "~>"
46
45
  - !ruby/object:Gem::Version
47
- version: '2.0'
46
+ version: '4.0'
48
47
  type: :development
49
48
  prerelease: false
50
49
  version_requirements: !ruby/object:Gem::Requirement
51
50
  requirements:
52
51
  - - "~>"
53
52
  - !ruby/object:Gem::Version
54
- version: '2.0'
53
+ version: '4.0'
55
54
  - !ruby/object:Gem::Dependency
56
55
  name: debug
57
56
  requirement: !ruby/object:Gem::Requirement
58
57
  requirements:
59
58
  - - "~>"
60
59
  - !ruby/object:Gem::Version
61
- version: '1.9'
60
+ version: '1.11'
62
61
  type: :development
63
62
  prerelease: false
64
63
  version_requirements: !ruby/object:Gem::Requirement
65
64
  requirements:
66
65
  - - "~>"
67
66
  - !ruby/object:Gem::Version
68
- version: '1.9'
67
+ version: '1.11'
69
68
  - !ruby/object:Gem::Dependency
70
69
  name: rake
71
70
  requirement: !ruby/object:Gem::Requirement
72
71
  requirements:
73
72
  - - "~>"
74
73
  - !ruby/object:Gem::Version
75
- version: '13.0'
74
+ version: '13.4'
76
75
  type: :development
77
76
  prerelease: false
78
77
  version_requirements: !ruby/object:Gem::Requirement
79
78
  requirements:
80
79
  - - "~>"
81
80
  - !ruby/object:Gem::Version
82
- version: '13.0'
81
+ version: '13.4'
82
+ - !ruby/object:Gem::Dependency
83
+ name: fiddle
84
+ requirement: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - "~>"
87
+ - !ruby/object:Gem::Version
88
+ version: '1.1'
89
+ type: :development
90
+ prerelease: false
91
+ version_requirements: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - "~>"
94
+ - !ruby/object:Gem::Version
95
+ version: '1.1'
83
96
  - !ruby/object:Gem::Dependency
84
97
  name: rspec
85
98
  requirement: !ruby/object:Gem::Requirement
86
99
  requirements:
87
100
  - - "~>"
88
101
  - !ruby/object:Gem::Version
89
- version: '3.0'
102
+ version: '3.13'
90
103
  type: :development
91
104
  prerelease: false
92
105
  version_requirements: !ruby/object:Gem::Requirement
93
106
  requirements:
94
107
  - - "~>"
95
108
  - !ruby/object:Gem::Version
96
- version: '3.0'
109
+ version: '3.13'
97
110
  - !ruby/object:Gem::Dependency
98
111
  name: standard
99
112
  requirement: !ruby/object:Gem::Requirement
100
113
  requirements:
101
114
  - - "~>"
102
115
  - !ruby/object:Gem::Version
103
- version: '1.3'
116
+ version: '1.56'
104
117
  type: :development
105
118
  prerelease: false
106
119
  version_requirements: !ruby/object:Gem::Requirement
107
120
  requirements:
108
121
  - - "~>"
109
122
  - !ruby/object:Gem::Version
110
- version: '1.3'
123
+ version: '1.56'
111
124
  description: Easy collecting your Hanami apps metrics
112
125
  email:
113
126
  - gkostin@umich.edu
114
127
  executables: []
115
128
  extensions: []
116
- extra_rdoc_files: []
129
+ extra_rdoc_files:
130
+ - CHANGELOG.md
131
+ - LICENSE.txt
132
+ - README.md
117
133
  files:
134
+ - CHANGELOG.md
135
+ - LICENSE.txt
136
+ - README.md
137
+ - lib/rubocop/cop/style/my_frozen_string_literal_comment.rb
118
138
  - lib/yabeda/hanami.rb
119
139
  - lib/yabeda/hanami/config.rb
120
140
  - lib/yabeda/hanami/event.rb
@@ -123,10 +143,9 @@ homepage: https://github.com/mlibrary/yabeda-hanami
123
143
  licenses:
124
144
  - Apache-2.0
125
145
  metadata:
126
- changelog_uri: https://github.com/mlibrary/yabeda-hanami/blob/main/CHANGELOG.md
127
146
  homepage_uri: https://github.com/mlibrary/yabeda-hanami
128
147
  source_code_uri: https://github.com/mlibrary/yabeda-hanami
129
- post_install_message:
148
+ changelog_uri: https://github.com/mlibrary/yabeda-hanami/blob/main/CHANGELOG.md
130
149
  rdoc_options: []
131
150
  require_paths:
132
151
  - lib
@@ -134,15 +153,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
134
153
  requirements:
135
154
  - - ">="
136
155
  - !ruby/object:Gem::Version
137
- version: 2.6.0
156
+ version: 3.3.0
138
157
  required_rubygems_version: !ruby/object:Gem::Requirement
139
158
  requirements:
140
159
  - - ">="
141
160
  - !ruby/object:Gem::Version
142
161
  version: '0'
143
162
  requirements: []
144
- rubygems_version: 3.3.7
145
- signing_key:
163
+ rubygems_version: 4.0.16
146
164
  specification_version: 4
147
165
  summary: Extensible metrics for monitoring a Hanami application
148
166
  test_files: []