hutch 0.25.0 → 0.26.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
- SHA1:
3
- metadata.gz: 6f166e0937fb1f468d18247afad90ff52263de57
4
- data.tar.gz: 97b3c87cd087984409fda36f620c180a71df03d8
2
+ SHA256:
3
+ metadata.gz: eeb0e500b415b5c125335f93c9bdf6d7c44faf8588514cc0d9ff0d11d35e831c
4
+ data.tar.gz: 4b96383eb819a42a9ce517e05499c85dcdde49602eec5a00dcf40a65b915239d
5
5
  SHA512:
6
- metadata.gz: 549463d55e4bfa5ee9b112c42a06c98999c25ab14a8562ef41adc75888f8eba30a42ebe39097ec7366939ad0ef44e38d6ffab8103f6f739f7e2aad68e955488c
7
- data.tar.gz: 55972b247cb63587772adc3f12d40e852d6332c9991e08ddba7c388a4ab711851d81e3399b8d0c7407c2a16584f20f8c59aaede191f9eb41cd1d46208a0acb29
6
+ metadata.gz: 4988b67c0057b9bb06273a87bb824741f735c549b39535030d9acbeec246bb9d746a93306291907776c8582eef171a883e162c9dc94488f6360d3333af17051f
7
+ data.tar.gz: 863ec55200be7dfc18bf5c350f0dbf707e85b74c8397628113779a6c7858911ff9b65cd995e76526452811de32c05be0c94d6cf53d2387525735115faa35c777
@@ -2,15 +2,21 @@ language: ruby
2
2
  cache: bundler
3
3
  before_install:
4
4
  - gem install bundler
5
+ before_script:
6
+ - "./bin/ci/install_on_debian.sh"
7
+ - until sudo lsof -i:5672; do echo "Waiting for RabbitMQ to start..."; sleep 1; done
5
8
  matrix:
6
9
  include:
7
- - rvm: 2.4.2
8
- - rvm: 2.3.5
9
- - rvm: 2.2.8
10
- - rvm: jruby-9.1.15.0
11
- jdk: oraclejdk8
12
- env:
13
- - JRUBY_OPTS='--debug'
10
+ - rvm: "2.6.1"
11
+ - rvm: "2.5.3"
12
+ - rvm: "2.4.5"
13
+ - rvm: "2.3.8"
14
+ - rvm: "jruby-9.2.6.0"
15
+ - rvm: "ruby-head"
16
+ allow_failures:
17
+ rvm:
18
+ - "jruby-9.2.6.0"
19
+ - ruby-head
14
20
 
15
21
  services:
16
22
  - rabbitmq
@@ -1,8 +1,99 @@
1
- ## 0.25.0 — (unreleased)
1
+ ## 0.27.0
2
2
 
3
3
  No changes yet.
4
4
 
5
5
 
