mnemosyne-ruby 1.2.1 → 1.3.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
2
  SHA1:
3
- metadata.gz: fb0d5bc4abf9f3fbf32db3c4b38176059b4b3041
4
- data.tar.gz: 3c088755475af2fb3317d770dbdffb053971257c
3
+ metadata.gz: 0dd6477917eee07e244adbce53f2f07b23ee2a8a
4
+ data.tar.gz: 6bfaf7fa6a1a5beb52ccedc769ceb72483dd7d1e
5
5
  SHA512:
6
- metadata.gz: 83904f7bfc80eb52f9919df216d07302f6a134e517cd103c84c81450bf432f0ba6bf143f5a5b503357f5357f999f9a0285247050bad9a55a15ceda2e9d0c2129
7
- data.tar.gz: 22d35f5acb70ac32b2dc7dac905116b0ea3c0aa06ac4d558764897e8c517bab5a12a9d174374bfa154ca974232e0c66f4fe6bdbea8f7e4267962b420164252a5
6
+ metadata.gz: 3cf8bf8db8c95be6c4a40e7ad68d7303a49737c46f405d6bb67e282b7bf32371038d8a0c274df94f4476158605fd5470308f13af0b3fedc480a3af3df294aa38
7
+ data.tar.gz: 24fbef4b46867c7511611e1152cdd4ddd5616ffb2f7a7434332ed57288fc5fbaf8f7d16cef65b69f55c5efebd57891a7b831135a972f539a4746a6f8859ea305
data/.travis.yml CHANGED
@@ -1,14 +1,29 @@
1
1
  language: ruby
2
2
  cache: bundler
3
+ sudo: required
4
+ services:
5
+ - rabbitmq
3
6
  rvm:
4
- - '2.4.0'
5
- - '2.3.3'
6
- - '2.2.6'
7
+ - 2.4.2
8
+ - 2.3.4
9
+ - 2.2.6
7
10
  before_install:
8
- - gem update --system
9
- - gem install bundler
11
+ - gem update --system
12
+ - gem install bundler
10
13
  script:
11
- - bundle exec rake rubocop
12
- - bundle exec rake spec
13
- matrix:
14
- fast_finish: true
14
+ - bundle exec rake rubocop
15
+ - bundle exec rake spec
16
+ jobs:
17
+ include:
18
+ - stage: Release
19
+ rvm: 2.4.2
20
+ install: skip
21
+ script: skip
22
+ deploy:
23
+ provider: rubygems
24
+ api_key:
25
+ secure: GDEAmZLPOYQOsMJRrAcyRIrdOdbkZ5iM0Z9OHjxMwLkHtnR8XcfjNzPdXEji6o1nQaS3PfcLIdpEmis6FJqT4aXRU0F/1VwHAgiYIe3NWs5rFEo2dWS0ScfeQJQ1rY2inq/ayp3r01/eUTVVwhks8hresBlZrT6HR2Jub300lkhJQoAwHB44cekTZrv3PSTpyMhHOBUjk8bpx2m0n/dGM3lOYlAnaL4DA1l6/JdoYNS3hbyphZFnymS4cl5QIxF6NRNlC6uEzmZ0Hr4dK0amnBwUeillqxgAWiYQXyj/do7r1iXdrtORidIb3QfGAhsuxZY9Cu6+E8CfhwvnnY5ElpGrDvlVTBV4hyfudsRq87QwTS64c62dQ7s1cvcMxJcYMfWDyaFkYmGoXN0QCrN9M9JhrXh8sLKAFQIMsc2kH8dyuhlIJXvIZVzdxtey8geOYBwalB8DJl7BM/nbG/LuEagpahJco4k0/+3KDxxMFRplMG4ShkOw/otousiVlsu7idszpgxuVPrVAwAbhIPxJV0i1Ak0Vt/nohkR2DOxdf4E40jDrP2d2A4DMVKU8R92BDH8Qj/nle20TeL/Wx2/3mLBAIH+stUtKILnpwoWEfVhe+Ys3LLEaDtYBLcOr4W9czlFH43GxctbBMiadVQAVBQOIUOTkA84gADFLCIOCA0=
26
+ gem: mnemosyne-ruby
27
+ on:
28
+ tags: true
29
+ repo: jgraichen/mnemosyne-ruby
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.3.0
4
+
5
+ * Add exception serialization to trace and protocol
6
+ * Add exception reporting to Sidekiq, Msgr, Rack and Rails
7
+
3
8
  ## 1.2.1
