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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c9761e02377d807f35d3c4e005d4948237bf89204ba7d7dc619d46e91d7bca38
4
- data.tar.gz: fade5b3c8657111ab4e485ad5b03bb584b69d4557cd2416d5e0c358bcf5dc3f4
3
+ metadata.gz: 1b625cc3f94218143ebafd31a854fdefb3e4b3ab5d54aa66385784f6560265c8
4
+ data.tar.gz: e7eb0b9995c66e2c4610b9eba4913a4ff94e8c89981302b4f736ccc9cdddf6aa
5
5
  SHA512:
6
- metadata.gz: c89ad6a21c559f77c671b10cd7da95bbd7fbf09a5b0489615e46338677cac4cab129faa2b8e8d69faf6f762cda00d9b0bbf261dd82998634ebc7702e55c4ddb3
7
- data.tar.gz: 0c785630df1938f248a4c5fc2f5ad5470ea8f75e872dada244dcc0229bedebbf8214ee98cbe28c5b745ba8037ce8d40ea48bafea028dc2e30329e01e6f7d623c
6
+ metadata.gz: f3e44b4a055f90493bfafe9cbeb8243ddc2bba0c6eb693f5b29c664f2675546a5415387519fbe9075a110304aa3d8136b8da9b0ce0dddfa793a155fa39aeca98
7
+ data.tar.gz: e7107a4d84b881d2522b04002f07395783912d83a3653673650b2947a1e500cf47b4d8282adaaf0aabacbcfb3572a6780e828ff994ffcdffe160805dd30272ec
data/Gemfile CHANGED
@@ -11,7 +11,7 @@ RUBY_MAJOR = RUBY_VERSION[0].to_i
11
11
 
12
12
  gem 'hanami-events', github: 'hanami/events'
13
13
  gem 'pry'
14
+ gem 'request_id', '~> 0.4.3'
14
15
  gem 'rubocop'
15
16
  gem 'simplecov', require: false
16
- gem 'request_id', '~> 0.4.3'
17
17
  gem 'webrick' if RUBY_MAJOR > 2
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-client` gem installed, a `/metrics` endpoint will
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/client'`.
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
- begin
64
- require 'prometheus/client'
65
- require 'hanami/events/cloud_pubsub/middleware/prometheus'
66
- middleware_stack.prepend(Middleware::Prometheus.new)
67
- rescue LoadError
68
- # ok
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
- if defined?(::Prometheus::Client)
58
- require 'prometheus/middleware/exporter'
59
- builder.use ::Prometheus::Middleware::Exporter
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
- attr_reader :events_counter
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
- docstring: 'A counter of received pubsub events',
17
- labels: %i[event_name subscription status]
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
- events_counter.increment(labels: labels)
38
+ Yabeda.received_pubsub_events.increment(labels, by: 1)
39
+ rescue StandardError
40
+ # ok
37
41
  end
38
42
  end
39
43
  end
@@ -3,7 +3,7 @@
3
3
  module Hanami
4
4
  module Events
5
5
  module CloudPubsub
6
- VERSION = '3.0.7'
6
+ VERSION = '3.1.0'
7
7
  end
8
8
  end
9
9
  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.7
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-05 00:00:00.000000000 Z
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: prometheus-client
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: rake
132
+ name: rspec
133
133
  requirement: !ruby/object:Gem::Requirement
134
134
  requirements:
135
135
  - - "~>"
136
136
  - !ruby/object:Gem::Version
137
- version: '13.0'
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: '13.0'
144
+ version: '3.0'
145
145
  - !ruby/object:Gem::Dependency
146
- name: rspec
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: '3.0'
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: '3.0'
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