6
+ ## 0.26.0 (February 13th, 2019)
7
+
8
+ ### Dependency Bumps
9
+
10
+ Bunny and other dependencies were updated to their latest release
11
+ series.
12
+
13
+ ### Synchronized Connection Code
14
+
15
+ The methods that connect to RabbitMQ are now synchronized which makes
16
+ them safer to use in concurrent settings. Note that Hutch still
17
+ uses a single Bunny channel which is not meant to be shared
18
+ between threads without application-level synchronization for publishing.
19
+
20
+ Contributed by Chris Barton.
21
+
22
+ GitHub issue: [#308](https://github.com/gocardless/hutch/pull/308).
23
+
24
+ ### More Bunny Options Propagated
25
+
26
+ Contributed by Damian Le Nouaille.
27
+
28
+ GitHub issue: [#322](https://github.com/gocardless/hutch/pull/322).
29
+
30
+ ### Removed Opbeat Integration
31
+
32
+ The service is no longer generally available.
33
+
34
+ Contributed by Olle Jonsson.
35
+
36
+ GitHub issue: [#313](https://github.com/gocardless/hutch/pull/313)
37
+
38
+
39
+ ## 0.25.0 - January 17th, 2018
40
+
41
+ ### Consumer groups
42
+
43
+ Consumer groups allow you to run groups of consumers together, rather than running them
44
+ all at once in a single process. You define groups in your config file, and then specify
45
+ a `--only-group` option when starting up Hutch with `hutch`.
46
+
47
+ Contributed by Nickolai Smirnov.
48
+
49
+ GitHub pull request: [#296](https://github.com/gocardless/hutch/pull/296)
50
+
51
+ ### Fix configuring Hutch with a URI
52
+
53
+ When Hutch is configured to connect to RabbitMQ with a URI, we should respect the
54
+ `amqps` specification, defaulting to the standard protocol ports when not specified.
55
+
56
+ This means, for example, that `amqp://guest:guest@127.0.0.1/` connects to the server on
57
+ port 5672 and does not use TLS, whereas `amqps://guest:guest@127.0.0.1/` connects to the
58
+ server on port 5671 and uses TLS.
59
+
60
+ This behaviour was introduced in [#159](https://github.com/gocardless/hutch/pull/159) but
61
+ broken since then. This fixes it, and includes tests.
62
+
63
+ Contributed by Michael Canden-Lennox.
64
+
65
+ GitHub pull request: [#305](https://github.com/gocardless/hutch/pull/305)
66
+
67
+ ### Pass exceptions when setting up the client to configured error handlers
68
+
69
+ When an error occurs during Hutch's startup, it is currently not passed to the configured
70
+ error handlers. This starts handling those exceptions.
71
+
72
+ Contributed by Valentin Krasontovitsch.
73
+
74
+ GitHub issue: [#288](https://github.com/gocardless/hutch/issues/288)
75
+ GitHub pull request: [#301](https://github.com/gocardless/hutch/pull/301)
76
+
77
+ ### Log the Rails environment when running Hutch in verbose mode
78
+
79
+ When starting up Hutch in verbose mode with `hutch -v`, the Rails environment is now
80
+ logged.
81
+
82
+ Contributed by [@wppurking](https://github.com/wppurking).
83
+
84
+ GitHub pull request: [#282](https://github.com/gocardless/hutch/pull/282)
85
+
86
+ ### Make the Honeybadger error handler compatible with new versions of `honeybadger-ruby`
87
+
88
+ [`honeybadger-ruby`](https://github.com/honeybadger-io/honeybadger-ruby/)
89
+ [changed](https://github.com/honeybadger-io/honeybadger-ruby/blob/master/CHANGELOG.md#300---2017-02-06)
90
+ its API in v3.0.0. This updates our error handler to work with that, whilst still
91
+ maintaining our existing behaviour.
92
+
93
+ Contributed by Olle Jonsson and Bill Ruddock.
94
+
95
+ GitHub pull requests: [#274](https://github.com/gocardless/hutch/pull/274),
96
+ [#290](https://github.com/gocardless/hutch/pull/290)
6
97
 
7
98
  ## 0.24.0 — February 1st, 2017
8
99
 
@@ -20,7 +111,7 @@ Hutch will now handle several OS signals:
20
111
 
21
112
  * `USR2` will log stack traces of all alive VM threads
22
113
  * `QUIT` (except on JRuby), `INT`, `TERM` will cause Hutch daemon to shut down
23
-
114
+
24
115
  Contributed by Olle Jonsson.
25
116
 
26
117
  GitHub issues: [#263](https://github.com/gocardless/hutch/pull/263), [#271](https://github.com/gocardless/hutch/pull/271)
@@ -104,7 +195,7 @@ Contributed by Seamus Abshere.
104
195
 
105
196
  ### Worker: Log received messages using level DEBUG instead of INFO
106
197
 
107
- Received messages used to be logged using severity level INFO.
198
+ Received messages used to be logged using severity level INFO.
108
199
  This has been lowered to DEBUG.
109
200
 
110
201
  Contributed by Jesper Josefsson.
@@ -636,4 +727,3 @@ Hutch.global_properties = proc {
636
727
  ## 0.1.0 - September 9, 2013
637
728
 
638
729
  - Initial release
639
-
data/Gemfile CHANGED
@@ -1,6 +1,6 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- ruby RUBY_VERSION
3
+ ruby '>= 2.3.0'
4
4
 
5
5
  gemspec
6
6
 
@@ -23,8 +23,7 @@ group :development, :test do
23
23
  gem "honeybadger"
24
24
  gem "coveralls", "~> 0.8.15", require: false
25
25
  gem "newrelic_rpm"
26
- gem "airbrake", "~> 7.0"
27
- gem "opbeat", "~> 3.0.9"
26
+ gem "airbrake", "~> 8.0"
28
27
  end
29
28
 
30
29
  group :development, :darwin do
data/README.md CHANGED
@@ -2,7 +2,6 @@
2
2
 
3
3
  [![Gem Version](https://badge.fury.io/rb/hutch.svg)](http://badge.fury.io/rb/hutch)
4
4
  [![Build Status](https://travis-ci.org/gocardless/hutch.svg?branch=master)](https://travis-ci.org/gocardless/hutch)
5
- [![Dependency Status](https://gemnasium.com/gocardless/hutch.svg)](https://gemnasium.com/gocardless/hutch)
6
5
  [![Code Climate](https://codeclimate.com/github/gocardless/hutch.svg)](https://codeclimate.com/github/gocardless/hutch)
7
6
 
8
7
  Hutch is a Ruby library for enabling asynchronous inter-service communication
@@ -40,7 +39,7 @@ gem install hutch
40
39
 
41
40
  ## Requirements
42
41
 
43
- - Hutch requires Ruby 2.0+ or JRuby 9K.
42
+ - Hutch requires Ruby 2.2+ or JRuby 9K.
44
43
  - Hutch requires RabbitMQ 3.3 or later.
45
44
 
46
45
  ## Overview
@@ -59,8 +58,9 @@ Hutch uses [Bunny](http://rubybunny.info) or [March Hare](http://rubymarchhare.i
59
58
 
60
59
  ### Project Maturity
61
60
 
62
- Hutch is a moderately mature project (started in early 2013)
63
- that was extracted from production systems.
61
+ Hutch is a mature project that was originally extracted from production systems
62
+ at [GoCardless](https://gocardless.com) in 2013 and is now maintained by a large
63
+ group of contributors.
64
64
 
65
65
  ## Consumers
66
66
 
@@ -122,7 +122,7 @@ end
122
122
 
123
123
  This sets the `x-max-length` header. For more details, see the [RabbitMQ
124
124
  documentation on Queue Length Limit](https://www.rabbitmq.com/maxlength.html). To find out more
125
- about custom queue arguments, consult the [RabbitMQ documentation on AMQP Protocol Extensions](https://www.rabbitmq.com/extensions.html).
125
+ about custom queue arguments, consult the [RabbitMQ documentation on AMQP Protocol Extensions](https://www.rabbitmq.com/extensions.html).
126
126
 
127
127
  Consumers can write to Hutch's log by calling the logger method. The logger method returns
128
128
  a [Logger object](http://ruby-doc.org/stdlib-2.1.2/libdoc/logger/rdoc/Logger.html).
@@ -166,7 +166,7 @@ This will enable NewRelic custom instrumentation:
166
166
  Hutch::Config.set(:tracer, Hutch::Tracers::NewRelic)
167
167
  ```
168
168
 
169
- Batteries included!
169
+ Batteries included!
170
170
 
171
171
  ## Running Hutch
172
172
 
@@ -341,6 +341,8 @@ Known configuration parameters are:
341
341
  * `connection_timeout`: Bunny's socket open timeout (default: `11`)
342
342
  * `read_timeout`: Bunny's socket read timeout (default: `11`)
343
343
  * `write_timeout`: Bunny's socket write timeout (default: `11`)
344
+ * `automatically_recover`: Bunny's enable/disable network recovery (default: `true`)
345
+ * `network_recovery_interval`: Bunny's reconnect interval (default: `1`)
344
346
  * `tracer`: tracer to use to track message processing
345
347
 
346
348
  ### Environment variables
@@ -484,6 +486,20 @@ Generate with
484
486
  <td><tt>HUTCH_WRITE_TIMEOUT</tt></td>
485
487
  <td><p>Bunny's socket write timeout</p></td>
486
488
  </tr>
489
+ <tr>
490
+ <td><tt>automatically_recover</tt></td>
491
+ <td>true</td>
492
+ <td>Boolean</td>
493
+ <td><tt>HUTCH_AUTOMATICALLY_RECOVER</tt></td>
494
+ <td><p>Bunny's enable/disable network recovery</p></td>
495
+ </tr>
496
+ <tr>
497
+ <td><tt>network_recovery_interval</tt></td>
498
+ <td>1</td>
499
+ <td>Number</td>
500
+ <td><tt>HUTCH_NETWORK_RECOVERY_INTERVAL</tt></td>
501
+ <td><p>Bunny's reconnect interval</p></td>
502
+ </tr>
487
503
  <tr>
488
504
  <td><tt>graceful_exit_timeout</tt></td>
489
505
  <td>11</td>
@@ -570,8 +586,3 @@ Generate with
570
586
  </tr>
571
587
  </tbody>
572
588
  </table>
573
-
574
-
575
- ---
576
-
577
- GoCardless ♥ open source. If you do too, come [join us](https://gocardless.com/jobs/backend_developer).
@@ -0,0 +1,17 @@
1
+ #!/bin/sh
2
+
3
+ sudo apt-get install -y wget
4
+ wget -O - "https://github.com/rabbitmq/signing-keys/releases/download/2.0/rabbitmq-release-signing-key.asc" | sudo apt-key add -
5
+
6
+ sudo tee /etc/apt/sources.list.d/bintray.rabbitmq.list <<EOF
7
+ deb https://dl.bintray.com/rabbitmq-erlang/debian xenial erlang
8
+ deb https://dl.bintray.com/rabbitmq/debian xenial main
9
+ EOF
10
+
11
+ sudo apt-get update -y
12
+ sudo apt-get upgrade -y
13
+ sudo apt-get install -y rabbitmq-server
14
+
15
+ sudo service rabbitmq-server start
16
+
17
+ until sudo lsof -i:5672; do echo "Waiting for RabbitMQ to start..."; sleep 1; done
@@ -6,7 +6,7 @@ Gem::Specification.new do |gem|
6
6
  gem.add_runtime_dependency 'march_hare', '>= 3.0.0'
7
7
  else
8
8
  gem.platform = Gem::Platform::RUBY
9
- gem.add_runtime_dependency 'bunny', '~> 2.9.0'
9
+ gem.add_runtime_dependency 'bunny', '>= 2.12', '< 2.15'
10
10
  end
11
11
  gem.add_runtime_dependency 'carrot-top', '~> 0.0.7'
12
12
  gem.add_runtime_dependency 'multi_json', '~> 1.12'
@@ -14,6 +14,8 @@ require 'hutch/exceptions'
14
14
  require 'hutch/tracers'
15
15
 
16
16
  module Hutch
17
+ @@connection_mutex = Mutex.new
18
+
17
19
  def self.register_consumer(consumer)
18
20
  self.consumers << consumer
19
21
  end
@@ -40,10 +42,12 @@ module Hutch
40
42
  # @param config [Hash] Configuration
41
43
  # @option options [Boolean] :enable_http_api_use
42
44
  def self.connect(options = {}, config = Hutch::Config)
43
- return if connected?
44
-
45
- @broker = Hutch::Broker.new(config)
46
- @broker.connect(options)
45
+ @@connection_mutex.synchronize do
46
+ unless connected?
47
+ @broker = Hutch::Broker.new(config)
48
+ @broker.connect(options)
49
+ end
50
+ end
47
51
  end
48
52
 
49
53
  def self.disconnect
@@ -298,8 +298,8 @@ module Hutch
298
298
  params[:write_timeout] = @config[:write_timeout]
299
299
 
300
300
 
301
- params[:automatically_recover] = true
302
- params[:network_recovery_interval] = 1
301
+ params[:automatically_recover] = @config[:automatically_recover]
302
+ params[:network_recovery_interval] = @config[:network_recovery_interval]
303
303
 
304
304
  params[:logger] = @config[:client_logger] if @config[:client_logger]
305
305
  end
@@ -89,6 +89,12 @@ module Hutch
89
89
  # Bunny's socket write timeout
90
90
  number_setting :write_timeout, 11
91
91
 
92
+ # Bunny's enable/disable network recovery
93
+ boolean_setting :automatically_recover, true
94
+
95
+ # Bunny's reconnect interval
96
+ number_setting :network_recovery_interval, 1
97
+
92
98
  # FIXME: DOCUMENT THIS
93
99
  number_setting :graceful_exit_timeout, 11
94
100
 
@@ -4,6 +4,5 @@ module Hutch
4
4
  autoload :Sentry, 'hutch/error_handlers/sentry'
5
5
  autoload :Honeybadger, 'hutch/error_handlers/honeybadger'
6
6
  autoload :Airbrake, 'hutch/error_handlers/airbrake'
7
- autoload :Opbeat, 'hutch/error_handlers/opbeat'
8
7
  end
9
8
  end
@@ -2,6 +2,5 @@ module Hutch
2
2
  module Tracers
3
3
  autoload :NullTracer, 'hutch/tracers/null_tracer'
4
4
  autoload :NewRelic, 'hutch/tracers/newrelic'
5
- autoload :Opbeat, 'hutch/tracers/opbeat'
6
5
  end
7
6
  end
@@ -1,4 +1,3 @@
1
1
  module Hutch
2
- VERSION = '0.25.0'.freeze
2
+ VERSION = '0.26.0'.freeze
3
3
  end
4
-
@@ -118,7 +118,7 @@ module Hutch
118
118
  def group_restricted?(consumer)
119
119
  consumers_to_load = consumer_groups[group]
120
120
  if consumers_to_load
121
- !allowed_consumers.include?(consumer.name)
121
+ !consumers_to_load.include?(consumer.name)
122
122
  else
123
123
  true
124
124
  end
metadata CHANGED
@@ -1,29 +1,35 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hutch
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.25.0
4
+ version: 0.26.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Harry Marr
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-01-17 00:00:00.000000000 Z
11
+ date: 2019-02-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bunny
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '2.12'
20
+ - - "<"
18
21
  - !ruby/object:Gem::Version
19
- version: 2.9.0
22
+ version: '2.15'
20
23
  type: :runtime
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
23
26
  requirements:
24
- - - "~>"
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ version: '2.12'
30
+ - - "<"
25
31
  - !ruby/object:Gem::Version
26
- version: 2.9.0
32
+ version: '2.15'
27
33
  - !ruby/object:Gem::Dependency
28
34
  name: carrot-top
29
35
  requirement: !ruby/object:Gem::Requirement
@@ -91,6 +97,7 @@ files:
91
97
  - LICENSE
92
98
  - README.md
93
99
  - Rakefile
100
+ - bin/ci/install_on_debian.sh
94
101
  - bin/hutch
95
102
  - examples/consumer.rb
96
103
  - examples/producer.rb
@@ -110,7 +117,6 @@ files:
110
117
  - lib/hutch/error_handlers/base.rb
111
118
  - lib/hutch/error_handlers/honeybadger.rb
112
119
  - lib/hutch/error_handlers/logger.rb
113
- - lib/hutch/error_handlers/opbeat.rb
114
120
  - lib/hutch/error_handlers/sentry.rb
115
121
  - lib/hutch/exceptions.rb
116
122
  - lib/hutch/logging.rb
@@ -121,7 +127,6 @@ files:
121
127
  - lib/hutch/tracers.rb
122
128
  - lib/hutch/tracers/newrelic.rb
123
129
  - lib/hutch/tracers/null_tracer.rb
124
- - lib/hutch/tracers/opbeat.rb
125
130
  - lib/hutch/version.rb
126
131
  - lib/hutch/waiter.rb
127
132
  - lib/hutch/worker.rb
@@ -134,7 +139,6 @@ files:
134
139
  - spec/hutch/error_handlers/airbrake_spec.rb
135
140
  - spec/hutch/error_handlers/honeybadger_spec.rb
136
141
  - spec/hutch/error_handlers/logger_spec.rb
137
- - spec/hutch/error_handlers/opbeat_spec.rb
138
142
  - spec/hutch/error_handlers/sentry_spec.rb
139
143
  - spec/hutch/logger_spec.rb
140
144
  - spec/hutch/message_spec.rb
@@ -143,7 +147,6 @@ files:
143
147
  - spec/hutch/worker_spec.rb
144
148
  - spec/hutch_spec.rb
145
149
  - spec/spec_helper.rb
146
- - spec/tracers/opbeat_spec.rb
147
150
  - templates/default/class/html/settings.erb
148
151
  - templates/default/class/setup.rb
149
152
  - templates/default/fulldoc/html/css/hutch.css
@@ -172,8 +175,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
172
175
  - !ruby/object:Gem::Version
173
176
  version: '0'
174
177
  requirements: []
175
- rubyforge_project:
176
- rubygems_version: 2.6.11
178
+ rubygems_version: 3.0.2
177
179
  signing_key:
178
180
  specification_version: 4
179
181
  summary: Easy inter-service communication using RabbitMQ.
@@ -185,7 +187,6 @@ test_files:
185
187
  - spec/hutch/error_handlers/airbrake_spec.rb
186
188
  - spec/hutch/error_handlers/honeybadger_spec.rb
187
189
  - spec/hutch/error_handlers/logger_spec.rb
188
- - spec/hutch/error_handlers/opbeat_spec.rb
189
190
  - spec/hutch/error_handlers/sentry_spec.rb
190
191
  - spec/hutch/logger_spec.rb
191
192
  - spec/hutch/message_spec.rb
@@ -194,4 +195,3 @@ test_files:
194
195
  - spec/hutch/worker_spec.rb
195
196
  - spec/hutch_spec.rb
196
197
  - spec/spec_helper.rb
197
- - spec/tracers/opbeat_spec.rb
@@ -1,30 +0,0 @@
1
- require 'hutch/logging'
2
- require 'opbeat'
3
- require 'hutch/error_handlers/base'
4
-
5
- module Hutch
6
- module ErrorHandlers
7
- class Opbeat < Base
8
-
9
- def initialize
10
- unless ::Opbeat.respond_to?(:report)
11
- raise "The Opbeat error handler requires Opbeat >= 3.0"
12
- end
13
- end
14
-
15
- def handle(properties, payload, consumer, ex)
16
- message_id = properties.message_id
17
- prefix = "message(#{message_id || '-'}):"
18
- logger.error "#{prefix} Logging event to Opbeat"
19
- logger.error "#{prefix} #{ex.class} - #{ex.message}"
20
- ::Opbeat.report(ex, extra: { payload: payload })
21
- end
22
-
23
- def handle_setup_exception(ex)
24
- logger.error "Logging setup exception to Opbeat"
25
- logger.error "#{ex.class} - #{ex.message}"
26
- ::Opbeat.report(ex)
27
- end
28
- end
29
- end
30
- end
@@ -1,37 +0,0 @@
1
- require 'opbeat'
2
-
3
- module Hutch
4
- module Tracers
5
- # Tracer for Opbeat, which traces each message processed.
6
- class Opbeat
7
- KIND = 'messaging.hutch'.freeze
8
-
9
- # @param klass [Consumer] Consumer instance (!)
10
- def initialize(klass)
11
- @klass = klass
12
- end
13
-
14
- # @param message [Message]
15
- def handle(message)
16
- ::Opbeat.transaction(sig, KIND, extra: extra_from(message)) do
17
- @klass.process(message)
18
- end.done(true)
19
- end
20
-
21
- private
22
-
23
- def sig
24
- @klass.class.name
25
- end
26
-
27
- def extra_from(message)
28
- {
29
- body: message.body.to_s,
30
- message_id: message.message_id,
31
- timestamp: message.timestamp,
32
- routing_key: message.routing_key
33
- }
34
- end
35
- end
36
- end
37
- end
@@ -1,37 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Hutch::ErrorHandlers::Opbeat do
4
- let(:error_handler) { Hutch::ErrorHandlers::Opbeat.new }
5
-
6
- describe '#handle' do
7
- let(:properties) { OpenStruct.new(message_id: "1") }
8
- let(:payload) { "{}" }
9
- let(:error) do
10
- begin
11
- raise "Stuff went wrong"
12
- rescue RuntimeError => err
13
- err
14
- end
15
- end
16
-
17
- it "logs the error to Opbeat" do
18
- expect(Opbeat).to receive(:report).with(error, extra: { payload: payload })
19
- error_handler.handle(properties, payload, double, error)
20
- end
21
- end
22
-
23
- describe '#handle_setup_exception' do
24
- let(:error) do
25
- begin
26
- raise "Stuff went wrong during setup"
27
- rescue RuntimeError => err
28
- err
29
- end
30
- end
31
-
32
- it "logs the error to Opbeat" do
33
- expect(Opbeat).to receive(:report).with(error)
34
- error_handler.handle_setup_exception(error)
35
- end
36
- end
37
- end
@@ -1,44 +0,0 @@
1
- require 'hutch/message'
2
- require 'hutch/serializers/identity'
3
- require 'hutch/tracers'
4
-
5
- RSpec.describe Hutch::Tracers::Opbeat do
6
- let(:consumer) { double('the-consumer') }
7
-
8
- subject(:tracer) { described_class.new(consumer) }
9
-
10
- let(:message) do
11
- Hutch::Message.new(double('the-delivery-info', routing_key: 'foo.bar',
12
- exchange: 'foo'),
13
- double('the-properties', message_id: 'the-id',
14
- timestamp: 'the-time'),
15
- double('the-payload', to_s: 'the-body'),
16
- Hutch::Serializers::Identity)
17
- end
18
-
19
- it 'formats messages as extra information' do
20
- expected_extra = {
21
- body: 'the-body',
22
- message_id: 'the-id',
23
- timestamp: 'the-time',
24
- routing_key: 'foo.bar'
25
- }
26
- expect(Opbeat).to receive(:transaction).with(anything,
27
- 'messaging.hutch',
28
- extra: expected_extra) {
29
- double('done-callback', done: true)
30
- }
31
-
32
- tracer.handle(message)
33
- end
34
-
35
- it 'presents consumer class name as Opbeat tracing signature' do
36
- expect(Opbeat).to receive(:transaction).with(consumer.class.name,
37
- 'messaging.hutch',
38
- anything) {
39
- double('done-callback', done: true)
40
- }
41
-
42
- tracer.handle(message)
43
- end
44
- end