hermes-rb 0.6.0 → 0.7.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +43 -0
- data/.gitignore +1 -0
- data/.ruby-version +1 -0
- data/Appraisals +12 -0
- data/Changelog.md +9 -0
- data/Gemfile.lock +35 -29
- data/README.md +6 -6
- data/gemfiles/rails.5.2.gemfile +9 -0
- data/gemfiles/rails.6.1.gemfile +9 -0
- data/gemfiles/rails.7.0.gemfile +9 -0
- data/hermes-rb.gemspec +1 -0
- data/lib/hermes/distributed_trace_repository.rb +3 -3
- data/lib/hermes/logger/params_filter.rb +1 -1
- data/lib/hermes/rb/version.rb +1 -1
- data/lib/hermes/tracers/datadog.rb +7 -1
- metadata +23 -4
- data/.travis.yml +0 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8f84d7c23f44dbdf7aabfa38122dd94c231c907b04d4aabe6ec444feef5ba7b2
|
4
|
+
data.tar.gz: 2eaf59a2dbca4952a7eaaa7fe053bcee8c9e783235fead16034b45ceb4850668
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 31728fa8f53e90d0317e964c92f3b3a8bc1e879821b12f46ec0441b5027f60c6983a4afe8d473a51954894ed8221941c7d8ceed78f45650aa9a791fa70964af7
|
7
|
+
data.tar.gz: 5950b3d5121580f9948c818ecdbf3d66f102ea118e74382f8e4d1943deb8fe226d492df55b9535c938ac1b1a7f06f74c73e848a0e03c27d5b0db1d4b9f4514e9
|
@@ -0,0 +1,43 @@
|
|
1
|
+
name: CI
|
2
|
+
on: [pull_request]
|
3
|
+
jobs:
|
4
|
+
rspec:
|
5
|
+
strategy:
|
6
|
+
fail-fast: false
|
7
|
+
matrix:
|
8
|
+
include:
|
9
|
+
- { ruby: '2.7', rails: '5.2' }
|
10
|
+
- { ruby: '3.0', rails: '6.1' }
|
11
|
+
- { ruby: '3.1', rails: '7.0' }
|
12
|
+
runs-on: ubuntu-latest
|
13
|
+
env:
|
14
|
+
BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/rails.${{ matrix.rails }}.gemfile
|
15
|
+
DATABASE_URL: "postgresql://postgres:postgres@127.0.0.1:5432/hermes-rb-test"
|
16
|
+
DISTRIBUTED_TRACING_DATABASE_URI: "postgresql://postgres:postgres@127.0.0.1:5432/hermes-rb-test"
|
17
|
+
HUTCH_URI: "amqp://guest:guest@127.0.0.1:5672"
|
18
|
+
HUTCH_ENABLE_HTTP_API_USE: false
|
19
|
+
services:
|
20
|
+
postgres:
|
21
|
+
image: postgres:14
|
22
|
+
env:
|
23
|
+
POSTGRES_USER: postgres
|
24
|
+
POSTGRES_PASSWORD: postgres
|
25
|
+
POSTGRES_DB: hermes-rb-test
|
26
|
+
ports:
|
27
|
+
- 5432:5432
|
28
|
+
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
|
29
|
+
rabbitmq:
|
30
|
+
image: rabbitmq
|
31
|
+
env:
|
32
|
+
RABBITMQ_DEFAULT_USER: guest
|
33
|
+
RABBITMQ_DEFAULT_PASS: guest
|
34
|
+
ports:
|
35
|
+
- 5672:5672
|
36
|
+
options: --health-cmd "rabbitmqctl node_health_check" --health-interval 10s --health-timeout 5s --health-retries 5
|
37
|
+
steps:
|
38
|
+
- uses: actions/checkout@v2
|
39
|
+
- uses: ruby/setup-ruby@v1
|
40
|
+
with:
|
41
|
+
ruby-version: ${{ matrix.ruby }}
|
42
|
+
bundler-cache: true
|
43
|
+
- run: bundle exec rspec
|
data/.gitignore
CHANGED
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.7
|
data/Appraisals
ADDED
data/Changelog.md
CHANGED
@@ -2,6 +2,15 @@
|
|
2
2
|
|
3
3
|
## Master
|
4
4
|
|
5
|
+
## 0.7.1
|
6
|
+
- Fix Hermes::DistributedTraceRepository so that it properly applies mapper that modifies event body
|
7
|
+
|
8
|
+
## 0.7.0
|
9
|
+
- Add support for DDTrace v1
|
10
|
+
|
11
|
+
## 0.6.1
|
12
|
+
- Extend the list of sensitive keywords for Hermes::Logger::ParamsFilter
|
13
|
+
|
5
14
|
## 0.6.0
|
6
15
|
- Add Health check
|
7
16
|
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
hermes-rb (0.
|
4
|
+
hermes-rb (0.7.1)
|
5
5
|
activerecord (>= 5)
|
6
6
|
activesupport (>= 5)
|
7
7
|
dry-container (~> 0)
|
@@ -12,36 +12,36 @@ PATH
|
|
12
12
|
GEM
|
13
13
|
remote: https://rubygems.org/
|
14
14
|
specs:
|
15
|
-
activemodel (
|
16
|
-
activesupport (=
|
17
|
-
activerecord (
|
18
|
-
activemodel (=
|
19
|
-
activesupport (=
|
20
|
-
activesupport (
|
15
|
+
activemodel (7.0.3.1)
|
16
|
+
activesupport (= 7.0.3.1)
|
17
|
+
activerecord (7.0.3.1)
|
18
|
+
activemodel (= 7.0.3.1)
|
19
|
+
activesupport (= 7.0.3.1)
|
20
|
+
activesupport (7.0.3.1)
|
21
21
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
22
22
|
i18n (>= 1.6, < 2)
|
23
23
|
minitest (>= 5.1)
|
24
24
|
tzinfo (~> 2.0)
|
25
|
-
zeitwerk (~> 2.3)
|
26
25
|
amq-protocol (2.3.2)
|
27
|
-
|
26
|
+
appraisal (2.4.1)
|
27
|
+
bundler
|
28
|
+
rake
|
29
|
+
thor (>= 0.14.0)
|
30
|
+
bunny (2.19.0)
|
28
31
|
amq-protocol (~> 2.3, >= 2.3.1)
|
32
|
+
sorted_set (~> 1, >= 1.0.2)
|
29
33
|
carrot-top (0.0.7)
|
30
34
|
json
|
31
|
-
concurrent-ruby (1.1.
|
35
|
+
concurrent-ruby (1.1.10)
|
32
36
|
ddtrace (0.45.0)
|
33
37
|
msgpack
|
34
38
|
diff-lcs (1.4.4)
|
35
|
-
dry-
|
39
|
+
dry-container (0.10.0)
|
36
40
|
concurrent-ruby (~> 1.0)
|
37
|
-
|
38
|
-
dry-container (0.7.2)
|
41
|
+
dry-core (0.8.0)
|
39
42
|
concurrent-ruby (~> 1.0)
|
40
|
-
|
41
|
-
dry-
|
42
|
-
concurrent-ruby (~> 1.0)
|
43
|
-
dry-inflector (0.2.0)
|
44
|
-
dry-logic (1.1.0)
|
43
|
+
dry-inflector (0.3.0)
|
44
|
+
dry-logic (1.2.0)
|
45
45
|
concurrent-ruby (~> 1.0)
|
46
46
|
dry-core (~> 0.5, >= 0.5)
|
47
47
|
dry-struct (1.4.0)
|
@@ -54,23 +54,24 @@ GEM
|
|
54
54
|
dry-core (~> 0.5, >= 0.5)
|
55
55
|
dry-inflector (~> 0.1, >= 0.1.2)
|
56
56
|
dry-logic (~> 1.0, >= 1.0.2)
|
57
|
-
hutch (1.
|
58
|
-
activesupport (>= 4.2, <
|
59
|
-
bunny (>= 2.
|
57
|
+
hutch (1.1.1)
|
58
|
+
activesupport (>= 4.2, < 8)
|
59
|
+
bunny (>= 2.19, < 3.0)
|
60
60
|
carrot-top (~> 0.0.7)
|
61
|
-
multi_json (~> 1.
|
62
|
-
i18n (1.
|
61
|
+
multi_json (~> 1.15)
|
62
|
+
i18n (1.12.0)
|
63
63
|
concurrent-ruby (~> 1.0)
|
64
64
|
ice_nine (0.11.2)
|
65
|
-
json (2.
|
66
|
-
minitest (5.
|
65
|
+
json (2.6.2)
|
66
|
+
minitest (5.16.2)
|
67
67
|
msgpack (1.4.2)
|
68
68
|
multi_json (1.15.0)
|
69
69
|
newrelic_rpm (6.15.0)
|
70
70
|
pg (1.2.3)
|
71
|
-
rack (2.2.
|
71
|
+
rack (2.2.4)
|
72
72
|
rake (13.0.1)
|
73
|
-
|
73
|
+
rbtree (0.4.5)
|
74
|
+
request_store (1.5.1)
|
74
75
|
rack (>= 1.4)
|
75
76
|
rspec (3.10.0)
|
76
77
|
rspec-core (~> 3.10.0)
|
@@ -85,16 +86,21 @@ GEM
|
|
85
86
|
diff-lcs (>= 1.2.0, < 2.0)
|
86
87
|
rspec-support (~> 3.10.0)
|
87
88
|
rspec-support (3.10.0)
|
89
|
+
set (1.0.2)
|
90
|
+
sorted_set (1.0.3)
|
91
|
+
rbtree
|
92
|
+
set (~> 1.0)
|
93
|
+
thor (1.2.1)
|
88
94
|
timecop (0.9.2)
|
89
95
|
tzinfo (2.0.4)
|
90
96
|
concurrent-ruby (~> 1.0)
|
91
97
|
vcr (5.0.0)
|
92
|
-
zeitwerk (2.4.2)
|
93
98
|
|
94
99
|
PLATFORMS
|
95
100
|
ruby
|
96
101
|
|
97
102
|
DEPENDENCIES
|
103
|
+
appraisal
|
98
104
|
bundler
|
99
105
|
ddtrace
|
100
106
|
hermes-rb!
|
@@ -106,4 +112,4 @@ DEPENDENCIES
|
|
106
112
|
vcr
|
107
113
|
|
108
114
|
BUNDLED WITH
|
109
|
-
2.
|
115
|
+
2.2.22
|
data/README.md
CHANGED
@@ -37,8 +37,8 @@ Rails.application.config.to_prepare do
|
|
37
37
|
config.configure_hutch do |hutch|
|
38
38
|
hutch.uri = ENV.fetch("HUTCH_URI")
|
39
39
|
hutch.force_publisher_confirms = true
|
40
|
-
hutch.enable_http_api_use = false
|
41
|
-
hutch.tracer = MyOwnCustomTracerIfIWantToDoSomethingCrazy
|
40
|
+
hutch.enable_http_api_use = false
|
41
|
+
hutch.tracer = MyOwnCustomTracerIfIWantToDoSomethingCrazy
|
42
42
|
end
|
43
43
|
config.distributed_tracing_database_uri = ENV.fetch("DISTRIBUTED_TRACING_DATABASE_URI", nil)
|
44
44
|
config.error_notification_service = Raven
|
@@ -47,7 +47,7 @@ Rails.application.config.to_prepare do
|
|
47
47
|
event_handler.handle_events do
|
48
48
|
handle Events::Example::Happened, with: Example::HappenedHandler
|
49
49
|
handle Events::Example::SyncCallHappened, with: Example::SyncCallHappenedHandler, async: false
|
50
|
-
|
50
|
+
|
51
51
|
extra_consumer_config = -> do
|
52
52
|
classic_queue
|
53
53
|
quorum_queue initial_group_size: 3
|
@@ -148,7 +148,7 @@ If you don't care about it, you can leave it empty.
|
|
148
148
|
|
149
149
|
12. `distributed_tracing_database_table` - Table name for storing traces, by default it's `hermes_distributed_traces`. Optional.
|
150
150
|
|
151
|
-
13. `distributes_tracing_mapper` - an object responding to `call` method taking one argument (a hash of attributes) which must return a hash as well. This hash will be used for assigning attributes when creating `Hermes::DistributedTrace`. It defaults to `Hermes::DistributedTrace::Mapper`, which uses `logger_params_filter` to remove sensitive info (this config option is covered below). You can either provide a custom mapper or pass a custom params filter, for example: `Hermes::DistributedTrace::Mapper.new(params_filter: custom_params_filter)`
|
151
|
+
13. `distributes_tracing_mapper` - an object responding to `call` method taking one argument (a hash of attributes) which must return a hash as well. This hash will be used for assigning attributes when creating `Hermes::DistributedTrace`. It defaults to `Hermes::DistributedTrace::Mapper`, which uses `logger_params_filter` to remove sensitive info (this config option is covered below). You can either provide a custom mapper or pass a custom params filter, for example: `Hermes::DistributedTrace::Mapper.new(params_filter: custom_params_filter)`
|
152
152
|
|
153
153
|
14. `error_notification_service` - an object responding to `capture_exception` method taking one argument (error). Its interface is based on `Raven` from [Sentry Raven](https://github.com/getsentry/sentry-ruby/tree/master/sentry-raven). By default `Hermes::NullErrorNotificationService` is used, which does nothing. Optional.
|
154
154
|
|
@@ -160,7 +160,7 @@ If you don't care about it, you can leave it empty.
|
|
160
160
|
|
161
161
|
18. `logger_params_filter` - a service used as params filter for logger, to make sure no sensitive data will be logged. It defaults to `Hermes::Logger::ParamsFilter` which already performs some filtering but it might not be enough in your case. If you are not satisfied with the defaults, you have 2 options, which are especially simple in Rails apps:
|
162
162
|
- provide custom array of sensitive attributes and still use a default filter: `Hermes::Logger::ParamsFilter.new(sensitive_keywords: Rails.application.config.filter_parameters)`.
|
163
|
-
- provide custom filter object, which responds to `call` method and takes 2 arguments: attribute name and its value and performs mutation by using `gsub!` (don't worry, the entire body is cloned before passing it to the filter, so nothing unexpected will happen). This is compatible with the interface of `Rails.application.config.filter_parameters` when you use a custom filter there. In such case, you can do something like this: `Rails.application.config.filter_parameters = [Proc.new { |k, v| do_something_custom_here(k, v) }]` and then just assign `Rails.application.config.filter_parameters.first` in the Hermes config.
|
163
|
+
- provide custom filter object, which responds to `call` method and takes 2 arguments: attribute name and its value and performs mutation by using `gsub!` (don't worry, the entire body is cloned before passing it to the filter, so nothing unexpected will happen). This is compatible with the interface of `Rails.application.config.filter_parameters` when you use a custom filter there. In such case, you can do something like this: `Rails.application.config.filter_parameters = [Proc.new { |k, v| do_something_custom_here(k, v) }]` and then just assign `Rails.application.config.filter_parameters.first` in the Hermes config.
|
164
164
|
## RPC
|
165
165
|
|
166
166
|
If you want to handle RPC call, you need to add `rpc: true` flag. Keep in mind that RPC requires a synchronous processing and response, so you also need to set `async: false`. The routing key and correlation ID will be resolved based on the message that is published by the client. The payload that is sent back will be what event handler reutrns, so it might be a good idea to just return a hash so that you can operate on JSON easily.
|
@@ -483,7 +483,7 @@ curl -v localhost:3000/health_check/hermes.json
|
|
483
483
|
2. Via binary:
|
484
484
|
|
485
485
|
```
|
486
|
-
|
486
|
+
bundle exec hermes_health_check
|
487
487
|
```
|
488
488
|
|
489
489
|
## CircleCI config for installing RabbitMQ
|
data/hermes-rb.gemspec
CHANGED
@@ -20,16 +20,16 @@ module Hermes
|
|
20
20
|
private
|
21
21
|
|
22
22
|
def attributes_for_trace_context(event, trace_context)
|
23
|
-
|
23
|
+
{
|
24
24
|
trace: trace_context.trace,
|
25
25
|
span: trace_context.span,
|
26
26
|
parent_span: trace_context.parent_span,
|
27
27
|
service: trace_context.service,
|
28
28
|
event_class: event.class.to_s,
|
29
29
|
routing_key: event.routing_key,
|
30
|
-
event_body: event.as_json,
|
30
|
+
event_body: distributes_tracing_mapper.call(event.as_json),
|
31
31
|
event_headers: event.to_headers
|
32
|
-
|
32
|
+
}
|
33
33
|
end
|
34
34
|
|
35
35
|
def store_trace(attributes)
|
@@ -2,7 +2,7 @@ module Hermes
|
|
2
2
|
class Logger
|
3
3
|
class ParamsFilter
|
4
4
|
SENSITIVE_ATTRIBUTES_KEYWORDS = %w(token password credit_card card_number security_code verification_value
|
5
|
-
private_key signature api_key secret_key publishable_key).freeze
|
5
|
+
private_key signature api_key secret_key publishable_key client_key client_secret secret).freeze
|
6
6
|
STRIPPED_VALUE = "[STRIPPED]".freeze
|
7
7
|
|
8
8
|
private_constant :SENSITIVE_ATTRIBUTES_KEYWORDS, :STRIPPED_VALUE
|
data/lib/hermes/rb/version.rb
CHANGED
@@ -11,7 +11,13 @@ module Hermes
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def handle(message)
|
14
|
-
::Datadog.
|
14
|
+
tracer = ::Datadog.respond_to?(:tracer) ? ::Datadog.tracer : "Datadog::Tracing".safe_constantize
|
15
|
+
|
16
|
+
tracer.trace(
|
17
|
+
klass.class.name || klass.class.to_s,
|
18
|
+
service: "hermes",
|
19
|
+
span_type: "rabbitmq"
|
20
|
+
) do
|
15
21
|
klass.process(message)
|
16
22
|
end
|
17
23
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hermes-rb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Karol Galanciak
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-07-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dry-struct
|
@@ -206,6 +206,20 @@ dependencies:
|
|
206
206
|
- - ">="
|
207
207
|
- !ruby/object:Gem::Version
|
208
208
|
version: '0'
|
209
|
+
- !ruby/object:Gem::Dependency
|
210
|
+
name: appraisal
|
211
|
+
requirement: !ruby/object:Gem::Requirement
|
212
|
+
requirements:
|
213
|
+
- - ">="
|
214
|
+
- !ruby/object:Gem::Version
|
215
|
+
version: '0'
|
216
|
+
type: :development
|
217
|
+
prerelease: false
|
218
|
+
version_requirements: !ruby/object:Gem::Requirement
|
219
|
+
requirements:
|
220
|
+
- - ">="
|
221
|
+
- !ruby/object:Gem::Version
|
222
|
+
version: '0'
|
209
223
|
description: A messenger of gods, delivering them via RabbitMQ with a little help
|
210
224
|
from Hutch
|
211
225
|
email:
|
@@ -215,9 +229,11 @@ executables:
|
|
215
229
|
extensions: []
|
216
230
|
extra_rdoc_files: []
|
217
231
|
files:
|
232
|
+
- ".github/workflows/ci.yml"
|
218
233
|
- ".gitignore"
|
219
234
|
- ".rspec"
|
220
|
-
- ".
|
235
|
+
- ".ruby-version"
|
236
|
+
- Appraisals
|
221
237
|
- Changelog.md
|
222
238
|
- Gemfile
|
223
239
|
- Gemfile.lock
|
@@ -227,6 +243,9 @@ files:
|
|
227
243
|
- bin/console
|
228
244
|
- bin/hermes_health_check
|
229
245
|
- bin/setup
|
246
|
+
- gemfiles/rails.5.2.gemfile
|
247
|
+
- gemfiles/rails.6.1.gemfile
|
248
|
+
- gemfiles/rails.7.0.gemfile
|
230
249
|
- hermes-rb.gemspec
|
231
250
|
- lib/hermes-rb.rb
|
232
251
|
- lib/hermes.rb
|
@@ -288,7 +307,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
288
307
|
- !ruby/object:Gem::Version
|
289
308
|
version: '0'
|
290
309
|
requirements: []
|
291
|
-
rubygems_version: 3.1.
|
310
|
+
rubygems_version: 3.1.4
|
292
311
|
signing_key:
|
293
312
|
specification_version: 4
|
294
313
|
summary: A messenger of gods, delivering them via RabbitMQ with a little help from
|
data/.travis.yml
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
---
|
2
|
-
language: ruby
|
3
|
-
cache: bundler
|
4
|
-
rvm:
|
5
|
-
- 2.7.2
|
6
|
-
env:
|
7
|
-
- HUTCH_URI="amqp://guest:guest@localhost:5672"
|
8
|
-
- HUTCH_ENABLE_HTTP_API_USE=false
|
9
|
-
dist: xenial
|
10
|
-
addons:
|
11
|
-
apt:
|
12
|
-
packages:
|
13
|
-
- rabbitmq-server
|
14
|
-
services:
|
15
|
-
- rabbitmq
|
16
|
-
- postgresql
|
17
|
-
before_install: gem install bundler -v 2.1.4
|