4
9
 
5
10
  * Improve AMQP connection recovery
data/Gemfile CHANGED
@@ -11,7 +11,10 @@ group :development, :test do
11
11
  end
12
12
 
13
13
  group :test do
14
+ gem 'msgr', require: false
14
15
  gem 'restify', require: false
15
16
  gem 'sidekiq', require: false
16
17
  gem 'webmock', require: false
17
18
  end
19
+
20
+ gem 'rubocop', '~> 0.50.0'
data/lib/mnemosyne.rb CHANGED
@@ -30,6 +30,7 @@ module Mnemosyne
30
30
  require 'mnemosyne/probes/acfs/request'
31
31
  require 'mnemosyne/probes/action_controller/process_action'
32
32
  require 'mnemosyne/probes/action_controller/renderers'
33
+ require 'mnemosyne/probes/action_dispatch/show_exceptions'
33
34
  require 'mnemosyne/probes/action_view/render_partial'
34
35
  require 'mnemosyne/probes/action_view/render_template'
35
36
  require 'mnemosyne/probes/active_record/query'
@@ -4,9 +4,9 @@ module Mnemosyne
4
4
  module Middleware
5
5
  class Rack
6
6
  class Proxy
7
- def initialize(body, &block)
7
+ def initialize(body, trace)
8
8
  @body = body
9
- @block = block
9
+ @trace = trace
10
10
  @closed = false
11
11
  end
12
12
 
@@ -33,7 +33,7 @@ module Mnemosyne
33
33
  begin
34
34
  @body.close if @body.respond_to? :close
35
35
  ensure
36
- @block.call
36
+ @trace.submit
37
37
  end
38
38
  end
39
39
 
@@ -42,11 +42,10 @@ module Mnemosyne
42
42
  end
43
43
 
44
44
  def each(*args)
45
- if block_given?
46
- @body.each(*args, &Proc.new)
47
- else
48
- @body.each(*args)
49
- end
45
+ @body.each(*args, &Proc.new)
46
+ rescue StandardError, LoadError, SyntaxError => e
47
+ @trace.attach_error(e)
48
+ raise
50
49
  end
51
50
  end
52
51
 
@@ -73,13 +72,17 @@ module Mnemosyne
73
72
 
74
73
  scan_response(trace, response)
75
74
 
76
- response[2] = Proxy.new(response[2]) { trace.submit }
75
+ response[2] = Proxy.new(response[2], trace)
77
76
  response
78
77
  else
79
78
  @app.call env
80
79
  end
81
- rescue Exception # rubocop:disable RescueException
82
- trace.submit if trace
80
+ rescue StandardError, LoadError, SyntaxError => e
81
+ if trace
82
+ trace.attach_error(e)
83
+ trace.submit
84
+ end
85
+
83
86
  raise
84
87
  ensure
85
88
  trace.release if trace
@@ -22,6 +22,9 @@ module Mnemosyne
22
22
  trace.start! if trace
23
23
 
24
24
  yield
25
+ rescue StandardError, LoadError, SyntaxError => err # rubocop:disable RescueException
26
+ trace.attach_error(err)
27
+ raise
25
28
  ensure
26
29
  if trace
