tracebin 0.0.7 → 0.0.8
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 +4 -4
- data/Gemfile +1 -1
- data/README.md +4 -4
- data/bin/console +1 -1
- data/lib/{vizsla → tracebin}/agent.rb +11 -11
- data/lib/tracebin/background_job_instrumentation/active_job.rb +14 -0
- data/lib/tracebin/background_job_instrumentation/resque.rb +37 -0
- data/lib/{vizsla → tracebin}/background_job_instrumentation/sidekiq.rb +3 -3
- data/lib/{vizsla → tracebin}/background_job_instrumentation.rb +6 -6
- data/lib/tracebin/background_timer.rb +9 -0
- data/lib/{vizsla → tracebin}/config.rb +2 -2
- data/lib/{vizsla → tracebin}/events.rb +3 -3
- data/lib/{vizsla → tracebin}/health_monitor.rb +3 -3
- data/lib/{vizsla → tracebin}/helpers.rb +1 -1
- data/lib/{vizsla → tracebin}/logger.rb +2 -2
- data/lib/{vizsla → tracebin}/middleware.rb +5 -5
- data/lib/{vizsla → tracebin}/patches/action_view_layout.rb +1 -1
- data/lib/{vizsla → tracebin}/patches/mysql2.rb +3 -3
- data/lib/{vizsla → tracebin}/patches/postgres.rb +6 -6
- data/lib/tracebin/patches/sidekiq_health.rb +27 -0
- data/lib/{vizsla → tracebin}/patches/sinatra.rb +3 -3
- data/lib/{vizsla → tracebin}/patches.rb +5 -5
- data/lib/{vizsla → tracebin}/puppet_master.rb +4 -4
- data/lib/{vizsla → tracebin}/recorder.rb +2 -2
- data/lib/{vizsla → tracebin}/reporter.rb +23 -16
- data/lib/{vizsla → tracebin}/storage.rb +1 -1
- data/lib/{vizsla → tracebin}/subscribers.rb +12 -13
- data/lib/{vizsla → tracebin}/system_health_sample.rb +1 -1
- data/lib/{vizsla → tracebin}/timer.rb +4 -5
- data/lib/tracebin/version.rb +3 -0
- data/lib/{vizsla → tracebin}/worker_process_monitor.rb +5 -5
- data/lib/tracebin.rb +17 -0
- data/{vizsla.gemspec → tracebin.gemspec} +2 -2
- metadata +31 -31
- data/lib/vizsla/background_job_instrumentation/active_job.rb +0 -14
- data/lib/vizsla/background_job_instrumentation/resque.rb +0 -37
- data/lib/vizsla/background_timer.rb +0 -9
- data/lib/vizsla/patches/sidekiq_health.rb +0 -27
- data/lib/vizsla/version.rb +0 -3
- data/lib/vizsla.rb +0 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 632b0078b17a6e931957ef7c68fa6618633bc798
|
4
|
+
data.tar.gz: e9dfe8944b070c402683a50e5d39664f07c1c5dc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7e7873a9d6d04088225e0f39b8d3fa7b6fc92cd202a055a535d828968beda8c2c0f87fec5135e1853c5e975d81294523411263ddcd2f199cf16a32d7d6f3d4e8
|
7
|
+
data.tar.gz: 47c77b5ccdb964e95e35999e821d646b0a468c074c8d1161f69b6e4638be9265baf60d013003e7b3efac823cf336d753a5e1012ad269d043af3b1abe898827cf
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,11 +1,11 @@
|
|
1
|
-
#
|
1
|
+
# tracebin-ruby
|
2
2
|
|
3
3
|
## Installation
|
4
4
|
|
5
5
|
Add this line to your application's Gemfile:
|
6
6
|
|
7
7
|
```ruby
|
8
|
-
gem '
|
8
|
+
gem 'tracebin'
|
9
9
|
```
|
10
10
|
|
11
11
|
And then execute:
|
@@ -14,7 +14,7 @@ And then execute:
|
|
14
14
|
|
15
15
|
Or install it yourself as:
|
16
16
|
|
17
|
-
$ gem install
|
17
|
+
$ gem install tracebin
|
18
18
|
|
19
19
|
## Usage
|
20
20
|
|
@@ -28,7 +28,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
28
28
|
|
29
29
|
## Contributing
|
30
30
|
|
31
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
31
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/tracebin/tracebin-ruby. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
32
32
|
|
33
33
|
|
34
34
|
## License
|
data/bin/console
CHANGED
@@ -1,18 +1,18 @@
|
|
1
1
|
require 'logger'
|
2
2
|
|
3
|
-
require '
|
4
|
-
require '
|
5
|
-
require '
|
6
|
-
require '
|
7
|
-
require '
|
3
|
+
require 'tracebin/subscribers'
|
4
|
+
require 'tracebin/health_monitor'
|
5
|
+
require 'tracebin/worker_process_monitor'
|
6
|
+
require 'tracebin/storage'
|
7
|
+
require 'tracebin/reporter'
|
8
8
|
|
9
|
-
module
|
9
|
+
module Tracebin
|
10
10
|
module Agent
|
11
11
|
class << self
|
12
12
|
attr_accessor :config, :storage, :logger
|
13
13
|
|
14
14
|
def start!
|
15
|
-
logger.info "Starting
|
15
|
+
logger.info "TRACEBIN: Starting Tracebin agent..."
|
16
16
|
|
17
17
|
@subscribers = Subscribers.new
|
18
18
|
@health_monitor = HealthMonitor.start
|
@@ -22,11 +22,11 @@ module Vizsla
|
|
22
22
|
|
23
23
|
@reporter.start!
|
24
24
|
|
25
|
-
logger.info "
|
25
|
+
logger.info "TRACEBIN: Tracebin agent started!"
|
26
26
|
end
|
27
27
|
|
28
28
|
def stop!
|
29
|
-
logger.info "Shutting down
|
29
|
+
logger.info "TRACEBIN: Shutting down Tracebin agent..."
|
30
30
|
|
31
31
|
@health_monitor.stop!
|
32
32
|
@worker_process_monitor.stop!
|
@@ -34,7 +34,7 @@ module Vizsla
|
|
34
34
|
|
35
35
|
@started = false
|
36
36
|
|
37
|
-
logger.info "
|
37
|
+
logger.info "TRACEBIN: Tracebin agent stopped!"
|
38
38
|
end
|
39
39
|
|
40
40
|
def started?
|
@@ -69,7 +69,7 @@ module Vizsla
|
|
69
69
|
end
|
70
70
|
|
71
71
|
def self.storage
|
72
|
-
@storage ||= ::
|
72
|
+
@storage ||= ::Tracebin::Storage.new
|
73
73
|
end
|
74
74
|
|
75
75
|
def self.config
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'tracebin/background_timer'
|
2
|
+
require 'tracebin/puppet_master'
|
3
|
+
|
4
|
+
if defined? ::ActiveJob::Base
|
5
|
+
::ActiveJob::Base.around_perform do |job, block|
|
6
|
+
@tracebin_timer = ::Tracebin::BackgroundTimer.new job.class.name.split('::').last
|
7
|
+
@tracebin_timer.start!
|
8
|
+
|
9
|
+
block.call
|
10
|
+
|
11
|
+
@tracebin_timer.stop!
|
12
|
+
::Tracebin::PuppetMaster.new(@tracebin_timer).process
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'tracebin/background_timer'
|
2
|
+
require 'tracebin/puppet_master'
|
3
|
+
|
4
|
+
module Resque
|
5
|
+
module Plugins
|
6
|
+
module TracebinInstrumentation
|
7
|
+
module Job
|
8
|
+
def before_perform_with_tracebin(*args)
|
9
|
+
@tracebin_timer = ::Tracebin::BackgroundTimer.new
|
10
|
+
@tracebin_timer.start!
|
11
|
+
|
12
|
+
yield *args if block_given?
|
13
|
+
end
|
14
|
+
|
15
|
+
def after_perform_with_tracebin(*args)
|
16
|
+
@tracebin_timer.stop!
|
17
|
+
::Tracebin::PuppetMaster.new(@tracebin_timer, logger: Resque.logger).process
|
18
|
+
|
19
|
+
yield *args if block_given?
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
module Tracebin
|
27
|
+
module BackgroundJobInstrumentation
|
28
|
+
module ResqueInstrumentationInstaller
|
29
|
+
def payload_class
|
30
|
+
klass = super
|
31
|
+
klass.instance_eval do
|
32
|
+
extend ::Resque::Plugins::TracebinInstrumentation::Job
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -1,7 +1,7 @@
|
|
1
|
-
require '
|
2
|
-
require '
|
1
|
+
require 'tracebin/background_timer'
|
2
|
+
require 'tracebin/puppet_master'
|
3
3
|
|
4
|
-
module
|
4
|
+
module Tracebin
|
5
5
|
module BackgroundJobInstrumentation
|
6
6
|
class Sidekiq
|
7
7
|
def call(worker, msg, queue, *args)
|
@@ -1,4 +1,4 @@
|
|
1
|
-
module
|
1
|
+
module Tracebin
|
2
2
|
module BackgroundJobInstrumentation
|
3
3
|
def self.install(inst_name)
|
4
4
|
self.send inst_name
|
@@ -7,28 +7,28 @@ module Vizsla
|
|
7
7
|
private
|
8
8
|
|
9
9
|
def self.sidekiq
|
10
|
-
require '
|
10
|
+
require 'tracebin/background_job_instrumentation/sidekiq'
|
11
11
|
|
12
12
|
::Sidekiq.configure_server do |config|
|
13
13
|
config.server_middleware do |chain|
|
14
|
-
chain.add ::
|
14
|
+
chain.add ::Tracebin::BackgroundJobInstrumentation::Sidekiq
|
15
15
|
end
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
19
19
|
def self.resque
|
20
|
-
require '
|
20
|
+
require 'tracebin/background_job_instrumentation/resque'
|
21
21
|
|
22
22
|
::Resque::Job.class_eval do
|
23
23
|
def self.new(*args)
|
24
|
-
super(*args).extend ::
|
24
|
+
super(*args).extend ::Tracebin::BackgroundJobInstrumentation::
|
25
25
|
ResqueInstrumentationInstaller
|
26
26
|
end
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
30
30
|
def self.active_job
|
31
|
-
require '
|
31
|
+
require 'tracebin/background_job_instrumentation/active_job'
|
32
32
|
end
|
33
33
|
end
|
34
34
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
module
|
1
|
+
module Tracebin
|
2
2
|
class RequestLogger
|
3
3
|
def initialize(logger_override = nil)
|
4
4
|
@logger_override = logger_override
|
@@ -25,7 +25,7 @@ module Vizsla
|
|
25
25
|
if ele.is_a? Hash
|
26
26
|
str_append_hash str, ele, bumper + ' '
|
27
27
|
else
|
28
|
-
str << "#{bumper}#{ele}"
|
28
|
+
str << "#{bumper}#{ele}\n"
|
29
29
|
end
|
30
30
|
end
|
31
31
|
else
|
@@ -1,15 +1,15 @@
|
|
1
|
-
require '
|
2
|
-
require '
|
1
|
+
require 'tracebin/timer'
|
2
|
+
require 'tracebin/puppet_master'
|
3
3
|
|
4
|
-
module
|
4
|
+
module Tracebin
|
5
5
|
class Middleware
|
6
6
|
attr_reader :config
|
7
7
|
|
8
8
|
def initialize(app)
|
9
9
|
@app = app
|
10
|
-
@config =
|
10
|
+
@config = Tracebin::Agent.config
|
11
11
|
|
12
|
-
|
12
|
+
Tracebin::Agent.start! unless Tracebin::Agent.started?
|
13
13
|
end
|
14
14
|
|
15
15
|
def call(env)
|
@@ -1,9 +1,9 @@
|
|
1
1
|
::Mysql2::Client.class_eval do
|
2
|
-
alias_method :
|
2
|
+
alias_method :query_without_tracebin, :query
|
3
3
|
|
4
4
|
def query(*args, &block)
|
5
5
|
start_time = Time.now
|
6
|
-
result =
|
6
|
+
result = query_without_tracebin(*args, &block)
|
7
7
|
end_time = Time.now
|
8
8
|
|
9
9
|
event_data = [
|
@@ -15,7 +15,7 @@
|
|
15
15
|
}
|
16
16
|
]
|
17
17
|
|
18
|
-
::
|
18
|
+
::Tracebin::Patches.handle_event :mysql2, event_data
|
19
19
|
|
20
20
|
result
|
21
21
|
end
|
@@ -1,10 +1,10 @@
|
|
1
1
|
::PG::Connection.class_eval do
|
2
|
-
alias_method :
|
3
|
-
alias_method :
|
2
|
+
alias_method :exec_without_tracebin, :exec
|
3
|
+
alias_method :exec_params_without_tracebin, :exec_params
|
4
4
|
|
5
5
|
def exec_params(*args, &block)
|
6
6
|
start_time = Time.now
|
7
|
-
result =
|
7
|
+
result = exec_params_without_tracebin(*args, &block)
|
8
8
|
end_time = Time.now
|
9
9
|
|
10
10
|
event_data = [
|
@@ -16,14 +16,14 @@
|
|
16
16
|
}
|
17
17
|
]
|
18
18
|
|
19
|
-
::
|
19
|
+
::Tracebin::Patches.handle_event :postgres, event_data
|
20
20
|
|
21
21
|
result
|
22
22
|
end
|
23
23
|
|
24
24
|
def exec(*args, &block)
|
25
25
|
start_time = Time.now
|
26
|
-
result =
|
26
|
+
result = exec_without_tracebin(*args, &block)
|
27
27
|
end_time = Time.now
|
28
28
|
|
29
29
|
event_data = [
|
@@ -35,7 +35,7 @@
|
|
35
35
|
}
|
36
36
|
]
|
37
37
|
|
38
|
-
::
|
38
|
+
::Tracebin::Patches.handle_event :postgres, event_data
|
39
39
|
|
40
40
|
result
|
41
41
|
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'tracebin/patches'
|
2
|
+
require 'tracebin/system_health_sample'
|
3
|
+
require 'concurrent'
|
4
|
+
|
5
|
+
require 'sidekiq/launcher'
|
6
|
+
|
7
|
+
::Sidekiq::Launcher.class_eval do
|
8
|
+
alias_method :run_without_tracebin, :run
|
9
|
+
alias_method :stop_without_tracebin, :stop
|
10
|
+
|
11
|
+
def run
|
12
|
+
@tracebin_task = Concurrent::TimerTask.new(execution_interval: 10) do
|
13
|
+
health = Tracebin::SystemHealthSample.new process: :worker
|
14
|
+
::Tracebin::Patches.handle_event :sidekiq_health, health
|
15
|
+
end
|
16
|
+
|
17
|
+
@tracebin_task.execute
|
18
|
+
|
19
|
+
run_without_tracebin
|
20
|
+
end
|
21
|
+
|
22
|
+
def stop
|
23
|
+
@tracebin_task.shutdown
|
24
|
+
|
25
|
+
stop_without_tracebin
|
26
|
+
end
|
27
|
+
end
|
@@ -1,9 +1,9 @@
|
|
1
1
|
::Sinatra::Base.class_eval do
|
2
|
-
alias_method :
|
2
|
+
alias_method :dispatch_without_tracebin!, :dispatch!
|
3
3
|
|
4
4
|
def dispatch!(*args, &block)
|
5
5
|
start_time = Time.now
|
6
|
-
result =
|
6
|
+
result = dispatch_without_tracebin!(*args, *block)
|
7
7
|
end_time = Time.now
|
8
8
|
route = env['sinatra.route']
|
9
9
|
|
@@ -14,7 +14,7 @@
|
|
14
14
|
route
|
15
15
|
]
|
16
16
|
|
17
|
-
::
|
17
|
+
::Tracebin::Patches.handle_event :sinatra, event_data
|
18
18
|
|
19
19
|
result
|
20
20
|
end
|
@@ -1,6 +1,6 @@
|
|
1
|
-
require '
|
1
|
+
require 'tracebin/helpers'
|
2
2
|
|
3
|
-
module
|
3
|
+
module Tracebin
|
4
4
|
##
|
5
5
|
# This singleton class handles patching for any given library we wish to
|
6
6
|
# instrument. To create a new patch for a library, just create a file in the
|
@@ -9,10 +9,10 @@ module Vizsla
|
|
9
9
|
# in that file, just call its corresponding +patch_+ method. For example, if
|
10
10
|
# we have a file +lib/patches/foo.rb+, then we would just call:
|
11
11
|
#
|
12
|
-
# ::
|
12
|
+
# ::Tracebin::Patches.patch_foo
|
13
13
|
#
|
14
14
|
class Patches
|
15
|
-
include ::
|
15
|
+
include ::Tracebin::Helpers
|
16
16
|
|
17
17
|
PATCH_METHOD_REGEX = /^patch_(.*)$/
|
18
18
|
|
@@ -26,7 +26,7 @@ module Vizsla
|
|
26
26
|
if method_sym.to_s =~ PATCH_METHOD_REGEX
|
27
27
|
patch_name = $1
|
28
28
|
instance_variable_set "@#{patch_name}_event_handler", block
|
29
|
-
require "
|
29
|
+
require "tracebin/patches/#{patch_name}"
|
30
30
|
else
|
31
31
|
super
|
32
32
|
end
|
@@ -1,12 +1,12 @@
|
|
1
|
-
require '
|
2
|
-
require '
|
1
|
+
require 'tracebin/logger'
|
2
|
+
require 'tracebin/reporter'
|
3
3
|
|
4
|
-
module
|
4
|
+
module Tracebin
|
5
5
|
class PuppetMaster
|
6
6
|
def initialize(puppet, options = {})
|
7
7
|
@puppet = puppet
|
8
8
|
@logger = RequestLogger.new(options[:logger])
|
9
|
-
@storage = ::
|
9
|
+
@storage = ::Tracebin::Agent.storage
|
10
10
|
end
|
11
11
|
|
12
12
|
def process
|
@@ -1,21 +1,21 @@
|
|
1
|
-
require 'net/
|
1
|
+
require 'net/https'
|
2
2
|
require 'json'
|
3
3
|
require 'concurrent'
|
4
4
|
|
5
|
-
module
|
5
|
+
module Tracebin
|
6
6
|
class Reporter
|
7
7
|
attr_reader :logger, :config, :storage
|
8
8
|
|
9
|
-
def initialize(storage =
|
9
|
+
def initialize(storage = Tracebin::Agent.storage, config = Tracebin::Agent.config, logger = Tracebin::Agent.logger)
|
10
10
|
@logger = logger
|
11
11
|
@config = config
|
12
12
|
@storage = storage
|
13
13
|
|
14
|
-
host =
|
15
|
-
path =
|
14
|
+
host = Tracebin::Agent.config.host
|
15
|
+
path = Tracebin::Agent.config.report_path
|
16
16
|
@uri = URI("#{host}/#{path}")
|
17
17
|
|
18
|
-
@bin_id =
|
18
|
+
@bin_id = Tracebin::Agent.config.bin_id
|
19
19
|
end
|
20
20
|
|
21
21
|
def start!
|
@@ -41,21 +41,28 @@ module Vizsla
|
|
41
41
|
|
42
42
|
def send_data(payload)
|
43
43
|
logger.info 'TRACEBIN: Sending analytics data to the server.'
|
44
|
+
logger.info "TRACEBIN: Sending #{payload.length} samples to: #{@uri}"
|
44
45
|
|
45
|
-
Net::HTTP.
|
46
|
-
|
47
|
-
|
48
|
-
report: payload
|
49
|
-
}.to_json
|
46
|
+
http = Net::HTTP.new @uri.host, @uri.port
|
47
|
+
http.use_ssl = true
|
48
|
+
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
50
49
|
|
51
|
-
|
52
|
-
|
53
|
-
|
50
|
+
body = {
|
51
|
+
bin_id: @bin_id,
|
52
|
+
report: payload
|
53
|
+
}.to_json
|
54
54
|
|
55
|
-
|
56
|
-
|
55
|
+
req = Net::HTTP::Post.new @uri
|
56
|
+
req.content_type = 'application/json'
|
57
|
+
req.body = body
|
58
|
+
|
59
|
+
res = http.request req
|
60
|
+
logger.debug "TRACEBIN: Server responded with a status code of #{res.code}."
|
61
|
+
|
62
|
+
res
|
57
63
|
rescue Exception => e
|
58
64
|
logger.warn "TRACEBIN: Exception occurred sending data to the server: #{e.message}"
|
65
|
+
self.stop!
|
59
66
|
end
|
60
67
|
|
61
68
|
def handle_response(res, payload)
|
@@ -1,9 +1,9 @@
|
|
1
|
-
require '
|
2
|
-
require '
|
3
|
-
require '
|
4
|
-
require '
|
1
|
+
require 'tracebin/recorder'
|
2
|
+
require 'tracebin/patches'
|
3
|
+
require 'tracebin/events'
|
4
|
+
require 'tracebin/background_job_instrumentation'
|
5
5
|
|
6
|
-
module
|
6
|
+
module Tracebin
|
7
7
|
##
|
8
8
|
# Subscribes to certain events, handels them, and passes event data to the
|
9
9
|
# +Recorder+ class. The general workflow goes like this:
|
@@ -54,7 +54,6 @@ module Vizsla
|
|
54
54
|
def other_hooks
|
55
55
|
sinatra_hook if sinatra_app?
|
56
56
|
db_hooks
|
57
|
-
background_job_hooks
|
58
57
|
end
|
59
58
|
|
60
59
|
def background_job_hooks
|
@@ -85,7 +84,7 @@ module Vizsla
|
|
85
84
|
|
86
85
|
def render_layout_hook
|
87
86
|
unless [ActionPack::VERSION::MAJOR, ActionPack::VERSION::MINOR] == [3, 0]
|
88
|
-
::
|
87
|
+
::Tracebin::Patches.patch_action_view_layout do |event_data|
|
89
88
|
event = ViewEvent.new event_data
|
90
89
|
@events_data << event
|
91
90
|
end
|
@@ -101,7 +100,7 @@ module Vizsla
|
|
101
100
|
end
|
102
101
|
|
103
102
|
def active_job_hook
|
104
|
-
::
|
103
|
+
::Tracebin::BackgroundJobInstrumentation.install :active_job
|
105
104
|
end
|
106
105
|
|
107
106
|
# ===---------------------------===
|
@@ -110,7 +109,7 @@ module Vizsla
|
|
110
109
|
|
111
110
|
def postgres_hook
|
112
111
|
return unless defined? ::PG
|
113
|
-
::
|
112
|
+
::Tracebin::Patches.patch_postgres do |event_data|
|
114
113
|
event = SQLEvent.new event_data
|
115
114
|
@events_data << event
|
116
115
|
end
|
@@ -119,7 +118,7 @@ module Vizsla
|
|
119
118
|
|
120
119
|
def mysql2_hook
|
121
120
|
return unless defined? ::Mysql2
|
122
|
-
::
|
121
|
+
::Tracebin::Patches.patch_mysql2 do |event_data|
|
123
122
|
event = SQLEvent.new event_data
|
124
123
|
@events_data << event
|
125
124
|
end
|
@@ -131,12 +130,12 @@ module Vizsla
|
|
131
130
|
|
132
131
|
def sidekiq_hook
|
133
132
|
return unless defined? ::Sidekiq
|
134
|
-
::
|
133
|
+
::Tracebin::BackgroundJobInstrumentation.install :sidekiq
|
135
134
|
end
|
136
135
|
|
137
136
|
def resque_hook
|
138
137
|
return unless defined? ::Resque
|
139
|
-
::
|
138
|
+
::Tracebin::BackgroundJobInstrumentation.install :resque
|
140
139
|
end
|
141
140
|
|
142
141
|
# ===---------------------------===
|
@@ -144,7 +143,7 @@ module Vizsla
|
|
144
143
|
# ===---------------------------===
|
145
144
|
|
146
145
|
def sinatra_hook
|
147
|
-
::
|
146
|
+
::Tracebin::Patches.patch_sinatra do |event_data|
|
148
147
|
event = SinatraEvent.new event_data
|
149
148
|
@events_data << event
|
150
149
|
end
|
@@ -1,10 +1,9 @@
|
|
1
|
-
require '
|
2
|
-
require '
|
1
|
+
require 'tracebin/recorder'
|
2
|
+
require 'tracebin/helpers'
|
3
3
|
|
4
|
-
|
5
|
-
module Vizsla
|
4
|
+
module Tracebin
|
6
5
|
class Timer
|
7
|
-
include ::
|
6
|
+
include ::Tracebin::Helpers
|
8
7
|
|
9
8
|
attr_accessor :transaction_name
|
10
9
|
attr_reader :events
|
@@ -1,7 +1,7 @@
|
|
1
|
-
require '
|
2
|
-
require '
|
1
|
+
require 'tracebin/patches'
|
2
|
+
require 'tracebin/puppet_master'
|
3
3
|
|
4
|
-
module
|
4
|
+
module Tracebin
|
5
5
|
class WorkerProcessMonitor
|
6
6
|
class << self
|
7
7
|
def start
|
@@ -16,8 +16,8 @@ module Vizsla
|
|
16
16
|
def sidekiq_health_patch
|
17
17
|
return unless defined? ::Sidekiq
|
18
18
|
|
19
|
-
::
|
20
|
-
::
|
19
|
+
::Tracebin::Patches.patch_sidekiq_health do |health_data|
|
20
|
+
::Tracebin::PuppetMaster.new(health_data, logger: ::Sidekiq::Logging.logger).process
|
21
21
|
end
|
22
22
|
end
|
23
23
|
end
|
data/lib/tracebin.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'tracebin/version'
|
2
|
+
require 'tracebin/config'
|
3
|
+
require 'tracebin/subscribers'
|
4
|
+
require 'tracebin/health_monitor'
|
5
|
+
require 'tracebin/worker_process_monitor'
|
6
|
+
require 'tracebin/agent'
|
7
|
+
require 'tracebin/middleware'
|
8
|
+
|
9
|
+
if defined?(::Rails) && defined?(::Rails::Railtie)
|
10
|
+
module Tracebin
|
11
|
+
class Railtie < Rails::Railtie
|
12
|
+
initializer 'tracebin.start' do |app|
|
13
|
+
app.middleware.use Tracebin::Middleware
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -1,11 +1,11 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
lib = File.expand_path('../lib', __FILE__)
|
3
3
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require '
|
4
|
+
require 'tracebin/version'
|
5
5
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
7
|
spec.name = "tracebin"
|
8
|
-
spec.version =
|
8
|
+
spec.version = Tracebin::VERSION
|
9
9
|
spec.authors = ["Tyler Guillen"]
|
10
10
|
spec.email = ["tyguillen@gmail.com"]
|
11
11
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tracebin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tyler Guillen
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-04-
|
11
|
+
date: 2017-04-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: concurrent-ruby
|
@@ -98,35 +98,35 @@ files:
|
|
98
98
|
- bin/console
|
99
99
|
- bin/setup
|
100
100
|
- dump.rdb
|
101
|
-
- lib/
|
102
|
-
- lib/
|
103
|
-
- lib/
|
104
|
-
- lib/
|
105
|
-
- lib/
|
106
|
-
- lib/
|
107
|
-
- lib/
|
108
|
-
- lib/
|
109
|
-
- lib/
|
110
|
-
- lib/
|
111
|
-
- lib/
|
112
|
-
- lib/
|
113
|
-
- lib/
|
114
|
-
- lib/
|
115
|
-
- lib/
|
116
|
-
- lib/
|
117
|
-
- lib/
|
118
|
-
- lib/
|
119
|
-
- lib/
|
120
|
-
- lib/
|
121
|
-
- lib/
|
122
|
-
- lib/
|
123
|
-
- lib/
|
124
|
-
- lib/
|
125
|
-
- lib/
|
126
|
-
- lib/
|
127
|
-
- lib/
|
128
|
-
- lib/
|
129
|
-
-
|
101
|
+
- lib/tracebin.rb
|
102
|
+
- lib/tracebin/agent.rb
|
103
|
+
- lib/tracebin/background_job_instrumentation.rb
|
104
|
+
- lib/tracebin/background_job_instrumentation/active_job.rb
|
105
|
+
- lib/tracebin/background_job_instrumentation/resque.rb
|
106
|
+
- lib/tracebin/background_job_instrumentation/sidekiq.rb
|
107
|
+
- lib/tracebin/background_timer.rb
|
108
|
+
- lib/tracebin/config.rb
|
109
|
+
- lib/tracebin/events.rb
|
110
|
+
- lib/tracebin/health_monitor.rb
|
111
|
+
- lib/tracebin/helpers.rb
|
112
|
+
- lib/tracebin/logger.rb
|
113
|
+
- lib/tracebin/middleware.rb
|
114
|
+
- lib/tracebin/patches.rb
|
115
|
+
- lib/tracebin/patches/action_view_layout.rb
|
116
|
+
- lib/tracebin/patches/mysql2.rb
|
117
|
+
- lib/tracebin/patches/postgres.rb
|
118
|
+
- lib/tracebin/patches/sidekiq_health.rb
|
119
|
+
- lib/tracebin/patches/sinatra.rb
|
120
|
+
- lib/tracebin/puppet_master.rb
|
121
|
+
- lib/tracebin/recorder.rb
|
122
|
+
- lib/tracebin/reporter.rb
|
123
|
+
- lib/tracebin/storage.rb
|
124
|
+
- lib/tracebin/subscribers.rb
|
125
|
+
- lib/tracebin/system_health_sample.rb
|
126
|
+
- lib/tracebin/timer.rb
|
127
|
+
- lib/tracebin/version.rb
|
128
|
+
- lib/tracebin/worker_process_monitor.rb
|
129
|
+
- tracebin.gemspec
|
130
130
|
homepage: https://google.com
|
131
131
|
licenses:
|
132
132
|
- MIT
|
@@ -1,14 +0,0 @@
|
|
1
|
-
require 'vizsla/background_timer'
|
2
|
-
require 'vizsla/puppet_master'
|
3
|
-
|
4
|
-
if defined? ::ActiveJob::Base
|
5
|
-
::ActiveJob::Base.around_perform do |job, block|
|
6
|
-
@vizsla_timer = ::Vizsla::BackgroundTimer.new job.class.name.split('::').last
|
7
|
-
@vizsla_timer.start!
|
8
|
-
|
9
|
-
block.call
|
10
|
-
|
11
|
-
@vizsla_timer.stop!
|
12
|
-
::Vizsla::PuppetMaster.new(@vizsla_timer).process
|
13
|
-
end
|
14
|
-
end
|
@@ -1,37 +0,0 @@
|
|
1
|
-
require 'vizsla/background_timer'
|
2
|
-
require 'vizsla/puppet_master'
|
3
|
-
|
4
|
-
module Resque
|
5
|
-
module Plugins
|
6
|
-
module VizslaInstrumentation
|
7
|
-
module Job
|
8
|
-
def before_perform_with_vizsla(*args)
|
9
|
-
@vizsla_timer = ::Vizsla::BackgroundTimer.new
|
10
|
-
@vizsla_timer.start!
|
11
|
-
|
12
|
-
yield *args if block_given?
|
13
|
-
end
|
14
|
-
|
15
|
-
def after_perform_with_vizsla(*args)
|
16
|
-
@vizsla_timer.stop!
|
17
|
-
::Vizsla::PuppetMaster.new(@vizsla_timer, logger: Resque.logger).process
|
18
|
-
|
19
|
-
yield *args if block_given?
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
module Vizsla
|
27
|
-
module BackgroundJobInstrumentation
|
28
|
-
module ResqueInstrumentationInstaller
|
29
|
-
def payload_class
|
30
|
-
klass = super
|
31
|
-
klass.instance_eval do
|
32
|
-
extend ::Resque::Plugins::VizslaInstrumentation::Job
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
@@ -1,27 +0,0 @@
|
|
1
|
-
require 'vizsla/patches'
|
2
|
-
require 'vizsla/system_health_sample'
|
3
|
-
require 'concurrent'
|
4
|
-
|
5
|
-
require 'sidekiq/launcher'
|
6
|
-
|
7
|
-
::Sidekiq::Launcher.class_eval do
|
8
|
-
alias_method :run_without_vizsla, :run
|
9
|
-
alias_method :stop_without_vizsla, :stop
|
10
|
-
|
11
|
-
def run
|
12
|
-
@vizsla_task = Concurrent::TimerTask.new(execution_interval: 10) do
|
13
|
-
health = Vizsla::SystemHealthSample.new process: :worker
|
14
|
-
::Vizsla::Patches.handle_event :sidekiq_health, health
|
15
|
-
end
|
16
|
-
|
17
|
-
@vizsla_task.execute
|
18
|
-
|
19
|
-
run_without_vizsla
|
20
|
-
end
|
21
|
-
|
22
|
-
def stop
|
23
|
-
@vizsla_task.shutdown
|
24
|
-
|
25
|
-
stop_without_vizsla
|
26
|
-
end
|
27
|
-
end
|
data/lib/vizsla/version.rb
DELETED
data/lib/vizsla.rb
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
require 'vizsla/version'
|
2
|
-
require 'vizsla/config'
|
3
|
-
require 'vizsla/subscribers'
|
4
|
-
require 'vizsla/health_monitor'
|
5
|
-
require 'vizsla/worker_process_monitor'
|
6
|
-
require 'vizsla/agent'
|
7
|
-
require 'vizsla/middleware'
|
8
|
-
|
9
|
-
if defined?(::Rails) && defined?(::Rails::Railtie)
|
10
|
-
module Vizsla
|
11
|
-
class Railtie < Rails::Railtie
|
12
|
-
initializer 'vizsla.start' do |app|
|
13
|
-
app.middleware.use Vizsla::Middleware
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|