mnemosyne-ruby 1.2.0 → 1.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/lib/mnemosyne/client.rb +5 -4
- data/lib/mnemosyne/configuration.rb +0 -2
- data/lib/mnemosyne/instrumenter.rb +7 -21
- data/lib/mnemosyne/logging.rb +19 -0
- data/lib/mnemosyne/probe.rb +3 -3
- data/lib/mnemosyne/probes.rb +5 -1
- data/lib/mnemosyne/railtie.rb +3 -2
- data/lib/mnemosyne/registry.rb +11 -8
- data/lib/mnemosyne/version.rb +1 -1
- data/lib/mnemosyne-ruby.rb +3 -0
- data/lib/mnemosyne.rb +3 -0
- data/mnemosyne-ruby.gemspec +3 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fb0d5bc4abf9f3fbf32db3c4b38176059b4b3041
|
4
|
+
data.tar.gz: 3c088755475af2fb3317d770dbdffb053971257c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 83904f7bfc80eb52f9919df216d07302f6a134e517cd103c84c81450bf432f0ba6bf143f5a5b503357f5357f999f9a0285247050bad9a55a15ceda2e9d0c2129
|
7
|
+
data.tar.gz: 22d35f5acb70ac32b2dc7dac905116b0ea3c0aa06ac4d558764897e8c517bab5a12a9d174374bfa154ca974232e0c66f4fe6bdbea8f7e4267962b420164252a5
|
data/CHANGELOG.md
CHANGED
data/lib/mnemosyne/client.rb
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
require 'bunny'
|
3
4
|
|
4
5
|
module Mnemosyne
|
5
6
|
class Client
|
6
|
-
|
7
|
+
include ::Mnemosyne::Logging
|
7
8
|
|
8
9
|
def initialize(config)
|
9
10
|
@config = config
|
@@ -11,11 +12,11 @@ module Mnemosyne
|
|
11
12
|
|
12
13
|
def connection
|
13
14
|
@connection ||= begin
|
14
|
-
|
15
|
+
logger.info "[Mnemosyne] Connect to #{@config.server}..."
|
15
16
|
|
16
17
|
connection = ::Bunny.new @config.amqp,
|
17
|
-
logger:
|
18
|
-
|
18
|
+
logger: logger,
|
19
|
+
heartbeat: :server
|
19
20
|
|
20
21
|
connection.start
|
21
22
|
connection
|
@@ -11,7 +11,6 @@ module Mnemosyne
|
|
11
11
|
attr_reader :platform
|
12
12
|
attr_reader :amqp
|
13
13
|
attr_reader :exchange
|
14
|
-
attr_reader :logger
|
15
14
|
attr_reader :server
|
16
15
|
|
17
16
|
def initialize(config) # rubocop:disable AbcSize
|
@@ -19,7 +18,6 @@ module Mnemosyne
|
|
19
18
|
@application = config.fetch('application', nil).to_s.strip.freeze
|
20
19
|
@enabled = config.fetch('enabled', true)
|
21
20
|
@exchange = config.fetch('exchange', 'mnemosyne').to_s.freeze
|
22
|
-
@logger = config.fetch('logger') { Logger.new(STDOUT) }
|
23
21
|
|
24
22
|
hostname = config.fetch('hostname') { default_hostname }
|
25
23
|
@hostname = hostname.to_s.strip.freeze
|
@@ -7,16 +7,15 @@ module Mnemosyne
|
|
7
7
|
IDENT = :__mnemosyne_current_trace
|
8
8
|
MUTEX = Mutex.new
|
9
9
|
|
10
|
-
|
10
|
+
include ::Mnemosyne::Logging
|
11
11
|
|
12
|
-
def initialize(config:, client
|
12
|
+
def initialize(config:, client:)
|
13
13
|
@client = client
|
14
14
|
@config = config
|
15
|
-
@logger = logger
|
16
15
|
|
17
16
|
::Mnemosyne::Probes.activate!
|
18
17
|
|
19
|
-
logger.
|
18
|
+
logger.debug(Mnemosyne) { 'Instrumenter started' }
|
20
19
|
end
|
21
20
|
|
22
21
|
def current_trace
|
@@ -46,7 +45,7 @@ module Mnemosyne
|
|
46
45
|
end
|
47
46
|
|
48
47
|
def submit(trace)
|
49
|
-
logger.debug { "Submit trace #{trace.uuid}" }
|
48
|
+
logger.debug(Mnemosyne) { "Submit trace #{trace.uuid}" }
|
50
49
|
|
51
50
|
@client.call trace
|
52
51
|
end
|
@@ -67,17 +66,12 @@ module Mnemosyne
|
|
67
66
|
return @instance if @instance
|
68
67
|
|
69
68
|
client = Client.new(config)
|
70
|
-
logger = config.logger
|
71
69
|
|
72
|
-
@instance = new(config: config, client: client
|
70
|
+
@instance = new(config: config, client: client)
|
73
71
|
end
|
74
72
|
rescue => err
|
75
|
-
|
76
|
-
|
77
|
-
if config && config.respond_to?(:logger)
|
78
|
-
config.logger.warn message
|
79
|
-
else
|
80
|
-
::Kernel.warn message
|
73
|
+
::Mnemosyne::Logging.logger.warn(Mnemosyne) do
|
74
|
+
"Unable to start instrumenter: #{err}"
|
81
75
|
end
|
82
76
|
|
83
77
|
raise
|
@@ -97,14 +91,6 @@ module Mnemosyne
|
|
97
91
|
instrumenter.trace(*args)
|
98
92
|
end
|
99
93
|
|
100
|
-
def logger
|
101
|
-
if (instrumenter = instance)
|
102
|
-
instrumenter.logger
|
103
|
-
else
|
104
|
-
@logger ||= Logger.new($stdout)
|
105
|
-
end
|
106
|
-
end
|
107
|
-
|
108
94
|
def current_trace
|
109
95
|
return unless (instrumenter = instance)
|
110
96
|
instrumenter.current_trace
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Mnemosyne
|
4
|
+
module Logging
|
5
|
+
def logger
|
6
|
+
::Mnemosyne::Logging.logger
|
7
|
+
end
|
8
|
+
|
9
|
+
class << self
|
10
|
+
attr_writer :logger
|
11
|
+
|
12
|
+
def logger
|
13
|
+
@logger ||= ::Logger.new($stdout).tap do |logger|
|
14
|
+
logger.level = ::Logger::INFO
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
data/lib/mnemosyne/probe.rb
CHANGED
@@ -2,6 +2,8 @@
|
|
2
2
|
|
3
3
|
module Mnemosyne
|
4
4
|
class Probe
|
5
|
+
include ::Mnemosyne::Logging
|
6
|
+
|
5
7
|
def install
|
6
8
|
setup
|
7
9
|
|
@@ -14,9 +16,7 @@ module Mnemosyne
|
|
14
16
|
end
|
15
17
|
end
|
16
18
|
|
17
|
-
|
18
|
-
"Installed probe #{self.class.name}"
|
19
|
-
end
|
19
|
+
logger.debug(Mnemosyne) { "Installed probe #{self.class.name}" }
|
20
20
|
end
|
21
21
|
|
22
22
|
def setup
|
data/lib/mnemosyne/probes.rb
CHANGED
@@ -11,6 +11,10 @@ module Mnemosyne
|
|
11
11
|
registry.activate!
|
12
12
|
end
|
13
13
|
|
14
|
+
def required(path)
|
15
|
+
registry.required(path)
|
16
|
+
end
|
17
|
+
|
14
18
|
private
|
15
19
|
|
16
20
|
def registry
|
@@ -27,7 +31,7 @@ module Kernel
|
|
27
31
|
ret = require_without_mn(name)
|
28
32
|
|
29
33
|
begin
|
30
|
-
::Mnemosyne::Probes.
|
34
|
+
::Mnemosyne::Probes.required(name)
|
31
35
|
rescue Exception # rubocop:disable RescueException, HandleExceptions
|
32
36
|
end
|
33
37
|
|
data/lib/mnemosyne/railtie.rb
CHANGED
@@ -7,8 +7,9 @@ module Mnemosyne
|
|
7
7
|
initializer 'mnemosyne.initialize' do |app|
|
8
8
|
config = app.config_for('mnemosyne')
|
9
9
|
|
10
|
+
::Mnemosyne::Logging.logger = Rails.logger
|
11
|
+
|
10
12
|
config['application'] ||= app.class.name.underscore.titleize
|
11
|
-
config['logger'] ||= Rails.logger
|
12
13
|
|
13
14
|
# If server is configured mnemosyne should be enabled by default
|
14
15
|
config['enabled'] = config.key?('server') unless config.key?('enabled')
|
@@ -20,7 +21,7 @@ module Mnemosyne
|
|
20
21
|
|
21
22
|
app.middleware.insert 0, ::Mnemosyne::Middleware::Rack
|
22
23
|
else
|
23
|
-
|
24
|
+
Rails.logger.warn(Mnemosyne) { 'Instrumentation disabled' }
|
24
25
|
end
|
25
26
|
end
|
26
27
|
end
|
data/lib/mnemosyne/registry.rb
CHANGED
@@ -53,6 +53,12 @@ module Mnemosyne
|
|
53
53
|
activate(registration) if activated?
|
54
54
|
end
|
55
55
|
|
56
|
+
def required(path)
|
57
|
+
return unless activated?
|
58
|
+
return unless (set = monitor.delete(path))
|
59
|
+
set.each(&method(:activate))
|
60
|
+
end
|
61
|
+
|
56
62
|
private
|
57
63
|
|
58
64
|
attr_reader :monitor
|
@@ -67,19 +73,16 @@ module Mnemosyne
|
|
67
73
|
|
68
74
|
class Monitor
|
69
75
|
def initialize
|
70
|
-
@requirements = {}
|
76
|
+
@requirements = Hash.new {|h, k| h[k] = Set.new }
|
71
77
|
end
|
72
78
|
|
73
|
-
def
|
74
|
-
|
75
|
-
@requirements[path] ||= []
|
76
|
-
@requirements[path] << registration
|
77
|
-
end
|
79
|
+
def delete(path)
|
80
|
+
@requirements.delete(path)
|
78
81
|
end
|
79
82
|
|
80
|
-
def
|
83
|
+
def <<(registration)
|
81
84
|
registration.require_paths.each do |path|
|
82
|
-
@requirements[path]
|
85
|
+
@requirements[path] << registration
|
83
86
|
end
|
84
87
|
end
|
85
88
|
end
|
data/lib/mnemosyne/version.rb
CHANGED
data/lib/mnemosyne-ruby.rb
CHANGED
data/lib/mnemosyne.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
require 'mnemosyne/version'
|
3
4
|
|
4
5
|
require 'active_support'
|
@@ -6,6 +7,8 @@ require 'active_support/core_ext/object/blank'
|
|
6
7
|
require 'active_support/notifications'
|
7
8
|
|
8
9
|
module Mnemosyne
|
10
|
+
require 'mnemosyne/logging'
|
11
|
+
|
9
12
|
require 'mnemosyne/global'
|
10
13
|
extend Global
|
11
14
|
|
data/mnemosyne-ruby.gemspec
CHANGED
@@ -14,7 +14,9 @@ Gem::Specification.new do |spec|
|
|
14
14
|
spec.homepage = 'http://github.com/jgraichen/mnemosyne-ruby'
|
15
15
|
spec.license = 'MIT'
|
16
16
|
|
17
|
-
spec.files = `git ls-files -z`.split("\x0").reject
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
18
|
+
f.match(%r{^(test|spec|features)/})
|
19
|
+
end
|
18
20
|
spec.bindir = 'bin'
|
19
21
|
spec.executables = spec.files.grep(%r{^exe/}) {|f| File.basename(f) }
|
20
22
|
spec.require_paths = %w(lib)
|
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.
|
4
|
+
version: 1.2.1
|
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-09-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bunny
|
@@ -131,6 +131,7 @@ files:
|
|
131
131
|
- lib/mnemosyne/configuration.rb
|
132
132
|
- lib/mnemosyne/global.rb
|
133
133
|
- lib/mnemosyne/instrumenter.rb
|
134
|
+
- lib/mnemosyne/logging.rb
|
134
135
|
- lib/mnemosyne/middleware/acfs.rb
|
135
136
|
- lib/mnemosyne/middleware/rack.rb
|
136
137
|
- lib/mnemosyne/middleware/sidekiq.rb
|
@@ -180,7 +181,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
180
181
|
version: '0'
|
181
182
|
requirements: []
|
182
183
|
rubyforge_project:
|
183
|
-
rubygems_version: 2.6.
|
184
|
+
rubygems_version: 2.6.13
|
184
185
|
signing_key:
|
185
186
|
specification_version: 4
|
186
187
|
summary: Ruby/Rails client for Mnemosynce
|