27
30
  trace.submit
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Mnemosyne
4
+ module Probes
5
+ module ActionDispatch
6
+ module ShowExceptions
7
+ class Probe < ::Mnemosyne::Probe
8
+ def setup
9
+ ::ActionDispatch::ShowExceptions.send :prepend, Instrumentation
10
+ end
11
+
12
+ module Instrumentation
13
+ def render_exception(env, exception)
14
+ if (trace = ::Mnemosyne::Instrumenter.current_trace)
15
+ trace.attach_error(exception)
16
+ end
17
+
18
+ super
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
24
+
25
+ register 'ActionDispatch::ShowExceptions',
26
+ 'action_dispatch/middleware/show_exceptions',
27
+ ActionDispatch::ShowExceptions::Probe.new
28
+ end
29
+ end
@@ -56,6 +56,9 @@ module Mnemosyne
56
56
  end
57
57
 
58
58
  super
59
+ rescue StandardError, LoadError, SyntaxError => e
60
+ trace.attach_error(e) if trace
61
+ raise
59
62
  ensure
60
63
  if trace
61
64
  trace.submit
@@ -2,13 +2,14 @@
2
2
 
3
3
  module Mnemosyne
4
4
  class Trace < Span
5
- attr_reader :uuid, :transaction, :origin, :span
5
+ attr_reader :uuid, :transaction, :origin, :span, :errors
6
6
 
7
7
  def initialize(instrumenter, name, transaction: nil, origin: nil, **kwargs)
8
8
  super(name, **kwargs)
9
9
 
10
- @uuid = ::SecureRandom.uuid
11
- @span = []
10
+ @uuid = ::SecureRandom.uuid
11
+ @span = []
12
+ @errors = []
12
13
 
13
14
  @origin = origin
14
15
  @transaction = transaction
@@ -20,6 +21,10 @@ module Mnemosyne
20
21
  @span << span
21
22
  end
22
23
 
24
+ def attach_error(error)
25
+ @errors << Error.new(error)
26
+ end
27
+
23
28
  def submit
24
29
  finish! unless finish
25
30
 
@@ -39,8 +44,27 @@ module Mnemosyne
39
44
  start: start,
40
45
  stop: finish,
41
46
  meta: meta,
42
- span: @span.map(&:serialize)
47
+ span: @span.map(&:serialize),
48
+ errors: @errors.map(&:serialize)
43
49
  }
44
50
  end
51
+
52
+ Error = Struct.new(:error) do
53
+ BT_REGEXP = /^((?:[a-zA-Z]:)?[^:]+):(\d+)(?::in `([^']+)')?$/
54
+
55
+ # rubocop:disable AbcSize
56
+ def serialize
57
+ {
58
+ type: error.class.name,
59
+ text: error.message,
60
+ stacktrace: error.backtrace.map do |bt|
61
+ md = BT_REGEXP.match(bt.to_s).to_a
62
+
63
+ {file: md[1], line: md[2], call: md[3], raw: md[0]}
64
+ end
65
+ }
66
+ end
67
+ # rubocop:enable all
68
+ end
45
69
  end
46
70
  end
@@ -3,8 +3,8 @@
3
3
  module Mnemosyne
4
4
  module VERSION
5
5
  MAJOR = 1
6
- MINOR = 2
7
- PATCH = 1
6
+ MINOR = 3
7
+ PATCH = 0
8
8
  STAGE = nil
9
9
 
10
10
  STRING = [MAJOR, MINOR, PATCH, STAGE].reject(&:nil?).join('.')
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mnemosyne-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.1
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jan Graichen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-09-20 00:00:00.000000000 Z
11
+ date: 2017-10-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bunny
@@ -140,6 +140,7 @@ files:
140
140
  - lib/mnemosyne/probes/acfs/request.rb
141
141
  - lib/mnemosyne/probes/action_controller/process_action.rb
142
142
  - lib/mnemosyne/probes/action_controller/renderers.rb
143
+ - lib/mnemosyne/probes/action_dispatch/show_exceptions.rb
143
144
  - lib/mnemosyne/probes/action_view/render_partial.rb
144
145
  - lib/mnemosyne/probes/action_view/render_template.rb
145
146
  - lib/mnemosyne/probes/active_record/query.rb