mnemosyne-ruby 1.4.0 → 1.5.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: f103ee3a06a19eb605a3cb19a97976320cc8db02
4
- data.tar.gz: 0855a77a9efbc497bb2173f857db77fd553b9dea
2
+ SHA256:
3
+ metadata.gz: b409992651786fbf3e023732bf1d745823aa6a82e547ef6a94f0cc0651942661
4
+ data.tar.gz: 927de0967e11668e64bc539cb776285432413cba49299fdacff0bfce11aafe0f
5
5
  SHA512:
6
- metadata.gz: fa7337ed893bc22a9e369c9467adb7235afa212ea9e849a28a1d6ed8b4cc8720c9c8709d751422020cce783e3735d79694146c535d05a89f9e1bea85edd60790
7
- data.tar.gz: 19c6b5de13c46b243a5f22c76548b812c360a88dff16ba59d13d9e0cecfe921149b063e6f4f6ce3ddb6b31ce4b0d43516c0b9ebf84267077587cc5abce4c108d
6
+ metadata.gz: 4dc45187bffa6fee59c62aafba5bd209c1e19d44d6dd4f9e0f860200ef247333174bb24b2b57fb4fa6d72324b4858c13af666c648bbe359c881fd209f02714fd
7
+ data.tar.gz: 15bcbfc123797b580e17ddadbf8b815edaaeb3fa7269e5333a10be6741c19e17a224c0e94959d76346f2d4459651a6a15d77ffb4fa779ad1578349bb52d49faa
data/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.5.0
4
+
5
+ * Add ActiveJob perform probe
6
+ * `attach_error` accepts errors without backtraces and string messages
7
+ * Capture endpoint names for grape web requests
8
+
3
9
  ## 1.4.0
4
10
 
5
11
  * Add global `#attach_error` for manual error reporting
data/Gemfile CHANGED
@@ -20,6 +20,8 @@ group :test do
20
20
  gem 'restify', require: false
21
21
  gem 'sidekiq', require: false
22
22
  gem 'webmock', require: false
23
+
24
+ gem 'rails', require: false
23
25
  end
24
26
 
25
27
  gem 'rubocop', '~> 0.50.0'
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Mnemosyne
4
+ module Probes
5
+ module ActiveJob
6
+ module Perform
7
+ class Probe < ::Mnemosyne::Probe
8
+ subscribe 'perform.active_job'
9
+
10
+ def call(trace, _name, start, finish, _id, payload)
11
+ start = ::Mnemosyne::Clock.to_tick(start)
12
+ finish = ::Mnemosyne::Clock.to_tick(finish)
13
+
14
+ job = payload[:job]
15
+
16
+ meta = {
17
+ id: job.job_id,
18
+ job: job.class.name,
19
+ arguments: job.arguments,
20
+ queue: job.queue_name
21
+ }
22
+
23
+ span = ::Mnemosyne::Span.new 'app.job.perform.active_job',
24
+ start: start, finish: finish, meta: meta
25
+
26
+ trace << span
27
+ end
28
+ end
29
+ end
30
+ end
31
+
32
+ register 'ActiveJob::Base',
33
+ 'active_job',
34
+ ActiveJob::Perform::Probe.new
35
+ end
36
+ end
@@ -14,11 +14,26 @@ module Mnemosyne
14
14
  endpoint = payload[:endpoint]
15
15
  return unless endpoint
16
16
 
17
+ meta = {
18
+ endpoint: extract_name(endpoint),
19
+ format: extract_format(payload[:env])
20
+ }
21
+
17
22
  span = ::Mnemosyne::Span.new 'app.controller.request.grape',
18
- start: start, finish: finish
23
+ start: start, finish: finish, meta: meta
19
24
 
20
25
  trace << span
21
26
  end
27
+
28
+ private
29
+
30
+ def extract_name(endpoint)
31
+ endpoint.options[:for].to_s
32
+ end
33
+
34
+ def extract_format(env)
35
+ env['api.format'.freeze]
36
+ end
22
37
  end
