hermes-rb 0.4.0 → 0.5.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: 61eb45c503cb8431d679fd198af4b65f379fd3efe4d40381ae72baf39bffa9bc
4
- data.tar.gz: '09cf809349943da3991e64e9ceea38b3e9a54cd5d992a6aeb11524c784bbe837'
3
+ metadata.gz: e7a8150916885c53a7ec982a4a8b4c52b3ae181c372a49d848af7e1938c4e57d
4
+ data.tar.gz: 1df94ecfc4595c5c8e6c67d79750c4a2fbca4f1a7119a1f5c532b83890a9e1f8
5
5
  SHA512:
6
- metadata.gz: 67a2991af401ec5a66b2717b683b82ad4816fd6a9bb6be17a688ee19de05bf112c511b81b126cdb224c219b42720125ff59acfd95b865a2fbde908f4f59338ef
7
- data.tar.gz: f7104301bfc8993a15cade245ec42d2a1a40e308c04033004caa1883aba238908358d6f62bca024c250a6208d20c4d5116db3b1553068c59895db9ce34fa60eb
6
+ metadata.gz: 57bd2ad4a3a48368360bc1d7fcd42817ef698f326c423068b237123142707d64ca025af62cc8fc0bc9540a0cfe338d701124d73a19b3fe6795c98a7a91ff3a50
7
+ data.tar.gz: 89550087ed862bdeb2cb3472d766071f6504f8608ffad58c3fa164c756dee2775b91d7ee299a55949e8ba7d8a31750accaff0688269a13cf81185a924bf71cfc
data/Changelog.md CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  ## Master
4
4
 
5
+ ## 0.5.0
6
+ - Add Datadog tracer
7
+ - Allow to provide a custom tracer
8
+
5
9
  ## 0.4.0
6
10
  - Make it possible to provide Hutch consumer config
7
11
 
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- hermes-rb (0.4.0)
4
+ hermes-rb (0.5.0)
5
5
  activerecord (>= 5)
6
6
  activesupport (>= 5)
7
7
  dry-container (~> 0)
@@ -29,6 +29,8 @@ GEM
29
29
  carrot-top (0.0.7)
30
30
  json
31
31
  concurrent-ruby (1.1.8)
32
+ ddtrace (0.45.0)
33
+ msgpack
32
34
  diff-lcs (1.4.4)
33
35
  dry-configurable (0.12.1)
34
36
  concurrent-ruby (~> 1.0)
@@ -61,7 +63,8 @@ GEM
61
63
  concurrent-ruby (~> 1.0)
62
64
  ice_nine (0.11.2)
63
65
  json (2.5.1)
64
- minitest (5.14.3)
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
@@ -38,6 +38,7 @@ Rails.application.config.to_prepare do
38
38
  hutch.uri = ENV.fetch("HUTCH_URI")
39
39
  hutch.force_publisher_confirms = true
40
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
@@ -92,6 +93,7 @@ If you know what you are doing, you don't necessarily have to process things in
92
93
  - `uri` - the URI for RabbitMQ, required.
93
94
  - `force_publisher_confirms` - defaults to `true`
94
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.
95
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`
96
98
 
97
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:
@@ -187,9 +189,11 @@ parsed_response_hash = Hermes::RpcClient.new(rpc_call_timeout: 10).call(event)
187
189
 
188
190
  If the request timeouts, `Hermes::RpcClient::RpcTimeoutError` will be raised.
189
191
 
190
- ## NewRelic integration
192
+ ## APM and tracing
191
193
 
192
- 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].
193
197
 
194
198
  ## Distributed Tracing (experimental feature, the interface might change in the future)
195
199
 
data/hermes-rb.gemspec CHANGED
@@ -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,7 @@ 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"
27
28
  require "active_support"
28
29
  require "active_support/core_ext/string"
29
30
  require "active_record"
@@ -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, Hutch::Tracers::NewRelic) if Object.const_defined?("NewRelic")
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
@@ -1,5 +1,5 @@
1
1
  module Hermes
2
2
  module Rb
3
- VERSION = "0.4.0"
3
+ VERSION = "0.5.0"
4
4
  end
5
5
  end
@@ -0,0 +1,5 @@
1
+ module Hermes
2
+ module Tracers
3
+ autoload :Datadog, "hermes/tracers/datadog"
4
+ end
5
+ end
@@ -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.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Karol Galanciak
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-02-25 00:00:00.000000000 Z
11
+ date: 2021-03-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dry-struct
@@ -192,6 +192,20 @@ 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:
@@ -245,6 +259,8 @@ files:
245
259
  - lib/hermes/serializer.rb
246
260
  - lib/hermes/support/matchers/publish_async_message.rb
247
261
  - lib/hermes/trace_context.rb
262
+ - lib/hermes/tracers.rb
263
+ - lib/hermes/tracers/datadog.rb
248
264
  - untitled
249
265
  homepage: https://github.com/BookingSync/hermes-rb
250
266
  licenses: