atatus 1.0.0 → 1.0.1
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/CHANGELOG.md +6 -1
- data/lib/atatus/agent.rb +1 -0
- data/lib/atatus/collector/base.rb +15 -9
- data/lib/atatus/rails.rb +1 -1
- data/lib/atatus/spies/elasticsearch.rb +13 -8
- data/lib/atatus/spies/faraday.rb +30 -27
- data/lib/atatus/spies/http.rb +21 -18
- data/lib/atatus/spies/json.rb +8 -5
- data/lib/atatus/spies/net_http.rb +24 -22
- data/lib/atatus/spies/redis.rb +9 -7
- data/lib/atatus/spies/sequel.rb +12 -10
- data/lib/atatus/spies/sinatra.rb +22 -16
- data/lib/atatus/spies/tilt.rb +8 -6
- data/lib/atatus/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: acfc54c3597def60fca53e99bf249711197735e0507b9bcade319f10182cbc26
|
4
|
+
data.tar.gz: efb49084366463b5ed40d3b4c57609ada57e745f28f8ac5949456e242167ede1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e6e2af0647be02da224d11dd9a45650c0c6cae63e10dbfaf81fd2d757fe8aa3414ab82ffad9eb880fc73f3340c145a175374be77a41f646febd621bf50502dca
|
7
|
+
data.tar.gz: 170206df98d5e3b5ccf68271f9dfdb58042ce45b13129321105aac2cf4fa8a04095807e0adc4ed75589bd09b556284ea41ac5a2030565584d96640da58aac03c
|
data/CHANGELOG.md
CHANGED
@@ -4,8 +4,13 @@ All notable changes to this project will be documented in this file.
|
|
4
4
|
|
5
5
|
This project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
|
6
6
|
|
7
|
+
## 1.0.1 (Wed, 13 Nov 2019)
|
7
8
|
|
8
|
-
|
9
|
+
- Fixed Instrumenting classes only when there are defined.
|
10
|
+
- Handled worker thread while exiting.
|
11
|
+
|
12
|
+
|
13
|
+
## 1.0.0 (Tue, 29 Oct 2019)
|
9
14
|
|
10
15
|
- General availability release of the Ruby agent.
|
11
16
|
|
data/lib/atatus/agent.rb
CHANGED
@@ -109,11 +109,24 @@ module Atatus
|
|
109
109
|
end
|
110
110
|
|
111
111
|
def start
|
112
|
-
debug '%s: Starting
|
112
|
+
debug '%s: Starting collector', pid_str
|
113
113
|
|
114
114
|
ensure_worker_running
|
115
115
|
end
|
116
116
|
|
117
|
+
def stop
|
118
|
+
return unless @running
|
119
|
+
@running = false
|
120
|
+
if worker_active?
|
121
|
+
debug '%s: Waiting for collector worker to exit', pid_str
|
122
|
+
@worker.run
|
123
|
+
@worker.join(10)
|
124
|
+
end
|
125
|
+
rescue => e
|
126
|
+
error format('Failed during collector stop: [%s] %s', e.class, e.message)
|
127
|
+
error "Backtrace:\n" + e.backtrace.join("\n")
|
128
|
+
end
|
129
|
+
|
117
130
|
def add_error(error)
|
118
131
|
ensure_worker_running
|
119
132
|
|
@@ -241,7 +254,7 @@ module Atatus
|
|
241
254
|
return if worker_active?
|
242
255
|
@running = true
|
243
256
|
@worker = Thread.new() do
|
244
|
-
debug '%s: Starting
|
257
|
+
debug '%s: Starting collector worker', pid_str
|
245
258
|
|
246
259
|
while @running
|
247
260
|
start_time = Time.now
|
@@ -249,13 +262,6 @@ module Atatus
|
|
249
262
|
collect start_time
|
250
263
|
end
|
251
264
|
end
|
252
|
-
|
253
|
-
at_exit do
|
254
|
-
debug '%s: Waiting for Collector Worker to exit', pid_str
|
255
|
-
@running = false
|
256
|
-
@worker.run
|
257
|
-
@worker.join(10)
|
258
|
-
end
|
259
265
|
end
|
260
266
|
|
261
267
|
def worker_active?
|
data/lib/atatus/rails.rb
CHANGED
@@ -37,7 +37,7 @@ module Atatus
|
|
37
37
|
Atatus.running?
|
38
38
|
rescue StandardError => e
|
39
39
|
config.logger.error format('Failed to start: %s', e.message)
|
40
|
-
config.logger.
|
40
|
+
config.logger.error "Backtrace:\n" + e.backtrace.join("\n")
|
41
41
|
end
|
42
42
|
# rubocop:enable Metrics/MethodLength, Metrics/AbcSize
|
43
43
|
# rubocop:enable Metrics/CyclomaticComplexity
|
@@ -10,16 +10,21 @@ module Atatus
|
|
10
10
|
|
11
11
|
# rubocop:disable Metrics/MethodLength
|
12
12
|
def install
|
13
|
-
::Elasticsearch
|
14
|
-
|
13
|
+
if defined?(::Elasticsearch) &&
|
14
|
+
defined?(::Elasticsearch::Transport) &&
|
15
|
+
defined?(::Elasticsearch::Transport::Client)
|
15
16
|
|
16
|
-
|
17
|
-
|
18
|
-
statement = args[0].is_a?(String) ? args[0] : args[0].to_json
|
19
|
-
context = Span::Context.new(db: { statement: statement })
|
17
|
+
::Elasticsearch::Transport::Client.class_eval do
|
18
|
+
alias perform_request_without_apm perform_request
|
20
19
|
|
21
|
-
|
22
|
-
|
20
|
+
def perform_request(method, path, *args, &block)
|
21
|
+
name = format(NAME_FORMAT, method, path)
|
22
|
+
statement = args[0].is_a?(String) ? args[0] : args[0].to_json
|
23
|
+
context = Span::Context.new(db: { statement: statement })
|
24
|
+
|
25
|
+
Atatus.with_span name, TYPE, context: context do
|
26
|
+
perform_request_without_apm(method, path, *args, &block)
|
27
|
+
end
|
23
28
|
end
|
24
29
|
end
|
25
30
|
end
|
data/lib/atatus/spies/faraday.rb
CHANGED
@@ -20,40 +20,43 @@ module Atatus
|
|
20
20
|
# rubocop:disable Metrics/BlockLength, Metrics/PerceivedComplexity
|
21
21
|
# rubocop:disable Metrics/CyclomaticComplexity
|
22
22
|
def install
|
23
|
-
::Faraday::Connection
|
24
|
-
alias run_request_without_apm run_request
|
23
|
+
if defined?(::Faraday) && defined?(::Faraday::Connection)
|
25
24
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
25
|
+
::Faraday::Connection.class_eval do
|
26
|
+
alias run_request_without_apm run_request
|
27
|
+
|
28
|
+
def run_request(method, url, body, headers, &block)
|
29
|
+
unless (transaction = Atatus.current_transaction)
|
30
|
+
return run_request_without_apm(method, url, body, headers, &block)
|
31
|
+
end
|
30
32
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
33
|
+
host = if url_prefix.is_a?(URI) && url_prefix.host
|
34
|
+
url_prefix.host
|
35
|
+
elsif url.nil?
|
36
|
+
tmp_request = build_request(method) do |req|
|
37
|
+
yield(req) if block_given?
|
38
|
+
end
|
39
|
+
URI(tmp_request.path).host
|
40
|
+
else
|
41
|
+
URI(url).host
|
36
42
|
end
|
37
|
-
URI(tmp_request.path).host
|
38
|
-
else
|
39
|
-
URI(url).host
|
40
|
-
end
|
41
43
|
|
42
|
-
|
44
|
+
name = "#{method.upcase} #{host}"
|
43
45
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
46
|
+
Atatus.with_span(
|
47
|
+
name,
|
48
|
+
TYPE,
|
49
|
+
subtype: SUBTYPE,
|
50
|
+
action: method.to_s
|
51
|
+
) do |span|
|
52
|
+
Atatus::Spies::FaradaySpy.without_net_http do
|
53
|
+
trace_context = span&.trace_context || transaction.trace_context
|
52
54
|
|
53
|
-
|
54
|
-
|
55
|
+
run_request_without_apm(method, url, body, headers) do |req|
|
56
|
+
req['Atatus-Apm-Traceparent'] = trace_context.to_header
|
55
57
|
|
56
|
-
|
58
|
+
yield req if block_given?
|
59
|
+
end
|
57
60
|
end
|
58
61
|
end
|
59
62
|
end
|
data/lib/atatus/spies/http.rb
CHANGED
@@ -10,28 +10,31 @@ module Atatus
|
|
10
10
|
|
11
11
|
# rubocop:disable Metrics/MethodLength
|
12
12
|
def install
|
13
|
-
::HTTP::Client
|
14
|
-
alias perform_without_apm perform
|
13
|
+
if defined?(::HTTP) && defined?(::HTTP::Client)
|
15
14
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
15
|
+
::HTTP::Client.class_eval do
|
16
|
+
alias perform_without_apm perform
|
17
|
+
|
18
|
+
def perform(req, options)
|
19
|
+
unless (transaction = Atatus.current_transaction)
|
20
|
+
return perform_without_apm(req, options)
|
21
|
+
end
|
20
22
|
|
21
|
-
|
22
|
-
|
23
|
+
method = req.verb.to_s.upcase
|
24
|
+
host = req.uri.host
|
23
25
|
|
24
|
-
|
26
|
+
name = "#{method} #{host}"
|
25
27
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
28
|
+
Atatus.with_span(
|
29
|
+
name,
|
30
|
+
TYPE,
|
31
|
+
subtype: SUBTYPE,
|
32
|
+
action: method
|
33
|
+
) do |span|
|
34
|
+
trace_context = span&.trace_context || transaction.trace_context
|
35
|
+
req['Atatus-Apm-Traceparent'] = trace_context.to_header
|
36
|
+
perform_without_apm(req, options)
|
37
|
+
end
|
35
38
|
end
|
36
39
|
end
|
37
40
|
end
|
data/lib/atatus/spies/json.rb
CHANGED
@@ -8,11 +8,14 @@ module Atatus
|
|
8
8
|
# @api private
|
9
9
|
class JSONSpy
|
10
10
|
def install
|
11
|
-
::JSON
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
11
|
+
if defined?(::JSON)
|
12
|
+
|
13
|
+
::JSON.class_eval do
|
14
|
+
include SpanHelpers
|
15
|
+
span_class_method :parse, 'JSON#parse', 'json.parse'
|
16
|
+
span_class_method :parse!, 'JSON#parse!', 'json.parse'
|
17
|
+
span_class_method :generate, 'JSON#generate', 'json.generate'
|
18
|
+
end
|
16
19
|
end
|
17
20
|
end
|
18
21
|
end
|
@@ -31,33 +31,35 @@ module Atatus
|
|
31
31
|
end
|
32
32
|
|
33
33
|
def install
|
34
|
-
Net::HTTP
|
35
|
-
|
34
|
+
if defined?(::Net) && defined?(::Net::HTTP)
|
35
|
+
::Net::HTTP.class_eval do
|
36
|
+
alias request_without_apm request
|
36
37
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
38
|
+
def request(req, body = nil, &block)
|
39
|
+
unless (transaction = Atatus.current_transaction)
|
40
|
+
return request_without_apm(req, body, &block)
|
41
|
+
end
|
42
|
+
if Atatus::Spies::NetHTTPSpy.disabled?
|
43
|
+
return request_without_apm(req, body, &block)
|
44
|
+
end
|
44
45
|
|
45
|
-
|
46
|
-
|
46
|
+
host, = req['host'] && req['host'].split(':')
|
47
|
+
method = req.method
|
47
48
|
|
48
|
-
|
49
|
+
host ||= address
|
49
50
|
|
50
|
-
|
51
|
+
name = "#{method} #{host}"
|
51
52
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
53
|
+
Atatus.with_span(
|
54
|
+
name,
|
55
|
+
TYPE,
|
56
|
+
subtype: SUBTYPE,
|
57
|
+
action: method.to_s
|
58
|
+
) do |span|
|
59
|
+
trace_context = span&.trace_context || transaction.trace_context
|
60
|
+
req['Atatus-Apm-Traceparent'] = trace_context.to_header
|
61
|
+
request_without_apm(req, body, &block)
|
62
|
+
end
|
61
63
|
end
|
62
64
|
end
|
63
65
|
end
|
data/lib/atatus/spies/redis.rb
CHANGED
@@ -6,16 +6,18 @@ module Atatus
|
|
6
6
|
# @api private
|
7
7
|
class RedisSpy
|
8
8
|
def install
|
9
|
-
::Redis::Client
|
10
|
-
|
9
|
+
if defined?(::Redis) && defined?(::Redis::Client)
|
10
|
+
::Redis::Client.class_eval do
|
11
|
+
alias call_without_apm call
|
11
12
|
|
12
|
-
|
13
|
-
|
13
|
+
def call(command, &block)
|
14
|
+
name = command[0].upcase
|
14
15
|
|
15
|
-
|
16
|
+
return call_without_apm(command, &block) if command[0] == :auth
|
16
17
|
|
17
|
-
|
18
|
-
|
18
|
+
Atatus.with_span(name.to_s, 'db.redis') do
|
19
|
+
call_without_apm(command, &block)
|
20
|
+
end
|
19
21
|
end
|
20
22
|
end
|
21
23
|
end
|
data/lib/atatus/spies/sequel.rb
CHANGED
@@ -23,19 +23,21 @@ module Atatus
|
|
23
23
|
def install
|
24
24
|
require 'sequel/database/logging'
|
25
25
|
|
26
|
-
::Sequel::Database
|
27
|
-
|
26
|
+
if defined?(::Sequel) && defined?(::Sequel::Database)
|
27
|
+
::Sequel::Database.class_eval do
|
28
|
+
alias log_connection_yield_without_apm log_connection_yield
|
28
29
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
30
|
+
def log_connection_yield(sql, *args, &block)
|
31
|
+
unless Atatus.current_transaction
|
32
|
+
return log_connection_yield_without_apm(sql, *args, &block)
|
33
|
+
end
|
33
34
|
|
34
|
-
|
35
|
-
|
36
|
-
|
35
|
+
summarizer = Atatus::Spies::SequelSpy.summarizer
|
36
|
+
name = summarizer.summarize sql
|
37
|
+
context = Atatus::Spies::SequelSpy.build_context(sql, opts)
|
37
38
|
|
38
|
-
|
39
|
+
Atatus.with_span(name, TYPE, context: context, &block)
|
40
|
+
end
|
39
41
|
end
|
40
42
|
end
|
41
43
|
end
|
data/lib/atatus/spies/sinatra.rb
CHANGED
@@ -7,27 +7,33 @@ module Atatus
|
|
7
7
|
class SinatraSpy
|
8
8
|
# rubocop:disable Metrics/MethodLength
|
9
9
|
def install
|
10
|
-
::Sinatra
|
11
|
-
|
12
|
-
|
10
|
+
if defined?(::Sinatra) &&
|
11
|
+
defined?(::Sinatra::Base) &&
|
12
|
+
::Sinatra::Base.private_method_defined?(:dispatch!) &&
|
13
|
+
::Sinatra::Base.private_method_defined?(:compile_template)
|
13
14
|
|
14
|
-
|
15
|
-
dispatch_without_apm!
|
16
|
-
|
17
|
-
next unless (route = env['sinatra.route'])
|
15
|
+
::Sinatra::Base.class_eval do
|
16
|
+
alias dispatch_without_apm! dispatch!
|
17
|
+
alias compile_template_without_apm compile_template
|
18
18
|
|
19
|
-
|
20
|
-
|
21
|
-
|
19
|
+
def dispatch!(*args, &block)
|
20
|
+
dispatch_without_apm!(*args, &block).tap do
|
21
|
+
next unless (transaction = Atatus.current_transaction)
|
22
|
+
next unless (route = env['sinatra.route'])
|
22
23
|
|
23
|
-
|
24
|
-
opts[:__atatus_template_name] =
|
25
|
-
case data
|
26
|
-
when Symbol then data.to_s
|
27
|
-
else format('Inline %s', engine)
|
24
|
+
transaction.name = route
|
28
25
|
end
|
26
|
+
end
|
29
27
|
|
30
|
-
|
28
|
+
def compile_template(engine, data, opts, *args, &block)
|
29
|
+
opts[:__atatus_template_name] =
|
30
|
+
case data
|
31
|
+
when Symbol then data.to_s
|
32
|
+
else format('Inline %s', engine)
|
33
|
+
end
|
34
|
+
|
35
|
+
compile_template_without_apm(engine, data, opts, *args, &block)
|
36
|
+
end
|
31
37
|
end
|
32
38
|
end
|
33
39
|
end
|
data/lib/atatus/spies/tilt.rb
CHANGED
@@ -8,14 +8,16 @@ module Atatus
|
|
8
8
|
TYPE = 'template.tilt'
|
9
9
|
|
10
10
|
def install
|
11
|
-
::Tilt::Template
|
12
|
-
|
11
|
+
if defined?(::Tilt) && defined?(::Tilt::Template)
|
12
|
+
::Tilt::Template.class_eval do
|
13
|
+
alias render_without_apm render
|
13
14
|
|
14
|
-
|
15
|
-
|
15
|
+
def render(*args, &block)
|
16
|
+
name = options[:__atatus_template_name] || 'Unknown template'
|
16
17
|
|
17
|
-
|
18
|
-
|
18
|
+
Atatus.with_span name, TYPE do
|
19
|
+
render_without_apm(*args, &block)
|
20
|
+
end
|
19
21
|
end
|
20
22
|
end
|
21
23
|
end
|
data/lib/atatus/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: atatus
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Atatus
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-11-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: concurrent-ruby
|