hermes-rb 0.3.0 → 0.6.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Changelog.md +16 -0
- data/Gemfile.lock +19 -15
- data/README.md +45 -7
- data/bin/hermes_health_check +12 -0
- data/hermes-rb.gemspec +3 -2
- data/lib/hermes.rb +2 -0
- data/lib/hermes/checks.rb +5 -0
- data/lib/hermes/checks/health_check.rb +14 -0
- data/lib/hermes/configuration.rb +10 -3
- data/lib/hermes/consumer_builder.rb +2 -1
- data/lib/hermes/dependencies_container.rb +4 -0
- data/lib/hermes/event_handler.rb +16 -10
- data/lib/hermes/logger.rb +4 -0
- data/lib/hermes/logger/params_filter.rb +2 -2
- data/lib/hermes/rb/version.rb +1 -1
- data/lib/hermes/tracers.rb +5 -0
- data/lib/hermes/tracers/datadog.rb +20 -0
- metadata +24 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8d9a8e1af4d989ab98014db38015a8a00f24c2c7a4ab0d7724c849e092812855
|
4
|
+
data.tar.gz: 7038b16132b50567e00ebd2398054907f8e17dccc6e15652a7367f1dbd76299e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 432bfa0092f9dbeaad563aadea388c542a8daf06c4708dca3df620806b8c678350c88b27838d2c6fd06eda9ce84398c5eb3d770efca21eff63a528161e46a3d9
|
7
|
+
data.tar.gz: ba182e98338361a3024829c2e7872bf935d28769a3c69f373ecbd4a3f6676040f6a2ecd3b2753f7683e0e799484dbbd178d695679a36fb0440a25575015f12f3
|
data/Changelog.md
CHANGED
@@ -2,6 +2,22 @@
|
|
2
2
|
|
3
3
|
## Master
|
4
4
|
|
5
|
+
## 0.6.1
|
6
|
+
- Extend the list of sensitive keywords for Hermes::Logger::ParamsFilter
|
7
|
+
|
8
|
+
## 0.6.0
|
9
|
+
- Add Health check
|
10
|
+
|
11
|
+
## 0.5.0
|
12
|
+
- Add Datadog tracer
|
13
|
+
- Allow to provide a custom tracer
|
14
|
+
|
15
|
+
## 0.4.0
|
16
|
+
- Make it possible to provide Hutch consumer config
|
17
|
+
|
18
|
+
## 0.3.1
|
19
|
+
- Fix filtering params for logs for nil values in sensitive attributes
|
20
|
+
|
5
21
|
## 0.3.0
|
6
22
|
- Reorganize Hutch config - instead of setting config values when connecting to Hutch when using publisher, do it right after the initialization.
|
7
23
|
- Make params filter customizable for the logger
|
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.6.1)
|
5
5
|
activerecord (>= 5)
|
6
6
|
activesupport (>= 5)
|
7
7
|
dry-container (~> 0)
|
@@ -12,12 +12,12 @@ PATH
|
|
12
12
|
GEM
|
13
13
|
remote: https://rubygems.org/
|
14
14
|
specs:
|
15
|
-
activemodel (6.1.2
|
16
|
-
activesupport (= 6.1.2
|
17
|
-
activerecord (6.1.2
|
18
|
-
activemodel (= 6.1.2
|
19
|
-
activesupport (= 6.1.2
|
20
|
-
activesupport (6.1.2
|
15
|
+
activemodel (6.1.3.2)
|
16
|
+
activesupport (= 6.1.3.2)
|
17
|
+
activerecord (6.1.3.2)
|
18
|
+
activemodel (= 6.1.3.2)
|
19
|
+
activesupport (= 6.1.3.2)
|
20
|
+
activesupport (6.1.3.2)
|
21
21
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
22
22
|
i18n (>= 1.6, < 2)
|
23
23
|
minitest (>= 5.1)
|
@@ -28,25 +28,27 @@ GEM
|
|
28
28
|
amq-protocol (~> 2.3, >= 2.3.1)
|
29
29
|
carrot-top (0.0.7)
|
30
30
|
json
|
31
|
-
concurrent-ruby (1.1.
|
31
|
+
concurrent-ruby (1.1.9)
|
32
|
+
ddtrace (0.45.0)
|
33
|
+
msgpack
|
32
34
|
diff-lcs (1.4.4)
|
33
|
-
dry-configurable (0.12.
|
35
|
+
dry-configurable (0.12.1)
|
34
36
|
concurrent-ruby (~> 1.0)
|
35
37
|
dry-core (~> 0.5, >= 0.5.0)
|
36
|
-
dry-container (0.
|
38
|
+
dry-container (0.8.0)
|
37
39
|
concurrent-ruby (~> 1.0)
|
38
40
|
dry-configurable (~> 0.1, >= 0.1.3)
|
39
|
-
dry-core (0.
|
41
|
+
dry-core (0.6.0)
|
40
42
|
concurrent-ruby (~> 1.0)
|
41
43
|
dry-inflector (0.2.0)
|
42
|
-
dry-logic (1.
|
44
|
+
dry-logic (1.2.0)
|
43
45
|
concurrent-ruby (~> 1.0)
|
44
46
|
dry-core (~> 0.5, >= 0.5)
|
45
47
|
dry-struct (1.4.0)
|
46
48
|
dry-core (~> 0.5, >= 0.5)
|
47
49
|
dry-types (~> 1.5)
|
48
50
|
ice_nine (~> 0.11)
|
49
|
-
dry-types (1.5.
|
51
|
+
dry-types (1.5.1)
|
50
52
|
concurrent-ruby (~> 1.0)
|
51
53
|
dry-container (~> 0.3)
|
52
54
|
dry-core (~> 0.5, >= 0.5)
|
@@ -57,11 +59,12 @@ GEM
|
|
57
59
|
bunny (>= 2.15, < 2.16)
|
58
60
|
carrot-top (~> 0.0.7)
|
59
61
|
multi_json (~> 1.14)
|
60
|
-
i18n (1.8.
|
62
|
+
i18n (1.8.10)
|
61
63
|
concurrent-ruby (~> 1.0)
|
62
64
|
ice_nine (0.11.2)
|
63
65
|
json (2.5.1)
|
64
|
-
minitest (5.14.
|
66
|
+
minitest (5.14.4)
|
67
|
+
msgpack (1.4.2)
|
65
68
|
multi_json (1.15.0)
|
66
69
|
newrelic_rpm (6.15.0)
|
67
70
|
pg (1.2.3)
|
@@ -93,6 +96,7 @@ PLATFORMS
|
|
93
96
|
|
94
97
|
DEPENDENCIES
|
95
98
|
bundler
|
99
|
+
ddtrace
|
96
100
|
hermes-rb!
|
97
101
|
newrelic_rpm
|
98
102
|
pg
|
data/README.md
CHANGED
@@ -37,7 +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
|
40
|
+
hutch.enable_http_api_use = false
|
41
|
+
hutch.tracer = MyOwnCustomTracerIfIWantToDoSomethingCrazy
|
41
42
|
end
|
42
43
|
config.distributed_tracing_database_uri = ENV.fetch("DISTRIBUTED_TRACING_DATABASE_URI", nil)
|
43
44
|
config.error_notification_service = Raven
|
@@ -45,8 +46,15 @@ Rails.application.config.to_prepare do
|
|
45
46
|
|
46
47
|
event_handler.handle_events do
|
47
48
|
handle Events::Example::Happened, with: Example::HappenedHandler
|
48
|
-
|
49
49
|
handle Events::Example::SyncCallHappened, with: Example::SyncCallHappenedHandler, async: false
|
50
|
+
|
51
|
+
extra_consumer_config = -> do
|
52
|
+
classic_queue
|
53
|
+
quorum_queue initial_group_size: 3
|
54
|
+
arguments "x-max-length" => 10
|
55
|
+
end
|
56
|
+
handle Events::Example::SomethingHappenedWithExtraConsumerConfig, with: Example::SomethingHappenedWithExtraConsumerConfigHandler,
|
57
|
+
consumer_config: extra_consumer_config
|
50
58
|
end
|
51
59
|
|
52
60
|
# if you care about distributed tracing
|
@@ -79,12 +87,13 @@ end
|
|
79
87
|
|
80
88
|
If you know what you are doing, you don't necessarily have to process things in the background. As long as the class implements the expected interface, you can do anything you want.
|
81
89
|
|
82
|
-
5. `event_handler` - an instance of event handler/storage, just use what is shown in the example.
|
90
|
+
5. `event_handler` - an instance of event handler/storage, just use what is shown in the example. Notice that you can also pass extra consumer config lambda that will be evaluated within the context of Hutch consumer.
|
83
91
|
6. `clock` - a clock object that is time-zone aware, implementing `now` method.
|
84
92
|
7. `configure_hutch` - a way to configure Hutch:
|
85
93
|
- `uri` - the URI for RabbitMQ, required.
|
86
94
|
- `force_publisher_confirms` - defaults to `true`
|
87
95
|
- `enable_http_api_use` - defaults to `false`
|
96
|
+
- `tracer` - defaults to `Hermes::Tracers::Datadog` if you use Datadog, `Hutch::Tracers::NewRelic` for NewRelic and `Hutch::Tracers::NullTracer` if you use neither Datadog, nor NewRelic. Check APM section for more details if you want to provide a custom tracer.
|
88
97
|
8. `event_handler.handle_events` - that's how you declare events and their handlers. The event handler is an object that responds to `call` method and takes `event` as an argument. All events should ideally be subclasses of `Hermes::BaseEvent`
|
89
98
|
|
90
99
|
This class inherits from `Dry::Struct`, so getting familiar with [dry-struct gem](https://dry-rb.org/gems/dry-struct/) would be beneficial. Here is an example event:
|
@@ -139,7 +148,7 @@ If you don't care about it, you can leave it empty.
|
|
139
148
|
|
140
149
|
12. `distributed_tracing_database_table` - Table name for storing traces, by default it's `hermes_distributed_traces`. Optional.
|
141
150
|
|
142
|
-
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)`
|
143
152
|
|
144
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.
|
145
154
|
|
@@ -151,7 +160,7 @@ If you don't care about it, you can leave it empty.
|
|
151
160
|
|
152
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:
|
153
162
|
- provide custom array of sensitive attributes and still use a default filter: `Hermes::Logger::ParamsFilter.new(sensitive_keywords: Rails.application.config.filter_parameters)`.
|
154
|
-
- 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.
|
155
164
|
## RPC
|
156
165
|
|
157
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.
|
@@ -180,9 +189,11 @@ parsed_response_hash = Hermes::RpcClient.new(rpc_call_timeout: 10).call(event)
|
|
180
189
|
|
181
190
|
If the request timeouts, `Hermes::RpcClient::RpcTimeoutError` will be raised.
|
182
191
|
|
183
|
-
##
|
192
|
+
## APM and tracing
|
184
193
|
|
185
|
-
The integration is enabled automatically if you use `newrelic_rpm` gem via `Hutch::Tracers::NewRelic
|
194
|
+
The integration is enabled automatically if you use `newrelic_rpm` gem via `Hutch::Tracers::NewRelic` or via `Hermes::Tracers::Datadog` when using `ddtrace` gem.
|
195
|
+
|
196
|
+
You can also provide your own tracer, as long as it implements an interface expected by [Hutch][https://github.com/ruby-amqp/hutch].
|
186
197
|
|
187
198
|
## Distributed Tracing (experimental feature, the interface might change in the future)
|
188
199
|
|
@@ -448,6 +459,33 @@ end
|
|
448
459
|
|
449
460
|
Hermes is just an extra layer on top of [hutch](https://github.com/gocardless/hutch), refer to Hutch's docs for more info about dealing with the workers and deployment.
|
450
461
|
|
462
|
+
## Health Checks
|
463
|
+
|
464
|
+
If you want to perform a health check, use `Hermes::Checks::HealthCheck.check`, which checks if it's possible to connect RabbitMQ via Hutch.
|
465
|
+
|
466
|
+
The interface is compliant with `health_check`[https://github.com/ianheggie/health_check] gem. If you want to add the custom health check, just add this to the config:
|
467
|
+
|
468
|
+
``` rb
|
469
|
+
config.add_custom_check("hermes") do
|
470
|
+
Hermes::Checks::HealthCheck.check
|
471
|
+
end
|
472
|
+
```
|
473
|
+
|
474
|
+
You can also use `bin/health_check` file to perform healthcheck - on success, the script exits with `0` status and on failure, it logs the error and exits with `1` status.
|
475
|
+
|
476
|
+
To perform the actual check:
|
477
|
+
|
478
|
+
1. Via `health_check` gem:
|
479
|
+
```
|
480
|
+
curl -v localhost:3000/health_check/hermes.json
|
481
|
+
```
|
482
|
+
|
483
|
+
2. Via binary:
|
484
|
+
|
485
|
+
```
|
486
|
+
bundle exec hermes_health_check
|
487
|
+
```
|
488
|
+
|
451
489
|
## CircleCI config for installing RabbitMQ
|
452
490
|
|
453
491
|
Use `- image: brandembassy/rabbitmq:latest`
|
@@ -0,0 +1,12 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require_relative "../lib/hermes-rb"
|
5
|
+
|
6
|
+
result = Hermes::Checks::HealthCheck.check
|
7
|
+
if result.empty?
|
8
|
+
exit 0
|
9
|
+
else
|
10
|
+
Hermes::DependenciesContainer["logger"].log_health_check_failure(result)
|
11
|
+
exit 1
|
12
|
+
end
|
data/hermes-rb.gemspec
CHANGED
@@ -23,8 +23,8 @@ Gem::Specification.new do |spec|
|
|
23
23
|
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
24
24
|
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
25
25
|
end
|
26
|
-
spec.bindir = "
|
27
|
-
spec.executables =
|
26
|
+
spec.bindir = "bin"
|
27
|
+
spec.executables = ["hermes_health_check"]
|
28
28
|
spec.require_paths = ["lib"]
|
29
29
|
|
30
30
|
spec.add_dependency "dry-struct", "~> 1"
|
@@ -41,4 +41,5 @@ Gem::Specification.new do |spec|
|
|
41
41
|
spec.add_development_dependency "vcr"
|
42
42
|
spec.add_development_dependency "pg"
|
43
43
|
spec.add_development_dependency "newrelic_rpm"
|
44
|
+
spec.add_development_dependency "ddtrace"
|
44
45
|
end
|
data/lib/hermes.rb
CHANGED
@@ -24,6 +24,8 @@ require "hermes/retryable_event_producer"
|
|
24
24
|
require "hermes/producer_error_handler"
|
25
25
|
require "hermes/producer_error_handler/null_handler"
|
26
26
|
require "hermes/producer_error_handler/safe_handler"
|
27
|
+
require "hermes/tracers"
|
28
|
+
require "hermes/checks"
|
27
29
|
require "active_support"
|
28
30
|
require "active_support/core_ext/string"
|
29
31
|
require "active_record"
|
data/lib/hermes/configuration.rb
CHANGED
@@ -4,7 +4,7 @@ module Hermes
|
|
4
4
|
:background_processor, :enqueue_method, :event_handler, :rpc_call_timeout,
|
5
5
|
:instrumenter, :distributed_tracing_database_uri, :distributed_tracing_database_table,
|
6
6
|
:distributes_tracing_mapper, :database_error_handler, :error_notification_service, :producer_error_handler,
|
7
|
-
:producer_error_handler_job_class, :producer_retryable, :logger_params_filter
|
7
|
+
:producer_error_handler_job_class, :producer_retryable, :logger_params_filter, :tracer
|
8
8
|
|
9
9
|
def configure_hutch
|
10
10
|
yield hutch
|
@@ -82,14 +82,14 @@ module Hermes
|
|
82
82
|
attr_reader :original_hutch_config
|
83
83
|
private :original_hutch_config
|
84
84
|
|
85
|
-
attr_accessor :uri, :force_publisher_confirms, :enable_http_api_use
|
85
|
+
attr_accessor :uri, :force_publisher_confirms, :enable_http_api_use, :tracer
|
86
86
|
|
87
87
|
def initialize(original_hutch_config: Hutch::Config)
|
88
88
|
@original_hutch_config = original_hutch_config
|
89
89
|
end
|
90
90
|
|
91
91
|
def commit_config
|
92
|
-
original_hutch_config.set(:tracer,
|
92
|
+
original_hutch_config.set(:tracer, tracer) if tracer
|
93
93
|
original_hutch_config.set(:force_publisher_confirms, force_publisher_confirms)
|
94
94
|
original_hutch_config.set(:uri, uri)
|
95
95
|
end
|
@@ -105,6 +105,13 @@ module Hermes
|
|
105
105
|
|
106
106
|
@enable_http_api_use ||= false
|
107
107
|
end
|
108
|
+
|
109
|
+
def tracer
|
110
|
+
return @tracer if @tracer
|
111
|
+
return Hermes::Tracers::Datadog if Object.const_defined?("Datadog")
|
112
|
+
return Hutch::Tracers::NewRelic if Object.const_defined?("NewRelic")
|
113
|
+
Hutch::Tracers::NullTracer
|
114
|
+
end
|
108
115
|
end
|
109
116
|
private_constant :HutchConfig
|
110
117
|
end
|
@@ -2,7 +2,7 @@ require "hutch"
|
|
2
2
|
|
3
3
|
module Hermes
|
4
4
|
class ConsumerBuilder
|
5
|
-
def build(event_class)
|
5
|
+
def build(event_class, consumer_config: -> {})
|
6
6
|
queue = queue_name_from_event(event_class)
|
7
7
|
routing_key = event_class.routing_key
|
8
8
|
consumer_name = consumer_name_from_event(event_class)
|
@@ -12,6 +12,7 @@ module Hermes
|
|
12
12
|
|
13
13
|
consume routing_key
|
14
14
|
queue_name queue
|
15
|
+
instance_exec(&consumer_config)
|
15
16
|
|
16
17
|
define_method :process do |message|
|
17
18
|
instrumenter.instrument("Hermes.Consumer.process") do
|
data/lib/hermes/event_handler.rb
CHANGED
@@ -5,25 +5,27 @@ module Hermes
|
|
5
5
|
attr_reader :container, :consumer_builder
|
6
6
|
private :container, :consumer_builder
|
7
7
|
|
8
|
-
def initialize
|
9
|
-
@container =
|
10
|
-
@consumer_builder =
|
8
|
+
def initialize(container: Dry::Container.new, consumer_builder: Hermes::DependenciesContainer["consumer_builder"])
|
9
|
+
@container = container
|
10
|
+
@consumer_builder = consumer_builder
|
11
11
|
end
|
12
12
|
|
13
13
|
def handle_events(&block)
|
14
14
|
instance_exec(&block)
|
15
15
|
end
|
16
16
|
|
17
|
-
def handle(event_class, with:, async: true, rpc: false)
|
17
|
+
def handle(event_class, with:, async: true, rpc: false, consumer_config: -> {})
|
18
18
|
handler = with
|
19
19
|
options = {
|
20
20
|
async: async,
|
21
|
-
rpc: rpc
|
21
|
+
rpc: rpc,
|
22
|
+
consumer_config: consumer_config
|
22
23
|
}
|
23
|
-
consumer = build_consumer_for_event(event_class)
|
24
|
+
consumer = build_consumer_for_event(event_class, consumer_config)
|
24
25
|
|
25
|
-
|
26
|
-
|
26
|
+
Registration.new(handler, consumer, options).tap do |registration|
|
27
|
+
container.register(event_class, registration)
|
28
|
+
end
|
27
29
|
end
|
28
30
|
|
29
31
|
def registration_for(event_class)
|
@@ -32,8 +34,8 @@ module Hermes
|
|
32
34
|
|
33
35
|
private
|
34
36
|
|
35
|
-
def build_consumer_for_event(event_class)
|
36
|
-
consumer_builder.build(event_class)
|
37
|
+
def build_consumer_for_event(event_class, consumer_config)
|
38
|
+
consumer_builder.build(event_class, consumer_config: consumer_config)
|
37
39
|
end
|
38
40
|
|
39
41
|
class Registration
|
@@ -52,6 +54,10 @@ module Hermes
|
|
52
54
|
def rpc?
|
53
55
|
options.fetch(:rpc) == true
|
54
56
|
end
|
57
|
+
|
58
|
+
def consumer_config
|
59
|
+
optons.fetch(:consumer_config)
|
60
|
+
end
|
55
61
|
end
|
56
62
|
end
|
57
63
|
end
|
data/lib/hermes/logger.rb
CHANGED
@@ -17,6 +17,10 @@ module Hermes
|
|
17
17
|
backend.info "[Hutch] published event to: #{routing_key}, properties: #{properties}, body: #{strip_sensitive_info(body)} at #{timestamp}"
|
18
18
|
end
|
19
19
|
|
20
|
+
def log_health_check_failure(error)
|
21
|
+
backend.info "[Hermes] health check failed: #{error}"
|
22
|
+
end
|
23
|
+
|
20
24
|
private
|
21
25
|
|
22
26
|
def strip_sensitive_info(body)
|
@@ -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
|
@@ -16,7 +16,7 @@ module Hermes
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def call(attribute, value)
|
19
|
-
if sensitive_keywords.any? { |sensitive_attribute| attribute.to_s.match(sensitive_attribute) }
|
19
|
+
if sensitive_keywords.any? { |sensitive_attribute| attribute.to_s.match(sensitive_attribute) } && value.respond_to?(:to_str)
|
20
20
|
value.gsub!(value, stripped_value)
|
21
21
|
end
|
22
22
|
end
|
data/lib/hermes/rb/version.rb
CHANGED
@@ -0,0 +1,20 @@
|
|
1
|
+
require "ddtrace"
|
2
|
+
|
3
|
+
module Hermes
|
4
|
+
module Tracers
|
5
|
+
class Datadog
|
6
|
+
attr_reader :klass
|
7
|
+
private :klass
|
8
|
+
|
9
|
+
def initialize(klass)
|
10
|
+
@klass = klass
|
11
|
+
end
|
12
|
+
|
13
|
+
def handle(message)
|
14
|
+
::Datadog.tracer.trace(klass.class.name, service: "hermes", span_type: "rabbitmq") do
|
15
|
+
klass.process(message)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
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.6.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Karol Galanciak
|
8
8
|
autorequire:
|
9
|
-
bindir:
|
9
|
+
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-06-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dry-struct
|
@@ -192,11 +192,26 @@ dependencies:
|
|
192
192
|
- - ">="
|
193
193
|
- !ruby/object:Gem::Version
|
194
194
|
version: '0'
|
195
|
+
- !ruby/object:Gem::Dependency
|
196
|
+
name: ddtrace
|
197
|
+
requirement: !ruby/object:Gem::Requirement
|
198
|
+
requirements:
|
199
|
+
- - ">="
|
200
|
+
- !ruby/object:Gem::Version
|
201
|
+
version: '0'
|
202
|
+
type: :development
|
203
|
+
prerelease: false
|
204
|
+
version_requirements: !ruby/object:Gem::Requirement
|
205
|
+
requirements:
|
206
|
+
- - ">="
|
207
|
+
- !ruby/object:Gem::Version
|
208
|
+
version: '0'
|
195
209
|
description: A messenger of gods, delivering them via RabbitMQ with a little help
|
196
210
|
from Hutch
|
197
211
|
email:
|
198
212
|
- dev@bookingsync.com
|
199
|
-
executables:
|
213
|
+
executables:
|
214
|
+
- hermes_health_check
|
200
215
|
extensions: []
|
201
216
|
extra_rdoc_files: []
|
202
217
|
files:
|
@@ -210,12 +225,15 @@ files:
|
|
210
225
|
- README.md
|
211
226
|
- Rakefile
|
212
227
|
- bin/console
|
228
|
+
- bin/hermes_health_check
|
213
229
|
- bin/setup
|
214
230
|
- hermes-rb.gemspec
|
215
231
|
- lib/hermes-rb.rb
|
216
232
|
- lib/hermes.rb
|
217
233
|
- lib/hermes/b_3_propagation_model_headers.rb
|
218
234
|
- lib/hermes/base_event.rb
|
235
|
+
- lib/hermes/checks.rb
|
236
|
+
- lib/hermes/checks/health_check.rb
|
219
237
|
- lib/hermes/configuration.rb
|
220
238
|
- lib/hermes/consumer_builder.rb
|
221
239
|
- lib/hermes/database_error_handler.rb
|
@@ -245,6 +263,8 @@ files:
|
|
245
263
|
- lib/hermes/serializer.rb
|
246
264
|
- lib/hermes/support/matchers/publish_async_message.rb
|
247
265
|
- lib/hermes/trace_context.rb
|
266
|
+
- lib/hermes/tracers.rb
|
267
|
+
- lib/hermes/tracers/datadog.rb
|
248
268
|
- untitled
|
249
269
|
homepage: https://github.com/BookingSync/hermes-rb
|
250
270
|
licenses:
|