instana 1.195.1 → 1.197.0.pre2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +16 -2
- data/.rubocop.yml +6 -2
- data/Appraisals +13 -1
- data/Rakefile +1 -1
- data/docker-compose.yml +20 -0
- data/gemfiles/aws_30.gemfile +3 -0
- data/gemfiles/excon_021.gemfile +18 -0
- data/gemfiles/excon_079.gemfile +18 -0
- data/gemfiles/shoryuken_50.gemfile +19 -0
- data/instana.gemspec +3 -7
- data/lib/instana.rb +3 -0
- data/lib/instana/activator.rb +2 -0
- data/lib/instana/activators/aws_sdk_s3.rb +20 -0
- data/lib/instana/activators/aws_sdk_sns.rb +20 -0
- data/lib/instana/activators/aws_sdk_sqs.rb +20 -0
- data/lib/instana/activators/excon.rb +1 -1
- data/lib/instana/activators/shoryuken.rb +24 -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/aws_sdk_dynamodb.rb +21 -2
- data/lib/instana/instrumentation/aws_sdk_s3.rb +55 -0
- data/lib/instana/instrumentation/aws_sdk_sns.rb +29 -0
- data/lib/instana/instrumentation/aws_sdk_sqs.rb +98 -0
- data/lib/instana/instrumentation/excon.rb +19 -9
- data/lib/instana/instrumentation/instrumented_request.rb +68 -8
- data/lib/instana/instrumentation/net-http.rb +11 -7
- data/lib/instana/instrumentation/rack.rb +12 -7
- data/lib/instana/instrumentation/shoryuken.rb +44 -0
- 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 +8 -4
- 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/ruby_process.rb +48 -0
- data/lib/instana/tracer.rb +29 -147
- data/lib/instana/tracing/processor.rb +14 -22
- data/lib/instana/tracing/span.rb +34 -37
- data/lib/instana/tracing/span_context.rb +16 -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/aws_test.rb +130 -2
- data/test/instrumentation/excon_test.rb +16 -1
- data/test/instrumentation/net_http_test.rb +18 -0
- data/test/instrumentation/rack_instrumented_request_test.rb +9 -4
- data/test/instrumentation/rack_test.rb +2 -14
- data/test/instrumentation/shoryuken_test.rb +47 -0
- 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 +86 -46
- data/Dockerfile +0 -16
- 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
@@ -11,6 +11,24 @@ class NetHTTPTest < Minitest::Test
|
|
11
11
|
assert_equal true, ::Instana.config[:nethttp][:enabled]
|
12
12
|
end
|
13
13
|
|
14
|
+
def test_get_with_query
|
15
|
+
clear_all!
|
16
|
+
WebMock.allow_net_connect!
|
17
|
+
|
18
|
+
Instana.tracer.start_or_continue_trace(:"net-http-test") do
|
19
|
+
Net::HTTP.get(URI('http://127.0.0.1:6511/?query_value=true'))
|
20
|
+
end
|
21
|
+
|
22
|
+
spans = ::Instana.processor.queued_spans
|
23
|
+
assert_equal 3, spans.length
|
24
|
+
|
25
|
+
http_span = find_first_span_by_name(spans, :'net-http')
|
26
|
+
assert_equal "http://127.0.0.1:6511/", http_span[:data][:http][:url]
|
27
|
+
assert_equal "query_value=true", http_span[:data][:http][:params]
|
28
|
+
|
29
|
+
WebMock.disable_net_connect!
|
30
|
+
end
|
31
|
+
|
14
32
|
def test_block_request
|
15
33
|
clear_all!
|
16
34
|
WebMock.allow_net_connect!
|
@@ -29,6 +29,7 @@ class RackInstrumentedRequestTest < Minitest::Test
|
|
29
29
|
expected = {
|
30
30
|
trace_id: id,
|
31
31
|
span_id: id,
|
32
|
+
from_w3: false,
|
32
33
|
level: '1'
|
33
34
|
}
|
34
35
|
|
@@ -47,6 +48,7 @@ class RackInstrumentedRequestTest < Minitest::Test
|
|
47
48
|
external_state: nil,
|
48
49
|
trace_id: 'a3ce929d0e0e4736',
|
49
50
|
span_id: '00f067aa0ba902b7',
|
51
|
+
from_w3: true,
|
50
52
|
level: '1'
|
51
53
|
}
|
52
54
|
|
@@ -81,12 +83,14 @@ class RackInstrumentedRequestTest < Minitest::Test
|
|
81
83
|
end
|
82
84
|
|
83
85
|
def test_request_tags
|
84
|
-
::Instana.agent.extra_headers
|
86
|
+
::Instana.agent.define_singleton_method(:extra_headers) { %w[X-Capture-This] }
|
87
|
+
|
85
88
|
req = Instana::InstrumentedRequest.new(
|
86
89
|
'HTTP_HOST' => 'example.com',
|
87
90
|
'REQUEST_METHOD' => 'GET',
|
88
91
|
'HTTP_X_CAPTURE_THIS' => 'that',
|
89
|
-
'PATH_INFO' => '/'
|
92
|
+
'PATH_INFO' => '/',
|
93
|
+
'QUERY_STRING' => 'test=true'
|
90
94
|
)
|
91
95
|
|
92
96
|
expected = {
|
@@ -95,11 +99,12 @@ class RackInstrumentedRequestTest < Minitest::Test
|
|
95
99
|
host: 'example.com',
|
96
100
|
header: {
|
97
101
|
"X-Capture-This": 'that'
|
98
|
-
}
|
102
|
+
},
|
103
|
+
params: 'test=true'
|
99
104
|
}
|
100
105
|
|
101
106
|
assert_equal expected, req.request_tags
|
102
|
-
::Instana.agent.extra_headers
|
107
|
+
::Instana.agent.singleton_class.send(:remove_method, :extra_headers)
|
103
108
|
end
|
104
109
|
|
105
110
|
def test_correlation_data_valid
|
@@ -80,9 +80,6 @@ class RackTest < Minitest::Test
|
|
80
80
|
assert_equal 200, rack_span[:data][:http][:status]
|
81
81
|
assert_equal 'example.org', rack_span[:data][:http][:host]
|
82
82
|
assert rack_span.key?(:f)
|
83
|
-
assert rack_span[:f].key?(:e)
|
84
|
-
assert rack_span[:f].key?(:h)
|
85
|
-
assert_equal ::Instana.agent.agent_uuid, rack_span[:f][:h]
|
86
83
|
assert !rack_span.key?(:stack)
|
87
84
|
|
88
85
|
# Restore to default
|
@@ -134,9 +131,6 @@ class RackTest < Minitest::Test
|
|
134
131
|
assert_equal "/mrlobster", rack_span[:data][:http][:url]
|
135
132
|
assert_equal 200, rack_span[:data][:http][:status]
|
136
133
|
assert rack_span.key?(:f)
|
137
|
-
assert rack_span[:f].key?(:e)
|
138
|
-
assert rack_span[:f].key?(:h)
|
139
|
-
assert_equal ::Instana.agent.agent_uuid, rack_span[:f][:h]
|
140
134
|
end
|
141
135
|
|
142
136
|
def test_basic_put
|
@@ -166,9 +160,6 @@ class RackTest < Minitest::Test
|
|
166
160
|
assert_equal "/mrlobster", rack_span[:data][:http][:url]
|
167
161
|
assert_equal 200, rack_span[:data][:http][:status]
|
168
162
|
assert rack_span.key?(:f)
|
169
|
-
assert rack_span[:f].key?(:e)
|
170
|
-
assert rack_span[:f].key?(:h)
|
171
|
-
assert_equal ::Instana.agent.agent_uuid, rack_span[:f][:h]
|
172
163
|
end
|
173
164
|
|
174
165
|
def test_context_continuation
|
@@ -202,9 +193,6 @@ class RackTest < Minitest::Test
|
|
202
193
|
assert_equal "/mrlobster", rack_span[:data][:http][:url]
|
203
194
|
assert_equal 200, rack_span[:data][:http][:status]
|
204
195
|
assert rack_span.key?(:f)
|
205
|
-
assert rack_span[:f].key?(:e)
|
206
|
-
assert rack_span[:f].key?(:h)
|
207
|
-
assert_equal ::Instana.agent.agent_uuid, rack_span[:f][:h]
|
208
196
|
|
209
197
|
# Context validation
|
210
198
|
# The first span should have the passed in trace ID
|
@@ -260,7 +248,7 @@ class RackTest < Minitest::Test
|
|
260
248
|
def test_custom_headers_capture
|
261
249
|
clear_all!
|
262
250
|
::Instana.config[:collect_backtraces] = true
|
263
|
-
::Instana.agent.extra_headers
|
251
|
+
::Instana.agent.define_singleton_method(:extra_headers) { %w(X-Capture-This X-Capture-That) }
|
264
252
|
|
265
253
|
get '/mrlobster', {}, { "HTTP_X_CAPTURE_THIS" => "ThereYouGo" }
|
266
254
|
assert last_response.ok?
|
@@ -280,7 +268,7 @@ class RackTest < Minitest::Test
|
|
280
268
|
|
281
269
|
# Restore to default
|
282
270
|
::Instana.config[:collect_backtraces] = false
|
283
|
-
::Instana.agent.extra_headers
|
271
|
+
::Instana.agent.singleton_class.send(:remove_method, :extra_headers)
|
284
272
|
end
|
285
273
|
|
286
274
|
def test_capture_http_path_template
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# (c) Copyright IBM Corp. 2021
|
2
|
+
# (c) Copyright Instana Inc. 2021
|
3
|
+
|
4
|
+
require 'test_helper'
|
5
|
+
require 'ostruct'
|
6
|
+
|
7
|
+
class ShoryukenTest < Minitest::Test
|
8
|
+
def setup
|
9
|
+
clear_all!
|
10
|
+
@middleware = Instana::Instrumentation::Shoryuken.new
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_start_trace_with_context
|
14
|
+
id = Instana::Util.generate_id
|
15
|
+
message = OpenStruct.new(
|
16
|
+
queue_url: 'http://example.com',
|
17
|
+
message_attributes: {
|
18
|
+
"X_INSTANA_T" => OpenStruct.new(string_value: id),
|
19
|
+
"X_INSTANA_S" => OpenStruct.new(string_value: id),
|
20
|
+
"X_INSTANA_L" => OpenStruct.new(string_value: '1')
|
21
|
+
}
|
22
|
+
)
|
23
|
+
|
24
|
+
@middleware.call(nil, nil, message, nil) {}
|
25
|
+
|
26
|
+
span = ::Instana.processor.queued_spans.first
|
27
|
+
|
28
|
+
assert_equal id, span[:t]
|
29
|
+
assert_equal id, span[:p]
|
30
|
+
assert_equal 'entry', span[:data][:sqs][:sort]
|
31
|
+
assert_equal 'http://example.com', span[:data][:sqs][:queue]
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_start_trace
|
35
|
+
message = OpenStruct.new(
|
36
|
+
queue_url: 'http://example.com'
|
37
|
+
)
|
38
|
+
|
39
|
+
@middleware.call(nil, nil, message, nil) {}
|
40
|
+
|
41
|
+
span = ::Instana.processor.queued_spans.first
|
42
|
+
|
43
|
+
assert_nil span[:p]
|
44
|
+
assert_equal 'entry', span[:data][:sqs][:sort]
|
45
|
+
assert_equal 'http://example.com', span[:data][:sqs][:queue]
|
46
|
+
end
|
47
|
+
end
|
data/test/secrets_test.rb
CHANGED
@@ -5,72 +5,91 @@ require 'test_helper'
|
|
5
5
|
|
6
6
|
class SecretsTest < Minitest::Test
|
7
7
|
def setup
|
8
|
-
@subject = Instana::Secrets.new
|
8
|
+
@subject = Instana::Secrets.new(logger: Logger.new('/dev/null'))
|
9
9
|
end
|
10
|
-
|
10
|
+
|
11
11
|
def test_equals_ignore_case
|
12
12
|
sample_config = {
|
13
|
-
"matcher"=>"equals-ignore-case",
|
13
|
+
"matcher"=>"equals-ignore-case",
|
14
14
|
"list"=>["key"]
|
15
15
|
}
|
16
|
-
|
16
|
+
|
17
17
|
url = url_for(%w(key Str kEy KEY))
|
18
18
|
assert_redacted @subject.remove_from_query(url, sample_config), %w(key kEy KEY)
|
19
19
|
end
|
20
|
-
|
20
|
+
|
21
21
|
def test_equals
|
22
22
|
sample_config = {
|
23
|
-
"matcher"=>"equals",
|
23
|
+
"matcher"=>"equals",
|
24
24
|
"list"=>["key", "kEy"]
|
25
25
|
}
|
26
|
-
|
26
|
+
|
27
27
|
url = url_for(%w(key Str kEy KEY))
|
28
28
|
assert_redacted @subject.remove_from_query(url, sample_config), %w(key kEy)
|
29
29
|
end
|
30
|
-
|
30
|
+
|
31
31
|
def test_contains_ignore_case
|
32
32
|
sample_config = {
|
33
|
-
"matcher"=>"contains-ignore-case",
|
33
|
+
"matcher"=>"contains-ignore-case",
|
34
34
|
"list"=>["stan"]
|
35
35
|
}
|
36
|
-
|
36
|
+
|
37
37
|
url = url_for(%w(instantiate conTESTant sample))
|
38
38
|
assert_redacted @subject.remove_from_query(url, sample_config), %w(instantiate conTESTant)
|
39
39
|
end
|
40
|
-
|
40
|
+
|
41
41
|
def test_contains
|
42
42
|
sample_config = {
|
43
|
-
"matcher"=>"contains",
|
43
|
+
"matcher"=>"contains",
|
44
44
|
"list"=>["stan"]
|
45
45
|
}
|
46
|
-
|
46
|
+
|
47
47
|
url = url_for(%w(instantiate conTESTant sample))
|
48
48
|
assert_redacted @subject.remove_from_query(url, sample_config), %w(instantiate)
|
49
|
-
|
50
49
|
end
|
51
|
-
|
50
|
+
|
52
51
|
def test_regexp
|
53
52
|
sample_config = {
|
54
|
-
"matcher"=>"regex",
|
53
|
+
"matcher"=>"regex",
|
55
54
|
"list"=>["l{2}"]
|
56
55
|
}
|
57
|
-
|
56
|
+
|
58
57
|
url = url_for(%w(ball foot move))
|
59
|
-
assert_redacted @subject.remove_from_query(url, sample_config), %w(ball)
|
58
|
+
assert_redacted @subject.remove_from_query(url, sample_config), %w(ball)
|
59
|
+
end
|
60
|
+
|
61
|
+
def test_invalid
|
62
|
+
sample_config = {
|
63
|
+
"matcher"=>"test_invalid",
|
64
|
+
"list"=>["key"]
|
65
|
+
}
|
66
|
+
|
67
|
+
url = url_for(%w(key Str kEy KEY))
|
68
|
+
assert_redacted @subject.remove_from_query(url, sample_config), []
|
69
|
+
end
|
70
|
+
|
71
|
+
def test_without_scheme
|
72
|
+
sample_config = {
|
73
|
+
"matcher"=>"contains",
|
74
|
+
"list"=>["stan"]
|
75
|
+
}
|
76
|
+
|
77
|
+
url = 'example.com?instantiate=true'
|
78
|
+
assert_redacted @subject.remove_from_query(url, sample_config), %w(instantiate)
|
60
79
|
end
|
61
|
-
|
80
|
+
|
62
81
|
private
|
63
|
-
|
82
|
+
|
64
83
|
def url_for(keys)
|
65
84
|
url = URI('http://example.com')
|
66
85
|
url.query = URI.encode_www_form(keys.map { |k| [k, rand(1..100)]})
|
67
86
|
url.to_s
|
68
87
|
end
|
69
|
-
|
88
|
+
|
70
89
|
def assert_redacted(str, keys)
|
71
90
|
url = URI(str)
|
72
91
|
params = CGI.parse(url.query)
|
73
|
-
|
92
|
+
|
74
93
|
assert_equal keys, params.select { |_, v| v == %w(<redacted>) }.keys, 'to be redacted'
|
75
94
|
end
|
76
95
|
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# (c) Copyright IBM Corp. 2021
|
2
|
+
# (c) Copyright Instana Inc. 2021
|
3
|
+
|
4
|
+
require 'test_helper'
|
5
|
+
|
6
|
+
class DeltableTest < Minitest::Test
|
7
|
+
include Instana::Snapshot::Deltable
|
8
|
+
|
9
|
+
def test_delta
|
10
|
+
subject = {a: {b: 5}}
|
11
|
+
|
12
|
+
assert_equal 5, delta(:a, :b, obj: subject, compute: ->(o, n) { o + n })
|
13
|
+
assert_equal 10, delta(:a, :b, obj: subject, compute: ->(o, n) { o + n })
|
14
|
+
|
15
|
+
assert_nil delta(:a, :c, obj: subject, compute: ->(o, n) { o + n })
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,82 @@
|
|
1
|
+
# (c) Copyright IBM Corp. 2021
|
2
|
+
# (c) Copyright Instana Inc. 2021
|
3
|
+
|
4
|
+
require 'test_helper'
|
5
|
+
|
6
|
+
class DockerContainerTest < Minitest::Test
|
7
|
+
def test_container
|
8
|
+
stub_request(:get, 'https://10.10.10.10:8080/v3/task/stats')
|
9
|
+
.to_return(status: 200, body: File.read('test/support/ecs/stats.json'))
|
10
|
+
|
11
|
+
container = JSON.parse(File.read('test/support/ecs/task.json'))['Containers'].first
|
12
|
+
subject = Instana::Snapshot::DockerContainer.new(container, metadata_uri: 'https://10.10.10.10:8080/v3')
|
13
|
+
|
14
|
+
snapshot = subject.snapshot
|
15
|
+
|
16
|
+
assert_equal Instana::Snapshot::DockerContainer::ID, snapshot[:name]
|
17
|
+
assert_equal 'arn:aws:ecs:us-east-2:012345678910:task/9781c248-0edd-4cdb-9a93-f63cb662a5d3::~internal~ecs~pause', snapshot[:entityId]
|
18
|
+
|
19
|
+
assert_equal "731a0d6a3b4210e2448339bc7015aaa79bfe4fa256384f4102db86ef94cbbc4c", snapshot[:data][:Id]
|
20
|
+
assert_equal "2018-02-01T20:55:08.366329616Z", snapshot[:data][:Created]
|
21
|
+
assert_equal "2018-02-01T20:55:09.058354915Z", snapshot[:data][:Started]
|
22
|
+
assert_equal "amazon/amazon-ecs-pause:0.1.0", snapshot[:data][:Image]
|
23
|
+
assert_equal container['Labels'], snapshot[:data][:Labels]
|
24
|
+
assert_nil snapshot[:data][:Ports]
|
25
|
+
assert_equal "awsvpc", snapshot[:data][:NetworkMode]
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_container_metrics
|
29
|
+
stub_request(:get, 'https://10.10.10.10:8080/v3/task/stats')
|
30
|
+
.to_return(status: 200, body: File.read('test/support/ecs/stats.json'))
|
31
|
+
|
32
|
+
container = JSON.parse(File.read('test/support/ecs/task.json'))['Containers'].last
|
33
|
+
subject = Instana::Snapshot::DockerContainer.new(container, metadata_uri: 'https://10.10.10.10:8080/v3')
|
34
|
+
|
35
|
+
snapshot = subject.snapshot
|
36
|
+
|
37
|
+
assert_equal Instana::Snapshot::DockerContainer::ID, snapshot[:name]
|
38
|
+
assert_equal 'arn:aws:ecs:us-east-2:012345678910:task/9781c248-0edd-4cdb-9a93-f63cb662a5d3::nginx-curl', snapshot[:entityId]
|
39
|
+
|
40
|
+
assert_equal 0.0030905127838258164, snapshot[:data][:cpu][:total_usage]
|
41
|
+
assert_equal 0.0022809745982374286, snapshot[:data][:cpu][:user_usage]
|
42
|
+
assert_equal 0.00031104199066874026, snapshot[:data][:cpu][:system_usage]
|
43
|
+
assert_equal 0, snapshot[:data][:cpu][:throttling_count]
|
44
|
+
assert_equal 0, snapshot[:data][:cpu][:throttling_time]
|
45
|
+
assert_equal 5_890_048, snapshot[:data][:blkio][:blk_read]
|
46
|
+
assert_equal 12288, snapshot[:data][:blkio][:blk_write]
|
47
|
+
assert_equal 6_610_944, snapshot[:data][:memory][:active_anon]
|
48
|
+
assert_equal 0, snapshot[:data][:memory][:active_file]
|
49
|
+
assert_equal 0, snapshot[:data][:memory][:inactive_anon]
|
50
|
+
assert_equal 2_158_592, snapshot[:data][:memory][:inactive_file]
|
51
|
+
assert_equal 0, snapshot[:data][:memory][:total_cache]
|
52
|
+
assert_equal 8_769_536, snapshot[:data][:memory][:total_rss]
|
53
|
+
assert_equal 10_035_200, snapshot[:data][:memory][:usage]
|
54
|
+
assert_equal 12_677_120, snapshot[:data][:memory][:max_usage]
|
55
|
+
assert_equal 4_134_825_984, snapshot[:data][:memory][:limit]
|
56
|
+
assert_equal({bytes: 40_000_257, dropped: 7, errors: 2, packet: 200_017}, snapshot[:data][:network][:rx])
|
57
|
+
assert_equal({bytes: 20_000_511, dropped: 200_007, errors: 5, packet: 2}, snapshot[:data][:network][:tx])
|
58
|
+
end
|
59
|
+
|
60
|
+
def test_container_no_network
|
61
|
+
stub_request(:get, 'https://10.10.10.10:8080/v3/task/stats')
|
62
|
+
.to_return(status: 200, body: File.read('test/support/ecs/stats.json'))
|
63
|
+
|
64
|
+
container = JSON.parse(File.read('test/support/ecs/task.json'))['Containers'][1]
|
65
|
+
subject = Instana::Snapshot::DockerContainer.new(container, metadata_uri: 'https://10.10.10.10:8080/v3')
|
66
|
+
|
67
|
+
snapshot = subject.snapshot
|
68
|
+
assert_nil snapshot[:data][:network]
|
69
|
+
end
|
70
|
+
|
71
|
+
def test_snapshot_error
|
72
|
+
stub_request(:get, 'https://10.10.10.10:8080/v3/task/stats')
|
73
|
+
.to_return(status: 500)
|
74
|
+
|
75
|
+
container = JSON.parse(File.read('test/support/ecs/task.json'))['Containers'].first
|
76
|
+
subject = Instana::Snapshot::DockerContainer.new(container, metadata_uri: 'https://10.10.10.10:8080/v3')
|
77
|
+
|
78
|
+
assert_raises do
|
79
|
+
subject.snapshot
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
@@ -0,0 +1,82 @@
|
|
1
|
+
# (c) Copyright IBM Corp. 2021
|
2
|
+
# (c) Copyright Instana Inc. 2021
|
3
|
+
|
4
|
+
require 'test_helper'
|
5
|
+
|
6
|
+
class FargateContainerTest < Minitest::Test
|
7
|
+
def test_snapshot_observed
|
8
|
+
container = JSON.parse(File.read('test/support/ecs/task.json'))['Containers'].first
|
9
|
+
subject = Instana::Snapshot::FargateContainer.new(container, metadata_uri: 'https://10.10.10.10:8080/v3')
|
10
|
+
|
11
|
+
stub_request(:get, 'https://10.10.10.10:8080/v3')
|
12
|
+
.to_return(status: 200, body: File.read('test/support/ecs/container.json'))
|
13
|
+
|
14
|
+
snapshot = subject.snapshot
|
15
|
+
|
16
|
+
assert_equal Instana::Snapshot::FargateContainer::ID, snapshot[:name]
|
17
|
+
assert_equal 'arn:aws:ecs:us-east-2:012345678910:task/9781c248-0edd-4cdb-9a93-f63cb662a5d3::~internal~ecs~pause', snapshot[:entityId]
|
18
|
+
|
19
|
+
assert_equal "731a0d6a3b4210e2448339bc7015aaa79bfe4fa256384f4102db86ef94cbbc4c", snapshot[:data][:dockerId]
|
20
|
+
assert_equal "ecs-nginx-5-internalecspause-acc699c0cbf2d6d11700", snapshot[:data][:dockerName]
|
21
|
+
assert_equal "~internal~ecs~pause", snapshot[:data][:containerName]
|
22
|
+
assert_equal "amazon/amazon-ecs-pause:0.1.0", snapshot[:data][:image]
|
23
|
+
assert_equal "", snapshot[:data][:imageId]
|
24
|
+
assert_equal "arn:aws:ecs:us-east-2:012345678910:task/9781c248-0edd-4cdb-9a93-f63cb662a5d3", snapshot[:data][:taskArn]
|
25
|
+
assert_nil snapshot[:data][:taskDefinition]
|
26
|
+
assert_nil snapshot[:data][:taskDefinitionVersion]
|
27
|
+
assert_equal "default", snapshot[:data][:clusterArn]
|
28
|
+
assert_equal "RESOURCES_PROVISIONED", snapshot[:data][:desiredStatus]
|
29
|
+
assert_equal "RESOURCES_PROVISIONED", snapshot[:data][:knownStatus]
|
30
|
+
assert_nil snapshot[:data][:ports]
|
31
|
+
assert_equal({:cpu => 0, :memory => 0}, snapshot[:data][:limits])
|
32
|
+
assert_equal "2018-02-01T20:55:08.366329616Z", snapshot[:data][:createdAt]
|
33
|
+
assert_equal "2018-02-01T20:55:09.058354915Z", snapshot[:data][:startedAt]
|
34
|
+
|
35
|
+
assert_nil subject.source
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_snapshot_current
|
39
|
+
container = JSON.parse(File.read('test/support/ecs/task.json'))['Containers'].last
|
40
|
+
subject = Instana::Snapshot::FargateContainer.new(container, metadata_uri: 'https://10.10.10.10:8080/v3')
|
41
|
+
|
42
|
+
stub_request(:get, 'https://10.10.10.10:8080/v3')
|
43
|
+
.to_return(status: 200, body: File.read('test/support/ecs/container.json'))
|
44
|
+
|
45
|
+
snapshot = subject.snapshot
|
46
|
+
|
47
|
+
assert_equal Instana::Snapshot::FargateContainer::ID, snapshot[:name]
|
48
|
+
assert_equal 'arn:aws:ecs:us-east-2:012345678910:task/9781c248-0edd-4cdb-9a93-f63cb662a5d3::nginx-curl', snapshot[:entityId]
|
49
|
+
|
50
|
+
assert_equal "43481a6ce4842eec8fe72fc28500c6b52edcc0917f105b83379f88cac1ff3946", snapshot[:data][:dockerId]
|
51
|
+
assert_equal "ecs-nginx-5-nginx-curl-ccccb9f49db0dfe0d901", snapshot[:data][:dockerName]
|
52
|
+
assert_equal "nginx-curl", snapshot[:data][:containerName]
|
53
|
+
assert_equal "nrdlngr/nginx-curl", snapshot[:data][:image]
|
54
|
+
assert_equal "sha256:2e00ae64383cfc865ba0a2ba37f61b50a120d2d9378559dcd458dc0de47bc165", snapshot[:data][:imageId]
|
55
|
+
assert_equal "arn:aws:ecs:us-east-2:012345678910:task/9781c248-0edd-4cdb-9a93-f63cb662a5d3", snapshot[:data][:taskArn]
|
56
|
+
assert_nil snapshot[:data][:taskDefinition]
|
57
|
+
assert_nil snapshot[:data][:taskDefinitionVersion]
|
58
|
+
assert_equal "default", snapshot[:data][:clusterArn]
|
59
|
+
assert_equal "RUNNING", snapshot[:data][:desiredStatus]
|
60
|
+
assert_equal "RUNNING", snapshot[:data][:knownStatus]
|
61
|
+
assert_nil snapshot[:data][:ports]
|
62
|
+
assert_equal({:cpu => 512, :memory => 512}, snapshot[:data][:limits])
|
63
|
+
assert_equal "2018-02-01T20:55:10.554941919Z", snapshot[:data][:createdAt]
|
64
|
+
assert_equal "2018-02-01T20:55:11.064236631Z", snapshot[:data][:startedAt]
|
65
|
+
assert_equal true, snapshot[:data][:instrumented]
|
66
|
+
assert_equal "ruby", snapshot[:data][:runtime]
|
67
|
+
|
68
|
+
assert_equal({hl: true, cp: "aws", e: "arn:aws:ecs:us-east-2:012345678910:task/9781c248-0edd-4cdb-9a93-f63cb662a5d3::nginx-curl"}, subject.source)
|
69
|
+
end
|
70
|
+
|
71
|
+
def test_snapshot_error
|
72
|
+
stub_request(:get, 'https://10.10.10.10:8080/v3')
|
73
|
+
.to_return(status: 500)
|
74
|
+
|
75
|
+
container = JSON.parse(File.read('test/support/ecs/task.json'))['Containers'].first
|
76
|
+
subject = Instana::Snapshot::FargateContainer.new(container, metadata_uri: 'https://10.10.10.10:8080/v3')
|
77
|
+
|
78
|
+
assert_raises do
|
79
|
+
subject.snapshot
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|