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 +5 -5
- data/CHANGELOG.md +6 -0
- data/Gemfile +2 -0
- data/lib/mnemosyne/probes/active_job/perform.rb +36 -0
- data/lib/mnemosyne/probes/grape/endpoint_run.rb +16 -1
- data/lib/mnemosyne/registry.rb +1 -6
- data/lib/mnemosyne/trace.rb +22 -9
- data/lib/mnemosyne/version.rb +1 -1
- data/lib/mnemosyne.rb +1 -0
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: b409992651786fbf3e023732bf1d745823aa6a82e547ef6a94f0cc0651942661
|
4
|
+
data.tar.gz: 927de0967e11668e64bc539cb776285432413cba49299fdacff0bfce11aafe0f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4dc45187bffa6fee59c62aafba5bd209c1e19d44d6dd4f9e0f860200ef247333174bb24b2b57fb4fa6d72324b4858c13af666c648bbe359c881fd209f02714fd
|
7
|
+
data.tar.gz: 15bcbfc123797b580e17ddadbf8b815edaaeb3fa7269e5333a10be6741c19e17a224c0e94959d76346f2d4459651a6a15d77ffb4fa779ad1578349bb52d49faa
|
data/CHANGELOG.md
CHANGED
data/Gemfile
CHANGED
@@ -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
|
data/lib/mnemosyne/registry.rb
CHANGED
@@ -18,12 +18,7 @@ module Mnemosyne
|
|
18
18
|
def installable?
|
19
19
|
return true unless class_name
|
20
20
|
|
21
|
-
|
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
|
data/lib/mnemosyne/trace.rb
CHANGED
@@ -22,7 +22,14 @@ module Mnemosyne
|
|
22
22
|
end
|
23
23
|
|
24
24
|
def attach_error(error)
|
25
|
-
|
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:
|
61
|
-
|
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
|
-
|
64
|
-
|
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
|
data/lib/mnemosyne/version.rb
CHANGED
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
|
+
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-
|
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.
|
130
|
+
rubygems_version: 2.7.2
|
130
131
|
signing_key:
|
131
132
|
specification_version: 4
|
132
133
|
summary: Ruby/Rails client for Mnemosyne APM
|