hutch 0.25.0.pre.rc1-java → 2.0.0.rc1-java
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 +5 -5
- data/CHANGELOG.md +402 -5
- data/LICENSE +1 -0
- data/README.md +157 -47
- data/bin/ci/before_build.sh +20 -0
- data/bin/ci/before_build_docker.sh +15 -0
- data/bin/ci/install_on_debian.sh +46 -0
- data/lib/hutch/acknowledgements/nack_on_all_failures.rb +1 -1
- data/lib/hutch/adapters/bunny.rb +29 -1
- data/lib/hutch/adapters/march_hare.rb +24 -0
- data/lib/hutch/broker.rb +122 -36
- data/lib/hutch/cli.rb +23 -12
- data/lib/hutch/config.rb +45 -13
- data/lib/hutch/consumer.rb +63 -4
- data/lib/hutch/error_handlers/airbrake.rb +20 -2
- data/lib/hutch/error_handlers/base.rb +15 -0
- data/lib/hutch/error_handlers/bugsnag.rb +30 -0
- data/lib/hutch/error_handlers/honeybadger.rb +11 -3
- data/lib/hutch/error_handlers/logger.rb +7 -2
- data/lib/hutch/error_handlers/rollbar.rb +28 -0
- data/lib/hutch/error_handlers/sentry.rb +13 -11
- data/lib/hutch/error_handlers.rb +2 -1
- data/lib/hutch/publisher.rb +1 -1
- data/lib/hutch/serializers/json.rb +3 -3
- data/lib/hutch/tracers/datadog.rb +18 -0
- data/lib/hutch/tracers.rb +1 -1
- data/lib/hutch/version.rb +1 -2
- data/lib/hutch/waiter.rb +1 -1
- data/lib/hutch/worker.rb +74 -8
- data/lib/hutch.rb +8 -4
- data/lib/yard-settings/yard-settings.rb +2 -2
- data/spec/hutch/broker_spec.rb +222 -10
- data/spec/hutch/cli_spec.rb +25 -9
- data/spec/hutch/config_spec.rb +84 -12
- data/spec/hutch/consumer_spec.rb +93 -4
- data/spec/hutch/error_handlers/airbrake_spec.rb +23 -1
- data/spec/hutch/error_handlers/bugsnag_spec.rb +56 -0
- data/spec/hutch/error_handlers/honeybadger_spec.rb +22 -1
- data/spec/hutch/error_handlers/logger_spec.rb +12 -1
- data/spec/hutch/error_handlers/rollbar_spec.rb +45 -0
- data/spec/hutch/error_handlers/sentry_spec.rb +27 -2
- data/spec/hutch/message_spec.rb +1 -1
- data/spec/hutch/tracers/datadog_spec.rb +46 -0
- data/spec/hutch/waiter_spec.rb +2 -2
- data/spec/hutch/worker_spec.rb +139 -25
- data/spec/integration/channel_recovery_spec.rb +187 -0
- data/spec/integration/publish_consume_spec.rb +47 -0
- metadata +35 -61
- data/.gitignore +0 -10
- data/.rspec +0 -1
- data/.travis.yml +0 -19
- data/.yardopts +0 -5
- data/Gemfile +0 -33
- data/Guardfile +0 -14
- data/Rakefile +0 -21
- data/examples/consumer.rb +0 -13
- data/examples/producer.rb +0 -10
- data/hutch.gemspec +0 -29
- data/lib/hutch/error_handlers/opbeat.rb +0 -24
- data/lib/hutch/tracers/opbeat.rb +0 -37
- data/spec/hutch/error_handlers/opbeat_spec.rb +0 -22
- data/spec/spec_helper.rb +0 -42
- data/spec/tracers/opbeat_spec.rb +0 -44
metadata
CHANGED
|
@@ -1,100 +1,71 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: hutch
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 2.0.0.rc1
|
|
5
5
|
platform: java
|
|
6
6
|
authors:
|
|
7
7
|
- Harry Marr
|
|
8
|
-
|
|
8
|
+
- Michael Klishin
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: march_hare
|
|
14
15
|
requirement: !ruby/object:Gem::Requirement
|
|
15
16
|
requirements:
|
|
16
17
|
- - ">="
|
|
17
18
|
- !ruby/object:Gem::Version
|
|
18
|
-
version:
|
|
19
|
-
name: march_hare
|
|
20
|
-
prerelease: false
|
|
19
|
+
version: 4.7.0
|
|
21
20
|
type: :runtime
|
|
21
|
+
prerelease: false
|
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
|
23
23
|
requirements:
|
|
24
24
|
- - ">="
|
|
25
25
|
- !ruby/object:Gem::Version
|
|
26
|
-
version:
|
|
26
|
+
version: 4.7.0
|
|
27
27
|
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: carrot-top
|
|
28
29
|
requirement: !ruby/object:Gem::Requirement
|
|
29
30
|
requirements:
|
|
30
31
|
- - "~>"
|
|
31
32
|
- !ruby/object:Gem::Version
|
|
32
33
|
version: 0.0.7
|
|
33
|
-
name: carrot-top
|
|
34
|
-
prerelease: false
|
|
35
34
|
type: :runtime
|
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
-
requirements:
|
|
38
|
-
- - "~>"
|
|
39
|
-
- !ruby/object:Gem::Version
|
|
40
|
-
version: 0.0.7
|
|
41
|
-
- !ruby/object:Gem::Dependency
|
|
42
|
-
requirement: !ruby/object:Gem::Requirement
|
|
43
|
-
requirements:
|
|
44
|
-
- - "~>"
|
|
45
|
-
- !ruby/object:Gem::Version
|
|
46
|
-
version: '1.12'
|
|
47
|
-
name: multi_json
|
|
48
35
|
prerelease: false
|
|
49
|
-
type: :runtime
|
|
50
36
|
version_requirements: !ruby/object:Gem::Requirement
|
|
51
37
|
requirements:
|
|
52
38
|
- - "~>"
|
|
53
39
|
- !ruby/object:Gem::Version
|
|
54
|
-
version:
|
|
40
|
+
version: 0.0.7
|
|
55
41
|
- !ruby/object:Gem::Dependency
|
|
42
|
+
name: activesupport
|
|
56
43
|
requirement: !ruby/object:Gem::Requirement
|
|
57
44
|
requirements:
|
|
58
45
|
- - ">="
|
|
59
46
|
- !ruby/object:Gem::Version
|
|
60
47
|
version: '4.2'
|
|
61
|
-
- - "<"
|
|
62
|
-
- !ruby/object:Gem::Version
|
|
63
|
-
version: '6'
|
|
64
|
-
name: activesupport
|
|
65
|
-
prerelease: false
|
|
66
48
|
type: :runtime
|
|
49
|
+
prerelease: false
|
|
67
50
|
version_requirements: !ruby/object:Gem::Requirement
|
|
68
51
|
requirements:
|
|
69
52
|
- - ">="
|
|
70
53
|
- !ruby/object:Gem::Version
|
|
71
54
|
version: '4.2'
|
|
72
|
-
- - "<"
|
|
73
|
-
- !ruby/object:Gem::Version
|
|
74
|
-
version: '6'
|
|
75
55
|
description: Hutch is a Ruby library for enabling asynchronous inter-service communication
|
|
76
|
-
using RabbitMQ
|
|
77
|
-
email:
|
|
78
|
-
- developers@gocardless.com
|
|
56
|
+
using RabbitMQ
|
|
79
57
|
executables:
|
|
80
58
|
- hutch
|
|
81
59
|
extensions: []
|
|
82
60
|
extra_rdoc_files: []
|
|
83
61
|
files:
|
|
84
|
-
- ".gitignore"
|
|
85
|
-
- ".rspec"
|
|
86
|
-
- ".travis.yml"
|
|
87
|
-
- ".yardopts"
|
|
88
62
|
- CHANGELOG.md
|
|
89
|
-
- Gemfile
|
|
90
|
-
- Guardfile
|
|
91
63
|
- LICENSE
|
|
92
64
|
- README.md
|
|
93
|
-
-
|
|
65
|
+
- bin/ci/before_build.sh
|
|
66
|
+
- bin/ci/before_build_docker.sh
|
|
67
|
+
- bin/ci/install_on_debian.sh
|
|
94
68
|
- bin/hutch
|
|
95
|
-
- examples/consumer.rb
|
|
96
|
-
- examples/producer.rb
|
|
97
|
-
- hutch.gemspec
|
|
98
69
|
- lib/hutch.rb
|
|
99
70
|
- lib/hutch/acknowledgements/base.rb
|
|
100
71
|
- lib/hutch/acknowledgements/nack_on_all_failures.rb
|
|
@@ -107,9 +78,11 @@ files:
|
|
|
107
78
|
- lib/hutch/consumer.rb
|
|
108
79
|
- lib/hutch/error_handlers.rb
|
|
109
80
|
- lib/hutch/error_handlers/airbrake.rb
|
|
81
|
+
- lib/hutch/error_handlers/base.rb
|
|
82
|
+
- lib/hutch/error_handlers/bugsnag.rb
|
|
110
83
|
- lib/hutch/error_handlers/honeybadger.rb
|
|
111
84
|
- lib/hutch/error_handlers/logger.rb
|
|
112
|
-
- lib/hutch/error_handlers/
|
|
85
|
+
- lib/hutch/error_handlers/rollbar.rb
|
|
113
86
|
- lib/hutch/error_handlers/sentry.rb
|
|
114
87
|
- lib/hutch/exceptions.rb
|
|
115
88
|
- lib/hutch/logging.rb
|
|
@@ -118,9 +91,9 @@ files:
|
|
|
118
91
|
- lib/hutch/serializers/identity.rb
|
|
119
92
|
- lib/hutch/serializers/json.rb
|
|
120
93
|
- lib/hutch/tracers.rb
|
|
94
|
+
- lib/hutch/tracers/datadog.rb
|
|
121
95
|
- lib/hutch/tracers/newrelic.rb
|
|
122
96
|
- lib/hutch/tracers/null_tracer.rb
|
|
123
|
-
- lib/hutch/tracers/opbeat.rb
|
|
124
97
|
- lib/hutch/version.rb
|
|
125
98
|
- lib/hutch/waiter.rb
|
|
126
99
|
- lib/hutch/worker.rb
|
|
@@ -131,18 +104,20 @@ files:
|
|
|
131
104
|
- spec/hutch/config_spec.rb
|
|
132
105
|
- spec/hutch/consumer_spec.rb
|
|
133
106
|
- spec/hutch/error_handlers/airbrake_spec.rb
|
|
107
|
+
- spec/hutch/error_handlers/bugsnag_spec.rb
|
|
134
108
|
- spec/hutch/error_handlers/honeybadger_spec.rb
|
|
135
109
|
- spec/hutch/error_handlers/logger_spec.rb
|
|
136
|
-
- spec/hutch/error_handlers/
|
|
110
|
+
- spec/hutch/error_handlers/rollbar_spec.rb
|
|
137
111
|
- spec/hutch/error_handlers/sentry_spec.rb
|
|
138
112
|
- spec/hutch/logger_spec.rb
|
|
139
113
|
- spec/hutch/message_spec.rb
|
|
140
114
|
- spec/hutch/serializers/json_spec.rb
|
|
115
|
+
- spec/hutch/tracers/datadog_spec.rb
|
|
141
116
|
- spec/hutch/waiter_spec.rb
|
|
142
117
|
- spec/hutch/worker_spec.rb
|
|
143
118
|
- spec/hutch_spec.rb
|
|
144
|
-
- spec/
|
|
145
|
-
- spec/
|
|
119
|
+
- spec/integration/channel_recovery_spec.rb
|
|
120
|
+
- spec/integration/publish_consume_spec.rb
|
|
146
121
|
- templates/default/class/html/settings.erb
|
|
147
122
|
- templates/default/class/setup.rb
|
|
148
123
|
- templates/default/fulldoc/html/css/hutch.css
|
|
@@ -152,11 +127,10 @@ files:
|
|
|
152
127
|
- templates/default/method_details/text/settings.erb
|
|
153
128
|
- templates/default/module/html/settings.erb
|
|
154
129
|
- templates/default/module/setup.rb
|
|
155
|
-
homepage: https://github.com/
|
|
130
|
+
homepage: https://github.com/ruby-amqp/hutch
|
|
156
131
|
licenses:
|
|
157
132
|
- MIT
|
|
158
133
|
metadata: {}
|
|
159
|
-
post_install_message:
|
|
160
134
|
rdoc_options: []
|
|
161
135
|
require_paths:
|
|
162
136
|
- lib
|
|
@@ -164,33 +138,33 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
164
138
|
requirements:
|
|
165
139
|
- - ">="
|
|
166
140
|
- !ruby/object:Gem::Version
|
|
167
|
-
version: '2
|
|
141
|
+
version: '3.2'
|
|
168
142
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
169
143
|
requirements:
|
|
170
|
-
- - "
|
|
144
|
+
- - ">="
|
|
171
145
|
- !ruby/object:Gem::Version
|
|
172
|
-
version:
|
|
146
|
+
version: '0'
|
|
173
147
|
requirements: []
|
|
174
|
-
|
|
175
|
-
rubygems_version: 2.6.8
|
|
176
|
-
signing_key:
|
|
148
|
+
rubygems_version: 4.0.16
|
|
177
149
|
specification_version: 4
|
|
178
|
-
summary:
|
|
150
|
+
summary: Opinionated asynchronous inter-service communication using RabbitMQ
|
|
179
151
|
test_files:
|
|
180
152
|
- spec/hutch/broker_spec.rb
|
|
181
153
|
- spec/hutch/cli_spec.rb
|
|
182
154
|
- spec/hutch/config_spec.rb
|
|
183
155
|
- spec/hutch/consumer_spec.rb
|
|
184
156
|
- spec/hutch/error_handlers/airbrake_spec.rb
|
|
157
|
+
- spec/hutch/error_handlers/bugsnag_spec.rb
|
|
185
158
|
- spec/hutch/error_handlers/honeybadger_spec.rb
|
|
186
159
|
- spec/hutch/error_handlers/logger_spec.rb
|
|
187
|
-
- spec/hutch/error_handlers/
|
|
160
|
+
- spec/hutch/error_handlers/rollbar_spec.rb
|
|
188
161
|
- spec/hutch/error_handlers/sentry_spec.rb
|
|
189
162
|
- spec/hutch/logger_spec.rb
|
|
190
163
|
- spec/hutch/message_spec.rb
|
|
191
164
|
- spec/hutch/serializers/json_spec.rb
|
|
165
|
+
- spec/hutch/tracers/datadog_spec.rb
|
|
192
166
|
- spec/hutch/waiter_spec.rb
|
|
193
167
|
- spec/hutch/worker_spec.rb
|
|
194
168
|
- spec/hutch_spec.rb
|
|
195
|
-
- spec/
|
|
196
|
-
- spec/
|
|
169
|
+
- spec/integration/channel_recovery_spec.rb
|
|
170
|
+
- spec/integration/publish_consume_spec.rb
|
data/.gitignore
DELETED
data/.rspec
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
--order random
|
data/.travis.yml
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
language: ruby
|
|
2
|
-
cache: bundler
|
|
3
|
-
before_install:
|
|
4
|
-
- gem update --system
|
|
5
|
-
- gem install bundler
|
|
6
|
-
matrix:
|
|
7
|
-
include:
|
|
8
|
-
- rvm: 2.4.1
|
|
9
|
-
- rvm: 2.3.4
|
|
10
|
-
- rvm: 2.2.7
|
|
11
|
-
- rvm: 2.1
|
|
12
|
-
- rvm: 2.0
|
|
13
|
-
- rvm: jruby-9.1.12.0
|
|
14
|
-
jdk: oraclejdk8
|
|
15
|
-
env:
|
|
16
|
-
- JRUBY_OPTS='--debug'
|
|
17
|
-
|
|
18
|
-
services:
|
|
19
|
-
- rabbitmq
|
data/.yardopts
DELETED
data/Gemfile
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
source 'https://rubygems.org'
|
|
2
|
-
|
|
3
|
-
ruby RUBY_VERSION
|
|
4
|
-
|
|
5
|
-
gemspec
|
|
6
|
-
|
|
7
|
-
group :development do
|
|
8
|
-
gem "rake"
|
|
9
|
-
gem "guard", "~> 2.14", platform: :mri_23
|
|
10
|
-
gem "guard-rspec", "~> 4.7", platform: :mri_23
|
|
11
|
-
|
|
12
|
-
gem "yard", "~> 0.9"
|
|
13
|
-
gem 'kramdown', "> 0", platform: :jruby
|
|
14
|
-
gem "redcarpet", "> 0", platform: :mri
|
|
15
|
-
gem "github-markup", "> 0"
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
group :development, :test do
|
|
19
|
-
gem "rspec", "~> 3.5"
|
|
20
|
-
gem "simplecov", "~> 0.12"
|
|
21
|
-
|
|
22
|
-
gem "sentry-raven"
|
|
23
|
-
gem "honeybadger"
|
|
24
|
-
gem "coveralls", "~> 0.8.15", require: false
|
|
25
|
-
gem "newrelic_rpm"
|
|
26
|
-
gem "airbrake", "~> 5.0"
|
|
27
|
-
gem "opbeat", "~> 3.0.9"
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
group :development, :darwin do
|
|
31
|
-
gem "rb-fsevent", "~> 0.9"
|
|
32
|
-
gem "growl", "~> 1.0.3"
|
|
33
|
-
end
|
data/Guardfile
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
guard :rspec, cmd: "bundle exec rspec" do
|
|
2
|
-
require "guard/rspec/dsl"
|
|
3
|
-
dsl = Guard::RSpec::Dsl.new(self)
|
|
4
|
-
|
|
5
|
-
# RSpec files
|
|
6
|
-
rspec = dsl.rspec
|
|
7
|
-
watch(rspec.spec_helper) { rspec.spec_dir }
|
|
8
|
-
watch(rspec.spec_support) { rspec.spec_dir }
|
|
9
|
-
watch(rspec.spec_files)
|
|
10
|
-
|
|
11
|
-
# Ruby files
|
|
12
|
-
ruby = dsl.ruby
|
|
13
|
-
dsl.watch_spec_files_for(ruby.lib_files)
|
|
14
|
-
end
|
data/Rakefile
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
require 'rspec/core/rake_task'
|
|
2
|
-
|
|
3
|
-
desc "Run an IRB session with Hutch pre-loaded"
|
|
4
|
-
task :console do
|
|
5
|
-
exec "irb -I lib -r hutch"
|
|
6
|
-
end
|
|
7
|
-
|
|
8
|
-
desc "Run the test suite"
|
|
9
|
-
RSpec::Core::RakeTask.new(:spec) do |t|
|
|
10
|
-
t.pattern = FileList['spec/**/*_spec.rb']
|
|
11
|
-
t.rspec_opts = %w(--color --format doc)
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
task default: :spec
|
|
15
|
-
|
|
16
|
-
#
|
|
17
|
-
# Re-generate API docs
|
|
18
|
-
#
|
|
19
|
-
require 'yard'
|
|
20
|
-
require 'yard/rake/yardoc_task'
|
|
21
|
-
YARD::Rake::YardocTask.new
|
data/examples/consumer.rb
DELETED
data/examples/producer.rb
DELETED
data/hutch.gemspec
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
require File.expand_path('../lib/hutch/version', __FILE__)
|
|
2
|
-
|
|
3
|
-
Gem::Specification.new do |gem|
|
|
4
|
-
if defined?(JRUBY_VERSION)
|
|
5
|
-
gem.platform = 'java'
|
|
6
|
-
gem.add_runtime_dependency 'march_hare', '>= 3.0.0'
|
|
7
|
-
else
|
|
8
|
-
gem.platform = Gem::Platform::RUBY
|
|
9
|
-
gem.add_runtime_dependency 'bunny', '>= 2.7.0'
|
|
10
|
-
end
|
|
11
|
-
gem.add_runtime_dependency 'carrot-top', '~> 0.0.7'
|
|
12
|
-
gem.add_runtime_dependency 'multi_json', '~> 1.12'
|
|
13
|
-
gem.add_runtime_dependency 'activesupport', '>= 4.2', '< 6'
|
|
14
|
-
|
|
15
|
-
gem.name = 'hutch'
|
|
16
|
-
gem.summary = 'Easy inter-service communication using RabbitMQ.'
|
|
17
|
-
gem.description = 'Hutch is a Ruby library for enabling asynchronous ' \
|
|
18
|
-
'inter-service communication using RabbitMQ.'
|
|
19
|
-
gem.version = Hutch::VERSION.dup
|
|
20
|
-
gem.required_ruby_version = '>= 2.0'
|
|
21
|
-
gem.authors = ['Harry Marr']
|
|
22
|
-
gem.email = ['developers@gocardless.com']
|
|
23
|
-
gem.homepage = 'https://github.com/gocardless/hutch'
|
|
24
|
-
gem.require_paths = ['lib']
|
|
25
|
-
gem.license = 'MIT'
|
|
26
|
-
gem.executables = ['hutch']
|
|
27
|
-
gem.files = `git ls-files`.split("\n")
|
|
28
|
-
gem.test_files = `git ls-files -- spec/*`.split("\n")
|
|
29
|
-
end
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
require 'hutch/logging'
|
|
2
|
-
require 'opbeat'
|
|
3
|
-
|
|
4
|
-
module Hutch
|
|
5
|
-
module ErrorHandlers
|
|
6
|
-
class Opbeat
|
|
7
|
-
include Logging
|
|
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
|
-
end
|
|
23
|
-
end
|
|
24
|
-
end
|
data/lib/hutch/tracers/opbeat.rb
DELETED
|
@@ -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,22 +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
|
-
end
|
data/spec/spec_helper.rb
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
require 'simplecov'
|
|
2
|
-
if ENV['TRAVIS']
|
|
3
|
-
require 'coveralls'
|
|
4
|
-
SimpleCov.formatter = Coveralls::SimpleCov::Formatter
|
|
5
|
-
end
|
|
6
|
-
|
|
7
|
-
SimpleCov.start do
|
|
8
|
-
add_filter '/spec/'
|
|
9
|
-
add_filter '/.bundle/'
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
require 'raven'
|
|
13
|
-
require 'hutch'
|
|
14
|
-
require 'logger'
|
|
15
|
-
|
|
16
|
-
# set logger to be a null logger
|
|
17
|
-
Hutch::Logging.logger = Logger.new(File::NULL)
|
|
18
|
-
|
|
19
|
-
RSpec.configure do |config|
|
|
20
|
-
config.raise_errors_for_deprecations!
|
|
21
|
-
|
|
22
|
-
if defined?(JRUBY_VERSION)
|
|
23
|
-
config.filter_run_excluding adapter: :bunny
|
|
24
|
-
else
|
|
25
|
-
config.filter_run_excluding adapter: :march_hare
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
config.mock_with :rspec do |mocks|
|
|
29
|
-
mocks.verify_partial_doubles = true
|
|
30
|
-
end
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
# Constants (classes, etc) defined within a block passed to this method
|
|
34
|
-
# will be removed from the global namespace after the block as run.
|
|
35
|
-
def isolate_constants
|
|
36
|
-
existing_constants = Object.constants
|
|
37
|
-
yield
|
|
38
|
-
ensure
|
|
39
|
-
(Object.constants - existing_constants).each do |constant|
|
|
40
|
-
Object.send(:remove_const, constant)
|
|
41
|
-
end
|
|
42
|
-
end
|
data/spec/tracers/opbeat_spec.rb
DELETED
|
@@ -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
|