hanami-events-cloud_pubsub 3.0.7 → 3.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -1
- data/README.md +3 -3
- data/hanami-events-cloud_pubsub.gemspec +1 -1
- data/lib/hanami/events/cloud_pubsub.rb +7 -6
- data/lib/hanami/events/cloud_pubsub/errors.rb +4 -0
- data/lib/hanami/events/cloud_pubsub/health_check_server.rb +3 -4
- data/lib/hanami/events/cloud_pubsub/middleware/prometheus.rb +14 -10
- data/lib/hanami/events/cloud_pubsub/version.rb +1 -1
- metadata +15 -16
- data/lib/hanami/events/cloud_pubsub/handler.rb +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1b625cc3f94218143ebafd31a854fdefb3e4b3ab5d54aa66385784f6560265c8
|
4
|
+
data.tar.gz: e7eb0b9995c66e2c4610b9eba4913a4ff94e8c89981302b4f736ccc9cdddf6aa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f3e44b4a055f90493bfafe9cbeb8243ddc2bba0c6eb693f5b29c664f2675546a5415387519fbe9075a110304aa3d8136b8da9b0ce0dddfa793a155fa39aeca98
|
7
|
+
data.tar.gz: e7107a4d84b881d2522b04002f07395783912d83a3653673650b2947a1e500cf47b4d8282adaaf0aabacbcfb3572a6780e828ff994ffcdffe160805dd30272ec
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -119,12 +119,12 @@ end
|
|
119
119
|
```
|
120
120
|
|
121
121
|
|
122
|
-
# Prometheus Integration
|
122
|
+
# Yabeda Prometheus Integration
|
123
123
|
|
124
|
-
If you have the `prometheus
|
124
|
+
If you have the `yabeda-prometheus` gem installed, a `/metrics` endpoint will
|
125
125
|
be available on the health check server which can be scraped.
|
126
126
|
|
127
|
-
All you need to do to activate this is to make sure to `require 'prometheus
|
127
|
+
All you need to do to activate this is to make sure to `require 'yabeda/prometheus'`.
|
128
128
|
|
129
129
|
# Testing
|
130
130
|
|
@@ -32,7 +32,7 @@ Gem::Specification.new do |spec|
|
|
32
32
|
spec.add_dependency 'rack'
|
33
33
|
|
34
34
|
spec.add_development_dependency 'bundler', '~> 2.1'
|
35
|
-
spec.add_development_dependency 'prometheus-client'
|
36
35
|
spec.add_development_dependency 'rake', '~> 13.0'
|
37
36
|
spec.add_development_dependency 'rspec', '~> 3.0'
|
37
|
+
spec.add_development_dependency 'yabeda-prometheus-mmap'
|
38
38
|
end
|
@@ -60,12 +60,13 @@ module Hanami
|
|
60
60
|
Middleware::Logging.new
|
61
61
|
)
|
62
62
|
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
63
|
+
if defined?(Yabeda::Prometheus::Exporter)
|
64
|
+
begin
|
65
|
+
require 'hanami/events/cloud_pubsub/middleware/prometheus'
|
66
|
+
middleware_stack.prepend(Middleware::Prometheus.new)
|
67
|
+
rescue LoadError
|
68
|
+
# ok
|
69
|
+
end
|
69
70
|
end
|
70
71
|
|
71
72
|
setting :middleware, middleware_stack
|
@@ -6,9 +6,13 @@ module Hanami
|
|
6
6
|
# Errors
|
7
7
|
module Errors
|
8
8
|
class Error < StandardError; end
|
9
|
+
|
9
10
|
class TopicNotFoundError < Error; end
|
11
|
+
|
10
12
|
class SubscriptionNotFoundError < Error; end
|
13
|
+
|
11
14
|
class SubscriptionTopicNameMismatch < Error; end
|
15
|
+
|
12
16
|
class NoSubscriberError < Error; end
|
13
17
|
end
|
14
18
|
end
|
@@ -54,10 +54,9 @@ module Hanami
|
|
54
54
|
|
55
55
|
Rack::Builder.new do |builder|
|
56
56
|
builder.use Rack::Deflater
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
end
|
57
|
+
require 'pry'
|
58
|
+
builder.use Yabeda::Prometheus::Exporter if defined?(Yabeda::Prometheus::Exporter)
|
59
|
+
|
61
60
|
builder.run health_endpoint_app
|
62
61
|
end
|
63
62
|
end
|
@@ -6,15 +6,11 @@ module Hanami
|
|
6
6
|
module Middleware
|
7
7
|
# Middleware used for logging useful information about an event
|
8
8
|
class Prometheus
|
9
|
-
|
10
|
-
|
11
|
-
def initialize
|
12
|
-
require 'prometheus/client'
|
13
|
-
prometheus = ::Prometheus::Client.registry
|
14
|
-
@events_counter = prometheus.counter(
|
9
|
+
Yabeda.configure do
|
10
|
+
counter(
|
15
11
|
:received_pubsub_events,
|
16
|
-
|
17
|
-
|
12
|
+
tags: %i[event_name subscription status],
|
13
|
+
comment: 'A counter of received pubsub events'
|
18
14
|
)
|
19
15
|
end
|
20
16
|
|
@@ -22,7 +18,7 @@ module Hanami
|
|
22
18
|
status = :running
|
23
19
|
|
24
20
|
begin
|
25
|
-
ret = yield(**opts)
|
21
|
+
ret = yield(**opts) if block_given?
|
26
22
|
status = :succeeded
|
27
23
|
ret
|
28
24
|
rescue StandardError
|
@@ -30,10 +26,18 @@ module Hanami
|
|
30
26
|
raise
|
31
27
|
end
|
32
28
|
ensure
|
29
|
+
record_metrics(msg, status)
|
30
|
+
end
|
31
|
+
|
32
|
+
private
|
33
|
+
|
34
|
+
def record_metrics(msg, status)
|
33
35
|
sub = msg.subscription.subscriber.subscription_name
|
34
36
|
event_name = msg.attributes['event_name']
|
35
37
|
labels = { event_name: event_name, subscription: sub, status: status }
|
36
|
-
|
38
|
+
Yabeda.received_pubsub_events.increment(labels, by: 1)
|
39
|
+
rescue StandardError
|
40
|
+
# ok
|
37
41
|
end
|
38
42
|
end
|
39
43
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hanami-events-cloud_pubsub
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0
|
4
|
+
version: 3.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ian Ker-Seymer
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-02-
|
11
|
+
date: 2021-02-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dry-configurable
|
@@ -115,47 +115,47 @@ dependencies:
|
|
115
115
|
- !ruby/object:Gem::Version
|
116
116
|
version: '2.1'
|
117
117
|
- !ruby/object:Gem::Dependency
|
118
|
-
name:
|
118
|
+
name: rake
|
119
119
|
requirement: !ruby/object:Gem::Requirement
|
120
120
|
requirements:
|
121
|
-
- - "
|
121
|
+
- - "~>"
|
122
122
|
- !ruby/object:Gem::Version
|
123
|
-
version: '0'
|
123
|
+
version: '13.0'
|
124
124
|
type: :development
|
125
125
|
prerelease: false
|
126
126
|
version_requirements: !ruby/object:Gem::Requirement
|
127
127
|
requirements:
|
128
|
-
- - "
|
128
|
+
- - "~>"
|
129
129
|
- !ruby/object:Gem::Version
|
130
|
-
version: '0'
|
130
|
+
version: '13.0'
|
131
131
|
- !ruby/object:Gem::Dependency
|
132
|
-
name:
|
132
|
+
name: rspec
|
133
133
|
requirement: !ruby/object:Gem::Requirement
|
134
134
|
requirements:
|
135
135
|
- - "~>"
|
136
136
|
- !ruby/object:Gem::Version
|
137
|
-
version: '
|
137
|
+
version: '3.0'
|
138
138
|
type: :development
|
139
139
|
prerelease: false
|
140
140
|
version_requirements: !ruby/object:Gem::Requirement
|
141
141
|
requirements:
|
142
142
|
- - "~>"
|
143
143
|
- !ruby/object:Gem::Version
|
144
|
-
version: '
|
144
|
+
version: '3.0'
|
145
145
|
- !ruby/object:Gem::Dependency
|
146
|
-
name:
|
146
|
+
name: yabeda-prometheus-mmap
|
147
147
|
requirement: !ruby/object:Gem::Requirement
|
148
148
|
requirements:
|
149
|
-
- - "
|
149
|
+
- - ">="
|
150
150
|
- !ruby/object:Gem::Version
|
151
|
-
version: '
|
151
|
+
version: '0'
|
152
152
|
type: :development
|
153
153
|
prerelease: false
|
154
154
|
version_requirements: !ruby/object:Gem::Requirement
|
155
155
|
requirements:
|
156
|
-
- - "
|
156
|
+
- - ">="
|
157
157
|
- !ruby/object:Gem::Version
|
158
|
-
version: '
|
158
|
+
version: '0'
|
159
159
|
description: Makes it easy to use Cloud Pub/Sub with Hanami
|
160
160
|
email:
|
161
161
|
- i.kerseymer@gmail.com
|
@@ -187,7 +187,6 @@ files:
|
|
187
187
|
- lib/hanami/events/cloud_pubsub.rb
|
188
188
|
- lib/hanami/events/cloud_pubsub/cli.rb
|
189
189
|
- lib/hanami/events/cloud_pubsub/errors.rb
|
190
|
-
- lib/hanami/events/cloud_pubsub/handler.rb
|
191
190
|
- lib/hanami/events/cloud_pubsub/health_check_server.rb
|
192
191
|
- lib/hanami/events/cloud_pubsub/integration.rb
|
193
192
|
- lib/hanami/events/cloud_pubsub/listener.rb
|
File without changes
|