instana 1.0.2 → 1.0.3
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/lib/instana/agent.rb +9 -33
- data/lib/instana/base.rb +6 -5
- data/lib/instana/collector.rb +115 -0
- data/lib/instana/collectors/gc.rb +3 -12
- data/lib/instana/collectors/memory.rb +5 -12
- data/lib/instana/collectors/thread.rb +3 -12
- data/lib/instana/config.rb +9 -1
- data/lib/instana/instrumentation/net-http.rb +48 -46
- data/lib/instana/instrumentation/rest-client.rb +1 -1
- data/lib/instana/setup.rb +7 -4
- data/lib/instana/util.rb +0 -18
- data/lib/instana/version.rb +1 -1
- metadata +3 -3
- data/lib/instana/collectors.rb +0 -46
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e4988b08659f80e1f76d21135af688030ee190a0
|
4
|
+
data.tar.gz: c773f6f64f7559da3e10dbfef73d1ca8012bd289
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2b6c215de5684fffe16f8338958b47b8b09cc8b17e6a15b4e2e8a6361f9eb14ba8ca343d8b7ca6a08c7b8d92d95a6ea5a368cd21d4211194c1175ef0a2f796bd
|
7
|
+
data.tar.gz: 9e22ce676e64dd9eb0adab68ea0a9933e1343f83356f88a0796ac6aa3f89582d76fe01d3dc4636afe62b2f6e77cdeca38d7e3a61861dd328e24aa00828cb2dbc
|
data/lib/instana/agent.rb
CHANGED
@@ -9,6 +9,7 @@ module Instana
|
|
9
9
|
class Agent
|
10
10
|
attr_accessor :state
|
11
11
|
attr_accessor :agent_uuid
|
12
|
+
attr_accessor :process
|
12
13
|
|
13
14
|
LOCALHOST = '127.0.0.1'.freeze
|
14
15
|
MIME_JSON = 'application/json'.freeze
|
@@ -18,14 +19,6 @@ module Instana
|
|
18
19
|
# Supported two states (unannounced & announced)
|
19
20
|
@state = :unannounced
|
20
21
|
|
21
|
-
# Snapshot data is collected once per process but resent
|
22
|
-
# every 10 minutes along side process metrics.
|
23
|
-
@snapshot = ::Instana::Util.take_snapshot
|
24
|
-
|
25
|
-
# Set last snapshot to just under 10 minutes ago
|
26
|
-
# so we send a snapshot sooner than later
|
27
|
-
@last_snapshot = Time.now - 570
|
28
|
-
|
29
22
|
# Timestamp of the last successful response from
|
30
23
|
# entity data reporting.
|
31
24
|
@entity_last_seen = Time.now
|
@@ -114,10 +107,10 @@ module Instana
|
|
114
107
|
|
115
108
|
# The collect timer
|
116
109
|
# If we are in announced state, send metric data (only delta reporting)
|
117
|
-
# every ::Instana
|
118
|
-
@collect_timer = @timers.every(::Instana
|
110
|
+
# every ::Instana.config[:collector][:interval] seconds.
|
111
|
+
@collect_timer = @timers.every(::Instana.config[:collector][:interval]) do
|
119
112
|
if @state == :announced
|
120
|
-
if !::Instana
|
113
|
+
if !::Instana.collector.collect_and_report
|
121
114
|
# If report has been failing for more than 1 minute,
|
122
115
|
# fall back to unannounced state
|
123
116
|
if (Time.now - @entity_last_seen) > 60
|
@@ -197,30 +190,18 @@ module Instana
|
|
197
190
|
#
|
198
191
|
# @param paylod [Hash] The collection of metrics to report.
|
199
192
|
#
|
200
|
-
|
193
|
+
# @return [Boolean] true on success, false otherwise
|
194
|
+
#
|
195
|
+
def report_metrics(payload)
|
201
196
|
unless @discovered
|
202
197
|
::Instana.logger.agent("#{__method__} called but discovery hasn't run yet!")
|
203
198
|
return false
|
204
199
|
end
|
205
200
|
|
206
|
-
with_snapshot = false
|
207
201
|
path = "com.instana.plugin.ruby.#{@process[:report_pid]}"
|
208
202
|
uri = URI.parse("http://#{@discovered[:agent_host]}:#{@discovered[:agent_port]}/#{path}")
|
209
203
|
req = Net::HTTP::Post.new(uri)
|
210
204
|
|
211
|
-
# Every 5 minutes, send snapshot data as well
|
212
|
-
if (Time.now - @last_snapshot) > 600
|
213
|
-
with_snapshot = true
|
214
|
-
payload.merge!(@snapshot)
|
215
|
-
|
216
|
-
# Add in process related that could have changed since
|
217
|
-
# snapshot was taken.
|
218
|
-
p = { :pid => @process[:report_pid] }
|
219
|
-
p[:name] = @process[:name]
|
220
|
-
p[:exec_args] = @process[:arguments]
|
221
|
-
payload.merge!(p)
|
222
|
-
end
|
223
|
-
|
224
205
|
req.body = payload.to_json
|
225
206
|
response = make_host_agent_request(req)
|
226
207
|
|
@@ -233,7 +214,6 @@ module Instana
|
|
233
214
|
|
234
215
|
if response.code.to_i == 200
|
235
216
|
@entity_last_seen = Time.now
|
236
|
-
@last_snapshot = Time.now if with_snapshot
|
237
217
|
return true
|
238
218
|
end
|
239
219
|
|
@@ -417,18 +397,14 @@ module Instana
|
|
417
397
|
# Reset the entity timer
|
418
398
|
@entity_last_seen = Time.now
|
419
399
|
|
420
|
-
# Set last snapshot to 10 minutes ago
|
421
|
-
# so we send a snapshot on first report
|
422
|
-
@last_snapshot = Time.now - 601
|
423
400
|
when :unannounced
|
424
401
|
@state = :unannounced
|
425
402
|
|
426
|
-
# Set last snapshot to 10 minutes ago
|
427
|
-
# so we send a snapshot on first report
|
428
|
-
@last_snapshot = Time.now - 601
|
429
403
|
else
|
430
404
|
::Instana.logger.warn "Uknown agent state: #{state}"
|
431
405
|
end
|
406
|
+
::Instana.collector.reset_timer!
|
407
|
+
true
|
432
408
|
end
|
433
409
|
|
434
410
|
# Centralization of the net/http communications
|
data/lib/instana/base.rb
CHANGED
@@ -6,7 +6,7 @@ require "instana/helpers"
|
|
6
6
|
module Instana
|
7
7
|
class << self
|
8
8
|
attr_accessor :agent
|
9
|
-
attr_accessor :
|
9
|
+
attr_accessor :collector
|
10
10
|
attr_accessor :tracer
|
11
11
|
attr_accessor :processor
|
12
12
|
attr_accessor :config
|
@@ -20,13 +20,10 @@ module Instana
|
|
20
20
|
# to run" state.
|
21
21
|
#
|
22
22
|
def setup
|
23
|
-
@logger = ::Instana::XLogger.new(STDOUT)
|
24
|
-
@logger.unknown "Stan is on the scene. Starting Instana instrumentation."
|
25
|
-
|
26
23
|
@agent = ::Instana::Agent.new
|
27
24
|
@tracer = ::Instana::Tracer.new
|
28
25
|
@processor = ::Instana::Processor.new
|
29
|
-
@
|
26
|
+
@collector = ::Instana::Collector.new
|
30
27
|
end
|
31
28
|
|
32
29
|
# Indicates whether we are running in a development environment.
|
@@ -46,3 +43,7 @@ module Instana
|
|
46
43
|
end
|
47
44
|
end
|
48
45
|
end
|
46
|
+
|
47
|
+
# Setup the logger as early as possible
|
48
|
+
::Instana.logger = ::Instana::XLogger.new(STDOUT)
|
49
|
+
::Instana.logger.unknown "Stan is on the scene. Starting Instana instrumentation."
|
@@ -0,0 +1,115 @@
|
|
1
|
+
module Instana
|
2
|
+
class Collector
|
3
|
+
attr_accessor :collectors
|
4
|
+
attr_accessor :last_report_log
|
5
|
+
|
6
|
+
def initialize
|
7
|
+
@collectors = []
|
8
|
+
|
9
|
+
# Snapshot data is collected once per process but resent
|
10
|
+
# every 10 minutes along side process metrics.
|
11
|
+
@snapshot = ::Instana::Util.take_snapshot
|
12
|
+
|
13
|
+
# Set last snapshot to just under 10 minutes ago
|
14
|
+
# so we send a snapshot sooner than later
|
15
|
+
@last_snapshot = Time.now - 570
|
16
|
+
|
17
|
+
# We track what we last sent as a metric payload so that
|
18
|
+
# we can do delta reporting
|
19
|
+
@last_values = {}
|
20
|
+
end
|
21
|
+
|
22
|
+
# Register an individual collector.
|
23
|
+
#
|
24
|
+
# @param [Object] the class of the collector to register
|
25
|
+
#
|
26
|
+
def register(klass)
|
27
|
+
::Instana.logger.debug "Adding #{klass} to collectors..."
|
28
|
+
@collectors << klass.new
|
29
|
+
end
|
30
|
+
|
31
|
+
# Resets the timer on when to send process snapshot data.
|
32
|
+
#
|
33
|
+
def reset_timer!
|
34
|
+
# Set last snapshot to 10 minutes ago
|
35
|
+
# so we send a snapshot on first report
|
36
|
+
@last_snapshot = Time.now - 601
|
37
|
+
end
|
38
|
+
|
39
|
+
##
|
40
|
+
# collect_and_report
|
41
|
+
#
|
42
|
+
# Run through each collector, let them collect up
|
43
|
+
# data and then report what we have via the agent
|
44
|
+
#
|
45
|
+
# @return Boolean true on success
|
46
|
+
#
|
47
|
+
def collect_and_report
|
48
|
+
payload = {}
|
49
|
+
with_snapshot = false
|
50
|
+
|
51
|
+
# Run through the registered collectors and
|
52
|
+
# get all the metrics
|
53
|
+
#
|
54
|
+
@collectors.each do |c|
|
55
|
+
metrics = c.collect
|
56
|
+
if metrics
|
57
|
+
payload[c.payload_key] = metrics
|
58
|
+
else
|
59
|
+
payload.delete(c.payload_key)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
# Every 5 minutes, send snapshot data as well
|
64
|
+
if (Time.now - @last_snapshot) > 600
|
65
|
+
with_snapshot = true
|
66
|
+
payload.merge!(@snapshot)
|
67
|
+
|
68
|
+
# Add in process related that could have changed since
|
69
|
+
# snapshot was taken.
|
70
|
+
p = { :pid => ::Instana.agent.report_pid }
|
71
|
+
p[:name] = ::Instana.agent.process[:name]
|
72
|
+
p[:exec_args] = ::Instana.agent.process[:arguments]
|
73
|
+
payload.merge!(p)
|
74
|
+
else
|
75
|
+
payload = enforce_deltas(payload, @last_values)
|
76
|
+
end
|
77
|
+
|
78
|
+
if ENV['INSTANA_GEM_TEST']
|
79
|
+
true
|
80
|
+
else
|
81
|
+
# Report all the collected goodies
|
82
|
+
if ::Instana.agent.report_metrics(payload) && with_snapshot
|
83
|
+
@last_snapshot = Time.now
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
# Take two hashes and enforce delta reporting.
|
89
|
+
# We only report when values change (instead of reporting all of
|
90
|
+
# the time). This is a recursive method.
|
91
|
+
#
|
92
|
+
# @param [Hash] the payload have delta reporting applied to
|
93
|
+
# @param [Hash] a hash of the last values reported
|
94
|
+
#
|
95
|
+
# @return [Hash] the candidate hash with delta reporting applied
|
96
|
+
#
|
97
|
+
def enforce_deltas(candidate, last)
|
98
|
+
candidate.each do |k,v|
|
99
|
+
if v.is_a?(Hash)
|
100
|
+
last[k] ||= {}
|
101
|
+
candidate[k] = enforce_deltas(candidate[k], last[k])
|
102
|
+
candidate.delete(k) if candidate[k].empty?
|
103
|
+
else
|
104
|
+
if last[k] == v
|
105
|
+
candidate.delete(k)
|
106
|
+
else
|
107
|
+
last[k] = candidate[k]
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
111
|
+
candidate
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
@@ -1,11 +1,10 @@
|
|
1
1
|
module Instana
|
2
|
-
module
|
2
|
+
module Collectors
|
3
3
|
class GC
|
4
4
|
attr_accessor :payload_key
|
5
5
|
|
6
6
|
def initialize
|
7
7
|
@payload_key = :gc
|
8
|
-
@last_report = {}
|
9
8
|
@this_gc = {}
|
10
9
|
@last_major_count = 0
|
11
10
|
@last_minor_count = 0
|
@@ -40,15 +39,7 @@ module Instana
|
|
40
39
|
# GC Heap
|
41
40
|
@this_gc[:heap_live] = stats[:heap_live_slot] || stats[:heap_live_slots] || stats[:heap_live_num]
|
42
41
|
@this_gc[:heap_free] = stats[:heap_free_slot] || stats[:heap_free_slots] || stats[:heap_free_num]
|
43
|
-
|
44
|
-
@this_gc = ::Instana::Util.enforce_deltas(@this_gc, @last_report)
|
45
|
-
|
46
|
-
unless @this_gc.empty?
|
47
|
-
@last_report.merge!(@this_gc)
|
48
|
-
@this_gc
|
49
|
-
else
|
50
|
-
nil
|
51
|
-
end
|
42
|
+
@this_gc
|
52
43
|
rescue => e
|
53
44
|
::Instana.logger.error "#{__method__}:#{File.basename(__FILE__)}:#{__LINE__}: #{e.message}"
|
54
45
|
::Instana.logger.debug e.backtrace.join("\r\n")
|
@@ -59,5 +50,5 @@ end
|
|
59
50
|
|
60
51
|
# Register the metrics collector if enabled
|
61
52
|
if ::Instana.config[:metrics][:gc][:enabled]
|
62
|
-
::Instana.
|
53
|
+
::Instana.collector.register(::Instana::Collectors::GC)
|
63
54
|
end
|
@@ -1,13 +1,12 @@
|
|
1
1
|
require 'get_process_mem'
|
2
2
|
|
3
3
|
module Instana
|
4
|
-
module
|
4
|
+
module Collectors
|
5
5
|
class Memory
|
6
6
|
attr_accessor :payload_key
|
7
7
|
|
8
8
|
def initialize
|
9
9
|
@payload_key = :memory
|
10
|
-
@last_report = {}
|
11
10
|
@this_mem = {}
|
12
11
|
end
|
13
12
|
|
@@ -16,17 +15,11 @@ module Instana
|
|
16
15
|
#
|
17
16
|
# To collect process memory usage.
|
18
17
|
#
|
18
|
+
# @return [Hash] a collection of metrics (if any)
|
19
|
+
#
|
19
20
|
def collect
|
20
|
-
@this_mem.clear
|
21
21
|
@this_mem[:rss_size] = ::GetProcessMem.new(Process.pid).kb
|
22
|
-
|
23
|
-
@this_mem = ::Instana::Util.enforce_deltas(@this_mem, @last_report)
|
24
|
-
unless @this_mem.empty?
|
25
|
-
@last_report.merge!(@this_mem)
|
26
|
-
@this_mem
|
27
|
-
else
|
28
|
-
nil
|
29
|
-
end
|
22
|
+
@this_mem
|
30
23
|
rescue => e
|
31
24
|
::Instana.logger.error "#{__method__}:#{File.basename(__FILE__)}:#{__LINE__}: #{e.message}"
|
32
25
|
::Instana.logger.debug e.backtrace.join("\r\n")
|
@@ -37,5 +30,5 @@ end
|
|
37
30
|
|
38
31
|
# Register the metrics collector if enabled
|
39
32
|
if ::Instana.config[:metrics][:memory][:enabled]
|
40
|
-
::Instana.
|
33
|
+
::Instana.collector.register(::Instana::Collectors::Memory)
|
41
34
|
end
|
@@ -1,11 +1,10 @@
|
|
1
1
|
module Instana
|
2
|
-
module
|
2
|
+
module Collectors
|
3
3
|
class Thread
|
4
4
|
attr_accessor :payload_key
|
5
5
|
|
6
6
|
def initialize
|
7
7
|
@payload_key = :thread
|
8
|
-
@last_report = {}
|
9
8
|
@this_count = {}
|
10
9
|
end
|
11
10
|
|
@@ -16,15 +15,7 @@ module Instana
|
|
16
15
|
#
|
17
16
|
def collect
|
18
17
|
@this_count[:count] = ::Thread.list.count
|
19
|
-
|
20
|
-
@this_count = ::Instana::Util.enforce_deltas(@this_count, @last_report)
|
21
|
-
|
22
|
-
unless @this_count.empty?
|
23
|
-
@last_report.merge!(@this_count)
|
24
|
-
@this_count
|
25
|
-
else
|
26
|
-
nil
|
27
|
-
end
|
18
|
+
@this_count
|
28
19
|
rescue => e
|
29
20
|
::Instana.logger.error "#{__method__}:#{File.basename(__FILE__)}:#{__LINE__}: #{e.message}"
|
30
21
|
::Instana.logger.debug e.backtrace.join("\r\n")
|
@@ -35,5 +26,5 @@ end
|
|
35
26
|
|
36
27
|
# Register the metrics collector if enabled
|
37
28
|
if ::Instana.config[:metrics][:thread][:enabled]
|
38
|
-
::Instana.
|
29
|
+
::Instana.collector.register(::Instana::Collectors::Thread)
|
39
30
|
end
|
data/lib/instana/config.rb
CHANGED
@@ -10,12 +10,20 @@ module Instana
|
|
10
10
|
@config[:metrics][:memory] = { :enabled => true }
|
11
11
|
@config[:metrics][:thread] = { :enabled => true }
|
12
12
|
|
13
|
+
if ENV.key?('INSTANA_GEM_DEV')
|
14
|
+
@config[:collector] = { :enabled => true, :interval => 3 }
|
15
|
+
else
|
16
|
+
@config[:collector] = { :enabled => true, :interval => 1 }
|
17
|
+
end
|
18
|
+
|
13
19
|
# EUM Related
|
14
20
|
@config[:eum_api_key] = nil
|
15
21
|
@config[:eum_baggage] = {}
|
16
22
|
|
17
23
|
# HTTP Clients
|
18
|
-
@config[:excon]
|
24
|
+
@config[:excon] = { :enabled => true }
|
25
|
+
@config[:nethttp] = { :enabled => true }
|
26
|
+
@config[:'rest-client'] = { :enabled => true }
|
19
27
|
end
|
20
28
|
|
21
29
|
def [](key)
|
@@ -1,63 +1,65 @@
|
|
1
1
|
require 'net/http'
|
2
2
|
|
3
|
-
Net::HTTP.
|
3
|
+
if defined?(::Net::HTTP) && ::Instana.config[:nethttp][:enabled]
|
4
|
+
Net::HTTP.class_eval {
|
4
5
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
6
|
+
def request_with_instana(*args, &block)
|
7
|
+
if !Instana.tracer.tracing? || !started?
|
8
|
+
return request_without_instana(*args, &block)
|
9
|
+
end
|
9
10
|
|
10
|
-
|
11
|
+
::Instana.tracer.log_entry(:'net-http')
|
11
12
|
|
12
|
-
|
13
|
-
|
13
|
+
# Send out the tracing context with the request
|
14
|
+
request = args[0]
|
14
15
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
16
|
+
# Set request headers; encode IDs as hexadecimal strings
|
17
|
+
t_context = ::Instana.tracer.context
|
18
|
+
request['X-Instana-T'] = t_context.trace_id_header
|
19
|
+
request['X-Instana-S'] = t_context.span_id_header
|
19
20
|
|
20
|
-
|
21
|
-
|
22
|
-
|
21
|
+
# Collect up KV info now in case any exception is raised
|
22
|
+
kv_payload = { :http => {} }
|
23
|
+
kv_payload[:http][:method] = request.method
|
23
24
|
|
24
|
-
|
25
|
-
|
26
|
-
else
|
27
|
-
if use_ssl?
|
28
|
-
kv_payload[:http][:url] = "https://#{@address}:#{@port}#{request.path}"
|
25
|
+
if request.uri
|
26
|
+
kv_payload[:http][:url] = request.uri.to_s
|
29
27
|
else
|
30
|
-
|
28
|
+
if use_ssl?
|
29
|
+
kv_payload[:http][:url] = "https://#{@address}:#{@port}#{request.path}"
|
30
|
+
else
|
31
|
+
kv_payload[:http][:url] = "http://#{@address}:#{@port}#{request.path}"
|
32
|
+
end
|
31
33
|
end
|
32
|
-
end
|
33
34
|
|
34
|
-
|
35
|
-
|
35
|
+
# The core call
|
36
|
+
response = request_without_instana(*args, &block)
|
36
37
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
38
|
+
# Pickup response headers; convert back to base 10 integer
|
39
|
+
if ::Instana.debug? && response.key?('X-Instana-T')
|
40
|
+
if ::Instana.tracer.trace_id != ::Instana.tracer.header_to_id(response.header['X-Instana-T'])
|
41
|
+
::Instana.logger.debug "#{Thread.current}: Trace ID mismatch on net/http response! ours: #{::Instana.tracer.trace_id} theirs: #{their_trace_id}"
|
42
|
+
end
|
41
43
|
end
|
42
|
-
end
|
43
44
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
45
|
+
kv_payload[:http][:status] = response.code
|
46
|
+
if response.code.to_i.between?(500, 511)
|
47
|
+
# Because of the 5xx response, we flag this span as errored but
|
48
|
+
# without a backtrace (no exception)
|
49
|
+
add_error(nil)
|
50
|
+
end
|
50
51
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
52
|
+
response
|
53
|
+
rescue => e
|
54
|
+
::Instana.tracer.log_error(e)
|
55
|
+
raise
|
56
|
+
ensure
|
57
|
+
::Instana.tracer.log_exit(:'net-http', kv_payload)
|
58
|
+
end
|
58
59
|
|
59
|
-
|
60
|
+
Instana.logger.warn "Instrumenting Net::HTTP"
|
60
61
|
|
61
|
-
|
62
|
-
|
63
|
-
}
|
62
|
+
alias request_without_instana request
|
63
|
+
alias request request_with_instana
|
64
|
+
}
|
65
|
+
end
|
@@ -28,7 +28,7 @@ module Instana
|
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
31
|
-
if defined?(::RestClient::Request)
|
31
|
+
if defined?(::RestClient::Request) && ::Instana.config[:'rest-client'][:enabled]
|
32
32
|
::Instana.logger.warn "Instrumenting RestClient"
|
33
33
|
::RestClient::Request.send(:include, ::Instana::Instrumentation::RestClientRequest)
|
34
34
|
end
|
data/lib/instana/setup.rb
CHANGED
@@ -1,16 +1,19 @@
|
|
1
1
|
require "instana/base"
|
2
2
|
require "instana/config"
|
3
3
|
require "instana/agent"
|
4
|
+
require "instana/collector"
|
4
5
|
require "instana/tracer"
|
5
6
|
require "instana/tracing/processor"
|
6
|
-
|
7
|
-
::Instana.setup
|
8
|
-
|
9
|
-
require "instana/collectors"
|
10
7
|
require "instana/instrumentation"
|
11
8
|
|
9
|
+
::Instana.setup
|
12
10
|
::Instana.agent.setup
|
13
11
|
|
12
|
+
# Register the metric collectors
|
13
|
+
require 'instana/collectors/gc'
|
14
|
+
require 'instana/collectors/memory'
|
15
|
+
require 'instana/collectors/thread'
|
16
|
+
|
14
17
|
# Require supported OpenTracing interfaces
|
15
18
|
require "opentracing"
|
16
19
|
|
data/lib/instana/util.rb
CHANGED
@@ -39,24 +39,6 @@ module Instana
|
|
39
39
|
target_cls.send(:include, cls) if defined?(target_cls)
|
40
40
|
end
|
41
41
|
|
42
|
-
# Take two hashes, and make sure candidate does not have
|
43
|
-
# any of the same values as `last`. We only report
|
44
|
-
# when values change.
|
45
|
-
#
|
46
|
-
# Note this is not recursive, so only pass in the single
|
47
|
-
# hashes that you want delta reporting with.
|
48
|
-
#
|
49
|
-
def enforce_deltas(candidate, last)
|
50
|
-
return unless last.is_a?(Hash)
|
51
|
-
|
52
|
-
candidate.each do |k,v|
|
53
|
-
if candidate[k] == last[k]
|
54
|
-
candidate.delete(k)
|
55
|
-
end
|
56
|
-
end
|
57
|
-
candidate
|
58
|
-
end
|
59
|
-
|
60
42
|
# Debugging helper method
|
61
43
|
#
|
62
44
|
def pry!
|
data/lib/instana/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: instana
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Peter Giacomo Lombardo
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-01-
|
11
|
+
date: 2017-01-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -132,7 +132,7 @@ files:
|
|
132
132
|
- lib/instana.rb
|
133
133
|
- lib/instana/agent.rb
|
134
134
|
- lib/instana/base.rb
|
135
|
-
- lib/instana/
|
135
|
+
- lib/instana/collector.rb
|
136
136
|
- lib/instana/collectors/gc.rb
|
137
137
|
- lib/instana/collectors/memory.rb
|
138
138
|
- lib/instana/collectors/thread.rb
|
data/lib/instana/collectors.rb
DELETED
@@ -1,46 +0,0 @@
|
|
1
|
-
require 'timers'
|
2
|
-
require 'instana/collectors/gc'
|
3
|
-
require 'instana/collectors/memory'
|
4
|
-
require 'instana/collectors/thread'
|
5
|
-
|
6
|
-
module Instana
|
7
|
-
module Collector
|
8
|
-
class << self
|
9
|
-
attr_accessor :interval
|
10
|
-
|
11
|
-
##
|
12
|
-
# collect_and_report
|
13
|
-
#
|
14
|
-
# Run through each collector, let them collect up
|
15
|
-
# data and then report what we have via the agent
|
16
|
-
#
|
17
|
-
# @return Boolean true on success
|
18
|
-
#
|
19
|
-
def collect_and_report
|
20
|
-
payload = {}
|
21
|
-
|
22
|
-
::Instana.collectors.each do |c|
|
23
|
-
metrics = c.collect
|
24
|
-
if metrics
|
25
|
-
payload[c.payload_key] = metrics
|
26
|
-
else
|
27
|
-
payload.delete(c.payload_key)
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
if ENV['INSTANA_GEM_TEST']
|
32
|
-
true
|
33
|
-
else
|
34
|
-
# Report all the collected goodies
|
35
|
-
::Instana.agent.report_entity_data(payload)
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
if ENV.key?('INSTANA_GEM_DEV')
|
43
|
-
::Instana::Collector.interval = 3
|
44
|
-
else
|
45
|
-
::Instana::Collector.interval = 1
|
46
|
-
end
|