instana 1.195.2 → 1.197.0
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/.rubocop.yml +6 -2
- data/Rakefile +1 -1
- data/instana.gemspec +3 -7
- data/lib/instana.rb +3 -0
- data/lib/instana/activator.rb +2 -0
- data/lib/instana/backend/agent.rb +60 -0
- data/lib/instana/backend/gc_snapshot.rb +41 -0
- data/lib/instana/backend/host_agent.rb +74 -0
- data/lib/instana/backend/host_agent_activation_observer.rb +97 -0
- data/lib/instana/backend/host_agent_lookup.rb +57 -0
- data/lib/instana/backend/host_agent_reporting_observer.rb +106 -0
- data/lib/instana/backend/process_info.rb +64 -0
- data/lib/instana/backend/request_client.rb +73 -0
- data/lib/instana/backend/serverless_agent.rb +118 -0
- data/lib/instana/base.rb +8 -27
- data/lib/instana/config.rb +8 -22
- data/lib/instana/instrumentation/excon.rb +17 -8
- data/lib/instana/instrumentation/instrumented_request.rb +62 -7
- data/lib/instana/instrumentation/net-http.rb +7 -5
- data/lib/instana/instrumentation/rack.rb +12 -7
- data/lib/instana/logger_delegator.rb +31 -0
- data/lib/instana/{opentracing → open_tracing}/carrier.rb +0 -0
- data/lib/instana/open_tracing/instana_tracer.rb +99 -0
- data/lib/instana/secrets.rb +6 -2
- data/lib/instana/setup.rb +20 -11
- data/lib/instana/snapshot/deltable.rb +25 -0
- data/lib/instana/snapshot/docker_container.rb +151 -0
- data/lib/instana/snapshot/fargate_container.rb +88 -0
- data/lib/instana/snapshot/fargate_process.rb +67 -0
- data/lib/instana/snapshot/fargate_task.rb +72 -0
- data/lib/instana/snapshot/lambda_function.rb +36 -0
- data/lib/instana/snapshot/ruby_process.rb +48 -0
- data/lib/instana/tracer.rb +25 -143
- data/lib/instana/tracing/processor.rb +14 -22
- data/lib/instana/tracing/span.rb +31 -34
- data/lib/instana/tracing/span_context.rb +15 -10
- data/lib/instana/util.rb +8 -69
- data/lib/instana/version.rb +1 -1
- data/lib/opentracing.rb +26 -3
- data/test/backend/agent_test.rb +54 -0
- data/test/backend/gc_snapshot_test.rb +11 -0
- data/test/backend/host_agent_activation_observer_test.rb +72 -0
- data/test/backend/host_agent_lookup_test.rb +78 -0
- data/test/backend/host_agent_reporting_observer_test.rb +192 -0
- data/test/backend/host_agent_test.rb +47 -0
- data/test/backend/process_info_test.rb +63 -0
- data/test/backend/request_client_test.rb +39 -0
- data/test/backend/serverless_agent_test.rb +73 -0
- data/test/config_test.rb +10 -0
- data/test/instana_test.rb +11 -4
- data/test/instrumentation/excon_test.rb +15 -1
- data/test/instrumentation/rack_instrumented_request_test.rb +5 -2
- data/test/instrumentation/rack_test.rb +2 -14
- data/test/secrets_test.rb +41 -22
- data/test/snapshot/deltable_test.rb +17 -0
- data/test/snapshot/docker_container_test.rb +82 -0
- data/test/snapshot/fargate_container_test.rb +82 -0
- data/test/snapshot/fargate_process_test.rb +35 -0
- data/test/snapshot/fargate_task_test.rb +49 -0
- data/test/snapshot/ruby_process_test.rb +14 -0
- data/test/support/mock_timer.rb +20 -0
- data/test/test_helper.rb +16 -4
- data/test/tracing/custom_test.rb +1 -3
- data/test/tracing/id_management_test.rb +4 -0
- data/test/tracing/opentracing_test.rb +15 -2
- data/test/tracing/processor_test.rb +58 -0
- data/test/tracing/span_context_test.rb +21 -0
- data/test/tracing/span_test.rb +136 -0
- data/test/tracing/tracer_async_test.rb +29 -0
- data/test/tracing/tracer_test.rb +82 -16
- data/test/util_test.rb +10 -0
- metadata +71 -43
- data/lib/instana/agent.rb +0 -508
- data/lib/instana/agent/helpers.rb +0 -87
- data/lib/instana/agent/hooks.rb +0 -44
- data/lib/instana/agent/tasks.rb +0 -51
- data/lib/instana/collector.rb +0 -119
- data/lib/instana/collectors/gc.rb +0 -60
- data/lib/instana/collectors/memory.rb +0 -37
- data/lib/instana/collectors/thread.rb +0 -33
- data/lib/instana/eum/eum-test.js.erb +0 -17
- data/lib/instana/eum/eum.js.erb +0 -17
- data/lib/instana/helpers.rb +0 -47
- data/lib/instana/opentracing/tracer.rb +0 -21
- data/lib/instana/thread_local.rb +0 -18
- data/lib/oj_check.rb +0 -19
- data/test/agent/agent_test.rb +0 -151
data/lib/instana/eum/eum.js.erb
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
<script>
|
2
|
-
(function(c,e,f,k,g,h,b,a,d){c[g]||(c[g]=h,b=c[h]=function(){
|
3
|
-
b.q.push(arguments)},b.q=[],b.l=1*new Date,a=e.createElement(f),a.async=1,
|
4
|
-
a.src=k,a.setAttribute("crossorigin", "anonymous"),d=e.getElementsByTagName(f)[0],
|
5
|
-
d.parentNode.insertBefore(a,d))})(window,document,"script",
|
6
|
-
"//eum.instana.io/eum.min.js","InstanaEumObject","ineum");
|
7
|
-
|
8
|
-
ineum('reportingUrl', 'https://eum-saas.instana.io');
|
9
|
-
ineum('key', '<%=::Instana.config[:eum_api_key]%>');
|
10
|
-
ineum('traceId', '<%=::Instana.tracer.trace_id_header%>');
|
11
|
-
|
12
|
-
<% if !::Instana.config[:eum_baggage].empty? %>
|
13
|
-
<% ::Instana.config[:eum_baggage].each do |k, v| %>
|
14
|
-
ineum('meta', '<%=k%>', '<%=v%>');
|
15
|
-
<% end %>
|
16
|
-
<% end %>
|
17
|
-
</script>
|
data/lib/instana/helpers.rb
DELETED
@@ -1,47 +0,0 @@
|
|
1
|
-
# (c) Copyright IBM Corp. 2021
|
2
|
-
# (c) Copyright Instana Inc. 2016
|
3
|
-
|
4
|
-
module Instana
|
5
|
-
module Helpers
|
6
|
-
EUM_SNIPPET= (File.read(File.dirname(__FILE__) + '/eum/eum.js.erb')).freeze
|
7
|
-
EUM_TEST_SNIPPET= (File.read(File.dirname(__FILE__) + '/eum/eum-test.js.erb')).freeze
|
8
|
-
|
9
|
-
class << self
|
10
|
-
|
11
|
-
# Returns a processed javascript snippet to be placed within the HEAD tag of an HTML page.
|
12
|
-
#
|
13
|
-
# DEPRECATED: This method will be removed in a future version.
|
14
|
-
#
|
15
|
-
def eum_snippet(api_key, kvs = {})
|
16
|
-
return nil if !::Instana.tracer.tracing?
|
17
|
-
|
18
|
-
::Instana.config[:eum_api_key] = api_key
|
19
|
-
::Instana.config[:eum_baggage] = kvs
|
20
|
-
|
21
|
-
ERB.new(EUM_SNIPPET).result
|
22
|
-
rescue => e
|
23
|
-
Instana.logger.info "#{__method__}:#{File.basename(__FILE__)}:#{__LINE__}: #{e.message}"
|
24
|
-
Instana.logger.debug { e.backtrace.join("\r\n") }
|
25
|
-
return nil
|
26
|
-
end
|
27
|
-
|
28
|
-
# Returns a processed javascript snippet to be placed within the HEAD tag of an HTML page.
|
29
|
-
# This one is used for testing only
|
30
|
-
#
|
31
|
-
# DEPRECATED: This method will be removed in a future version.
|
32
|
-
#
|
33
|
-
def eum_test_snippet(api_key, kvs = {})
|
34
|
-
return nil if !::Instana.tracer.tracing?
|
35
|
-
|
36
|
-
::Instana.config[:eum_api_key] = api_key
|
37
|
-
::Instana.config[:eum_baggage] = kvs
|
38
|
-
|
39
|
-
ERB.new(EUM_TEST_SNIPPET).result
|
40
|
-
rescue => e
|
41
|
-
Instana.logger.info "#{__method__}:#{File.basename(__FILE__)}:#{__LINE__}: #{e.message}"
|
42
|
-
Instana.logger.debug { e.backtrace.join("\r\n") }
|
43
|
-
return nil
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
# (c) Copyright IBM Corp. 2021
|
2
|
-
# (c) Copyright Instana Inc. 2017
|
3
|
-
|
4
|
-
module OpenTracing
|
5
|
-
class << self
|
6
|
-
# Text format for #inject and #extract
|
7
|
-
FORMAT_TEXT_MAP = 1
|
8
|
-
|
9
|
-
# Binary format for #inject and #extract
|
10
|
-
FORMAT_BINARY = 2
|
11
|
-
|
12
|
-
# Ruby Specific format to handle how Rack changes environment variables.
|
13
|
-
FORMAT_RACK = 3
|
14
|
-
|
15
|
-
attr_accessor :global_tracer
|
16
|
-
|
17
|
-
def method_missing(method_name, *args, &block)
|
18
|
-
@global_tracer.send(method_name, *args, &block)
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
data/lib/instana/thread_local.rb
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
# (c) Copyright IBM Corp. 2021
|
2
|
-
# (c) Copyright Instana Inc. 2016
|
3
|
-
|
4
|
-
module Instana
|
5
|
-
module ThreadLocal
|
6
|
-
def thread_local(name)
|
7
|
-
key = "__#{self}_#{name}__".intern
|
8
|
-
|
9
|
-
define_method(name) do
|
10
|
-
Thread.current[key]
|
11
|
-
end
|
12
|
-
|
13
|
-
define_method(name.to_s + '=') do |value|
|
14
|
-
Thread.current[key] = value
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
data/lib/oj_check.rb
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
# (c) Copyright IBM Corp. 2021
|
2
|
-
# (c) Copyright Instana Inc. 2019
|
3
|
-
|
4
|
-
begin
|
5
|
-
require 'oj'
|
6
|
-
rescue LoadError => e
|
7
|
-
# OJ is not available in JRuby
|
8
|
-
module Instana
|
9
|
-
class Oj
|
10
|
-
def self.dump(*args)
|
11
|
-
args.first.to_json
|
12
|
-
end
|
13
|
-
|
14
|
-
def self.load(*args)
|
15
|
-
JSON.parse args.first
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
data/test/agent/agent_test.rb
DELETED
@@ -1,151 +0,0 @@
|
|
1
|
-
# (c) Copyright IBM Corp. 2021
|
2
|
-
# (c) Copyright Instana Inc. 2016
|
3
|
-
|
4
|
-
require 'test_helper'
|
5
|
-
require './lib/oj_check'
|
6
|
-
|
7
|
-
class AgentTest < Minitest::Test
|
8
|
-
|
9
|
-
Oj = ::Instana::Oj unless defined?(Oj)
|
10
|
-
|
11
|
-
def teardown
|
12
|
-
WebMock.reset!
|
13
|
-
::Instana.agent.instance_variable_set(:@discovered, nil)
|
14
|
-
end
|
15
|
-
|
16
|
-
def test_agent_host_detection
|
17
|
-
url = "http://#{::Instana.config[:agent_host]}:#{::Instana.config[:agent_port]}/"
|
18
|
-
stub_request(:get, url)
|
19
|
-
assert_equal true, ::Instana.agent.host_agent_available?
|
20
|
-
end
|
21
|
-
|
22
|
-
def test_successful_discovery
|
23
|
-
url = "http://#{::Instana.config[:agent_host]}:#{::Instana.config[:agent_port]}/"
|
24
|
-
docker_url = "http://#{::Instana.agent.instance_variable_get(:@default_gateway)}:#{::Instana.config[:agent_port]}/"
|
25
|
-
stub_request(:get, url)
|
26
|
-
stub_request(:get, docker_url)
|
27
|
-
discovered = ::Instana.agent.run_discovery
|
28
|
-
|
29
|
-
assert discovered.is_a?(Hash)
|
30
|
-
assert_equal "127.0.0.1", discovered[:agent_host]
|
31
|
-
assert_equal 42699, discovered[:agent_port]
|
32
|
-
end
|
33
|
-
|
34
|
-
def test_failed_discovery
|
35
|
-
url = "http://#{::Instana.config[:agent_host]}:#{::Instana.config[:agent_port]}/"
|
36
|
-
docker_url = "http://#{::Instana.agent.instance_variable_get(:@default_gateway)}:#{::Instana.config[:agent_port]}/"
|
37
|
-
stub_request(:get, url).to_raise(Errno::ECONNREFUSED)
|
38
|
-
stub_request(:get, docker_url).to_raise(Errno::ECONNREFUSED)
|
39
|
-
|
40
|
-
discovered = ::Instana.agent.run_discovery
|
41
|
-
|
42
|
-
assert_equal nil, discovered
|
43
|
-
end
|
44
|
-
|
45
|
-
def test_custom_configure_agent
|
46
|
-
original_host = ::Instana.config[:agent_host]
|
47
|
-
original_port = ::Instana.config[:agent_port]
|
48
|
-
|
49
|
-
# Set custom agent/port
|
50
|
-
::Instana.config[:agent_host] = '172.0.12.100'
|
51
|
-
::Instana.config[:agent_port] = 12829
|
52
|
-
|
53
|
-
url = "http://#{::Instana.config[:agent_host]}:#{::Instana.config[:agent_port]}/"
|
54
|
-
stub_request(:get, url)
|
55
|
-
discovered = ::Instana.agent.run_discovery
|
56
|
-
|
57
|
-
assert discovered.is_a?(Hash)
|
58
|
-
assert_equal "172.0.12.100", discovered[:agent_host]
|
59
|
-
assert_equal 12829, discovered[:agent_port]
|
60
|
-
|
61
|
-
::Instana.config[:agent_host] = original_host
|
62
|
-
::Instana.config[:agent_port] = original_port
|
63
|
-
end
|
64
|
-
|
65
|
-
def test_no_host_agent
|
66
|
-
localhost_url = "http://#{::Instana::Agent::LOCALHOST}:#{::Instana.config[:agent_port]}/"
|
67
|
-
stub_request(:get, localhost_url).to_raise(Errno::ECONNREFUSED)
|
68
|
-
docker_url = "http://#{::Instana.agent.instance_variable_get(:@default_gateway)}:#{::Instana.config[:agent_port]}/"
|
69
|
-
stub_request(:get, docker_url).to_timeout
|
70
|
-
assert_equal false, ::Instana.agent.host_agent_available?
|
71
|
-
end
|
72
|
-
|
73
|
-
def test_announce_sensor
|
74
|
-
# Fake discovery values
|
75
|
-
discovery = {}
|
76
|
-
discovery[:agent_host] = ::Instana.config[:agent_host]
|
77
|
-
discovery[:agent_port] = ::Instana.config[:agent_port]
|
78
|
-
::Instana.agent.instance_variable_set(:@discovered, discovery)
|
79
|
-
|
80
|
-
url = "http://#{::Instana.config[:agent_host]}:#{::Instana.config[:agent_port]}/com.instana.plugin.ruby.discovery"
|
81
|
-
json = Oj.dump({ 'pid' => Process.pid, 'agentUuid' => 'abc' })
|
82
|
-
stub_request(:put, url).to_return(:body => json, :status => 200)
|
83
|
-
|
84
|
-
assert_equal true, ::Instana.agent.announce_sensor
|
85
|
-
end
|
86
|
-
|
87
|
-
def test_failed_announce_sensor
|
88
|
-
# Fake discovery values
|
89
|
-
discovery = {}
|
90
|
-
discovery[:agent_host] = ::Instana.config[:agent_host]
|
91
|
-
discovery[:agent_port] = ::Instana.config[:agent_port]
|
92
|
-
::Instana.agent.instance_variable_set(:@discovered, discovery)
|
93
|
-
|
94
|
-
url = "http://#{::Instana.config[:agent_host]}:#{::Instana.config[:agent_port]}/com.instana.plugin.ruby.discovery"
|
95
|
-
stub_request(:put, url).to_raise(Errno::ECONNREFUSED)
|
96
|
-
|
97
|
-
assert_equal false, ::Instana.agent.announce_sensor
|
98
|
-
end
|
99
|
-
|
100
|
-
def test_metric_report
|
101
|
-
# Fake discovery values
|
102
|
-
discovery = {}
|
103
|
-
discovery[:agent_host] = ::Instana.config[:agent_host]
|
104
|
-
discovery[:agent_port] = ::Instana.config[:agent_port]
|
105
|
-
::Instana.agent.instance_variable_set(:@discovered, discovery)
|
106
|
-
|
107
|
-
url = "http://#{::Instana.config[:agent_host]}:#{::Instana.config[:agent_port]}/com.instana.plugin.ruby.discovery"
|
108
|
-
json = Oj.dump({ 'pid' => Process.pid, 'agentUuid' => 'abc' })
|
109
|
-
stub_request(:put, url).to_return(:body => json, :status => 200)
|
110
|
-
::Instana.agent.announce_sensor
|
111
|
-
|
112
|
-
url = "http://#{::Instana.config[:agent_host]}:#{::Instana.config[:agent_port]}/com.instana.plugin.ruby.#{Process.pid}"
|
113
|
-
stub_request(:post, url)
|
114
|
-
|
115
|
-
payload = { :test => 'true' }
|
116
|
-
assert_equal true, ::Instana.agent.report_metrics(payload)
|
117
|
-
end
|
118
|
-
|
119
|
-
def test_failed_metric_report
|
120
|
-
# Fake discovery values
|
121
|
-
discovery = {}
|
122
|
-
discovery[:agent_host] = ::Instana.config[:agent_host]
|
123
|
-
discovery[:agent_port] = ::Instana.config[:agent_port]
|
124
|
-
::Instana.agent.instance_variable_set(:@discovered, discovery)
|
125
|
-
|
126
|
-
url = "http://#{::Instana.config[:agent_host]}:#{::Instana.config[:agent_port]}/com.instana.plugin.ruby.discovery"
|
127
|
-
json = { 'pid' => Process.pid, 'agentUuid' => 'abc' }.to_json
|
128
|
-
stub_request(:put, url).to_return(:body => json, :status => 200)
|
129
|
-
|
130
|
-
::Instana.agent.announce_sensor
|
131
|
-
|
132
|
-
url = "http://#{::Instana.config[:agent_host]}:#{::Instana.config[:agent_port]}/com.instana.plugin.ruby.#{Process.pid}"
|
133
|
-
stub_request(:post, url).to_raise(Errno::ECONNREFUSED)
|
134
|
-
|
135
|
-
payload = { :test => 'true' }
|
136
|
-
assert_equal false, ::Instana.agent.report_metrics(payload)
|
137
|
-
end
|
138
|
-
|
139
|
-
def test_agent_timeout
|
140
|
-
# Fake discovery values
|
141
|
-
discovery = {}
|
142
|
-
discovery[:agent_host] = ::Instana.config[:agent_host]
|
143
|
-
discovery[:agent_port] = ::Instana.config[:agent_port]
|
144
|
-
::Instana.agent.instance_variable_set(:@discovered, discovery)
|
145
|
-
|
146
|
-
localhost_url = "http://#{::Instana::Agent::LOCALHOST}:#{::Instana.config[:agent_port]}/com.instana.plugin.ruby.discovery"
|
147
|
-
stub_request(:any, localhost_url).to_timeout
|
148
|
-
|
149
|
-
assert_equal false, ::Instana.agent.announce_sensor
|
150
|
-
end
|
151
|
-
end
|