23
38
  end
24
39
  end
@@ -18,12 +18,7 @@ module Mnemosyne
18
18
  def installable?
19
19
  return true unless class_name
20
20
 
21
- begin
22
- Module.const_get(class_name).is_a?(Class) ||
23
- Module.const_get(class_name).is_a?(Module)
24
- rescue NameError
25
- false
26
- end
21
+ Module.const_defined?(class_name)
27
22
  end
28
23
 
29
24
  delegate install: :@probe
@@ -22,7 +22,14 @@ module Mnemosyne
22
22
  end
23
23
 
24
24
  def attach_error(error)
25
- @errors << Error.new(error)
25
+ case error
26
+ when Exception
27
+ @errors << Error.new(error)
28
+ when String
29
+ @errors << Error.new(RuntimeError.new(error))
30
+ else
31
+ raise ArgumentError.new "Invalid error type: #{error.inspect}"
32
+ end
26
33
  end
27
34
 
28
35
  def submit
@@ -52,19 +59,25 @@ module Mnemosyne
52
59
  Error = Struct.new(:error) do
53
60
  BT_REGEXP = /^((?:[a-zA-Z]:)?[^:]+):(\d+)(?::in `([^']+)')?$/
54
61
 
55
- # rubocop:disable AbcSize
56
62
  def serialize
57
63
  {
58
64
  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
65
+ text: error.message.to_s,
66
+ stacktrace: serialize_backtrace
67
+ }.compact
68
+ end
69
+
70
+ private
71
+
72
+ def serialize_backtrace
73
+ return unless error.backtrace
74
+
75
+ error.backtrace.map do |bt|
76
+ md = BT_REGEXP.match(bt.to_s).to_a
62
77
 
63
- {file: md[1], line: md[2], call: md[3], raw: md[0]}
64
- end
65
- }
78
+ {file: md[1], line: md[2], call: md[3], raw: md[0]}
79
+ end
66
80
  end
67
- # rubocop:enable all
68
81
  end
69
82
  end
70
83
  end
@@ -3,7 +3,7 @@
3
3
  module Mnemosyne
4
4
  module VERSION
5
5
  MAJOR = 1
6
- MINOR = 4
6
+ MINOR = 5
7
7
  PATCH = 0
8
8
  STAGE = nil
9
9
 
data/lib/mnemosyne.rb CHANGED
@@ -33,6 +33,7 @@ module Mnemosyne
33
33
  require 'mnemosyne/probes/action_dispatch/show_exceptions'
34
34
  require 'mnemosyne/probes/action_view/render_partial'
35
35
  require 'mnemosyne/probes/action_view/render_template'
36
+ require 'mnemosyne/probes/active_job/perform'
36
37
  require 'mnemosyne/probes/active_record/query'
37
38
  require 'mnemosyne/probes/grape/endpoint_render'
38
39
  require 'mnemosyne/probes/grape/endpoint_run'
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.4.0
4
+ version: 1.5.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-10-13 00:00:00.000000000 Z
11
+ date: 2017-11-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bunny
@@ -87,6 +87,7 @@ files:
87
87
  - lib/mnemosyne/probes/action_dispatch/show_exceptions.rb
88
88
  - lib/mnemosyne/probes/action_view/render_partial.rb
89
89
  - lib/mnemosyne/probes/action_view/render_template.rb
90
+ - lib/mnemosyne/probes/active_job/perform.rb
90
91
  - lib/mnemosyne/probes/active_record/query.rb
91
92
  - lib/mnemosyne/probes/grape/endpoint_render.rb
92
93
  - lib/mnemosyne/probes/grape/endpoint_run.rb
@@ -126,7 +127,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
126
127
  version: '0'
127
128
  requirements: []
128
129
  rubyforge_project:
129
- rubygems_version: 2.6.14
130
+ rubygems_version: 2.7.2
130
131
  signing_key:
131
132
  specification_version: 4
132
133
  summary: Ruby/Rails client for Mnemosyne APM