instana 1.3.1 → 1.3.2
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/Configuration.md +19 -1
- data/lib/instana/collector.rb +2 -0
- data/lib/instana/config.rb +19 -1
- data/lib/instana/logger.rb +1 -1
- data/lib/instana/tracer.rb +12 -4
- data/lib/instana/version.rb +1 -1
- data/test/config_test.rb +20 -0
- data/test/tracing/tracer_test.rb +15 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 44d2db00220595e42136a421be4f1d9d149fb958
|
4
|
+
data.tar.gz: 0e52f23d95fbfdf296c4632da28319d170298ca9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1e753d5fbd1c60c52afaa5a8219ee5c4e980dff40c22d27ccfc719ffc4068c72dae09e8a7fe5e072b30aa63e6a4fd5b240af054444df2a7f4a6a1a7b333aed05
|
7
|
+
data.tar.gz: 768f34f163485454e6371ab0ce2b39e44020a19ff44a9efe5a107b9efe282574f9cdcd6c62893a473fd86e323cb94438f2a751e06063e45cadc0c286c3ccf1a8
|
data/Configuration.md
CHANGED
@@ -1,6 +1,24 @@
|
|
1
1
|
# Configuration
|
2
2
|
|
3
|
-
##
|
3
|
+
## Global Enable/Disable
|
4
|
+
|
5
|
+
The entire gem can be disabled at runtime with:
|
6
|
+
|
7
|
+
```Ruby
|
8
|
+
::Instana.config[:enabled] = false # default: true
|
9
|
+
```
|
10
|
+
|
11
|
+
Other global enable/disable options are:
|
12
|
+
|
13
|
+
```Ruby
|
14
|
+
# Enable/Disable metrics collection and reporting
|
15
|
+
Instana.config[:metrics][:enabled] # default true
|
16
|
+
|
17
|
+
# Enable/Disable tracing
|
18
|
+
Instana.config[:tracing][:enabled] # default true
|
19
|
+
```
|
20
|
+
|
21
|
+
## Enabling/Disabling Individual Components
|
4
22
|
|
5
23
|
Individual components can be enabled and disabled with a local config.
|
6
24
|
|
data/lib/instana/collector.rb
CHANGED
data/lib/instana/config.rb
CHANGED
@@ -3,13 +3,24 @@ module Instana
|
|
3
3
|
|
4
4
|
def initialize
|
5
5
|
@config = {}
|
6
|
+
|
6
7
|
@config[:agent_host] = '127.0.0.1'
|
7
8
|
@config[:agent_port] = 42699
|
8
|
-
|
9
|
+
|
10
|
+
# Global on/off switch for prebuilt environments
|
11
|
+
# Setting this to false will disable this gem
|
12
|
+
# from doing anything.
|
13
|
+
@config[:enabled] = true
|
14
|
+
|
15
|
+
# Enable/disable metrics globally or individually (default: all enabled)
|
16
|
+
@config[:metrics] = { :enabled => true }
|
9
17
|
@config[:metrics][:gc] = { :enabled => true }
|
10
18
|
@config[:metrics][:memory] = { :enabled => true }
|
11
19
|
@config[:metrics][:thread] = { :enabled => true }
|
12
20
|
|
21
|
+
# Enable/disable tracing (default: enabled)
|
22
|
+
@config[:tracing] = { :enabled => true }
|
23
|
+
|
13
24
|
if ENV.key?('INSTANA_GEM_DEV')
|
14
25
|
@config[:collector] = { :enabled => true, :interval => 3 }
|
15
26
|
else
|
@@ -36,6 +47,13 @@ module Instana
|
|
36
47
|
|
37
48
|
def []=(key, value)
|
38
49
|
@config[key.to_sym] = value
|
50
|
+
|
51
|
+
if key == :enabled
|
52
|
+
# Configuring global enable/disable flag, then set the
|
53
|
+
# appropriate children flags.
|
54
|
+
@config[:metrics][:enabled] = value
|
55
|
+
@config[:tracing][:enabled] = value
|
56
|
+
end
|
39
57
|
end
|
40
58
|
end
|
41
59
|
end
|
data/lib/instana/logger.rb
CHANGED
@@ -6,6 +6,7 @@ module Instana
|
|
6
6
|
STAMP = "Instana: ".freeze
|
7
7
|
|
8
8
|
def initialize(*args)
|
9
|
+
super(*args)
|
9
10
|
if ENV.key?('INSTANA_GEM_TEST')
|
10
11
|
self.level = Logger::DEBUG
|
11
12
|
elsif ENV.key?('INSTANA_GEM_DEV')
|
@@ -14,7 +15,6 @@ module Instana
|
|
14
15
|
else
|
15
16
|
self.level = Logger::WARN
|
16
17
|
end
|
17
|
-
super(*args)
|
18
18
|
end
|
19
19
|
|
20
20
|
# Sets the debug level for this logger. The debug level is broken up into various
|
data/lib/instana/tracer.rb
CHANGED
@@ -72,7 +72,7 @@ module Instana
|
|
72
72
|
# :level specifies data collection level (optional)
|
73
73
|
#
|
74
74
|
def log_start_or_continue(name, kvs = {}, incoming_context = {})
|
75
|
-
return
|
75
|
+
return if !::Instana.agent.ready? || !::Instana.config[:tracing][:enabled]
|
76
76
|
::Instana.logger.debug "#{__method__} passed a block. Use `start_or_continue` instead!" if block_given?
|
77
77
|
self.current_trace = ::Instana::Trace.new(name, kvs, incoming_context)
|
78
78
|
end
|
@@ -191,7 +191,11 @@ module Instana
|
|
191
191
|
self.current_trace.add_async_info(kvs, span)
|
192
192
|
else
|
193
193
|
trace = ::Instana.processor.staged_trace(span.context.trace_id)
|
194
|
-
trace
|
194
|
+
if trace
|
195
|
+
trace.add_async_info(kvs, span)
|
196
|
+
else
|
197
|
+
::Instana.logger.debug "#{__method__}: Couldn't find staged trace. #{span.inspect}"
|
198
|
+
end
|
195
199
|
end
|
196
200
|
end
|
197
201
|
|
@@ -210,7 +214,11 @@ module Instana
|
|
210
214
|
self.current_trace.add_async_error(e, span)
|
211
215
|
else
|
212
216
|
trace = ::Instana.processor.staged_trace(span.context.trace_id)
|
213
|
-
trace
|
217
|
+
if trace
|
218
|
+
trace.add_async_error(e, span)
|
219
|
+
else
|
220
|
+
::Instana.logger.debug "#{__method__}: Couldn't find staged trace. #{span.inspect}"
|
221
|
+
end
|
214
222
|
end
|
215
223
|
end
|
216
224
|
|
@@ -235,7 +243,7 @@ module Instana
|
|
235
243
|
if trace
|
236
244
|
trace.end_async_span(kvs, span)
|
237
245
|
else
|
238
|
-
::Instana.logger.debug "
|
246
|
+
::Instana.logger.debug "#{__method__}: Couldn't find staged trace. #{span.inspect}"
|
239
247
|
end
|
240
248
|
end
|
241
249
|
end
|
data/lib/instana/version.rb
CHANGED
data/test/config_test.rb
CHANGED
@@ -10,8 +10,28 @@ class ConfigTest < Minitest::Test
|
|
10
10
|
assert_equal '127.0.0.1', ::Instana.config[:agent_host]
|
11
11
|
assert_equal 42699, ::Instana.config[:agent_port]
|
12
12
|
|
13
|
+
assert ::Instana.config[:enabled]
|
14
|
+
assert ::Instana.config[:tracing][:enabled]
|
15
|
+
assert ::Instana.config[:metrics][:enabled]
|
16
|
+
|
13
17
|
::Instana.config[:metrics].each do |k, v|
|
14
18
|
assert_equal true, ::Instana.config[:metrics][k].key?(:enabled)
|
15
19
|
end
|
16
20
|
end
|
21
|
+
|
22
|
+
def test_that_global_affects_children
|
23
|
+
# Disabling the gem should explicitly disable
|
24
|
+
# metrics and tracing flags
|
25
|
+
::Instana.config[:enabled] = false
|
26
|
+
|
27
|
+
assert_equal false, ::Instana.config[:tracing][:enabled]
|
28
|
+
assert_equal false, ::Instana.config[:metrics][:enabled]
|
29
|
+
|
30
|
+
# Enabling the gem should explicitly enable
|
31
|
+
# metrics and tracing flags
|
32
|
+
::Instana.config[:enabled] = true
|
33
|
+
|
34
|
+
assert_equal ::Instana.config[:tracing][:enabled]
|
35
|
+
assert_equal ::Instana.config[:metrics][:enabled]
|
36
|
+
end
|
17
37
|
end
|
data/test/tracing/tracer_test.rb
CHANGED
@@ -6,6 +6,20 @@ class TracerTest < Minitest::Test
|
|
6
6
|
assert ::Instana.tracer.is_a?(::Instana::Tracer)
|
7
7
|
end
|
8
8
|
|
9
|
+
def test_obey_tracing_config
|
10
|
+
clear_all!
|
11
|
+
|
12
|
+
::Instana.config[:tracing][:enabled] = false
|
13
|
+
assert_equal false, ::Instana.tracer.tracing?
|
14
|
+
|
15
|
+
::Instana.tracer.start_or_continue_trace(:rack, {:one => 1}) do
|
16
|
+
assert_equal false, ::Instana.tracer.tracing?
|
17
|
+
end
|
18
|
+
|
19
|
+
::Instana.config[:tracing][:enabled] = true
|
20
|
+
end
|
21
|
+
|
22
|
+
|
9
23
|
def test_basic_trace_block
|
10
24
|
clear_all!
|
11
25
|
|
@@ -13,7 +27,7 @@ class TracerTest < Minitest::Test
|
|
13
27
|
|
14
28
|
::Instana.tracer.start_or_continue_trace(:rack, {:one => 1}) do
|
15
29
|
assert_equal true, ::Instana.tracer.tracing?
|
16
|
-
sleep 0.
|
30
|
+
sleep 0.3
|
17
31
|
end
|
18
32
|
|
19
33
|
traces = ::Instana.processor.queued_traces
|
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.3.
|
4
|
+
version: 1.3.2
|
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-
|
11
|
+
date: 2017-02-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|