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
@@ -0,0 +1,47 @@
|
|
1
|
+
# (c) Copyright IBM Corp. 2021
|
2
|
+
# (c) Copyright Instana Inc. 2021
|
3
|
+
|
4
|
+
require 'test_helper'
|
5
|
+
|
6
|
+
class HostAgentTest < Minitest::Test
|
7
|
+
def test_spawn_background_thread
|
8
|
+
ENV['INSTANA_TEST'] = nil
|
9
|
+
::Instana.config[:agent_host] = '10.10.10.10'
|
10
|
+
|
11
|
+
if File.exist?('/sbin/ip')
|
12
|
+
addr = `/sbin/ip route | awk '/default/ { print $3 }'`.strip
|
13
|
+
stub_request(:get, "http://#{addr}:42699/")
|
14
|
+
.to_timeout
|
15
|
+
end
|
16
|
+
|
17
|
+
stub_request(:get, "http://10.10.10.10:42699/")
|
18
|
+
.to_timeout.times(3).then
|
19
|
+
.to_return(status: 200, body: "", headers: {})
|
20
|
+
|
21
|
+
discovery = Minitest::Mock.new
|
22
|
+
discovery.expect(:delete_observers, discovery, [])
|
23
|
+
discovery.expect(:with_observer, discovery, [Instana::Backend::HostAgentActivationObserver])
|
24
|
+
discovery.expect(:with_observer, discovery, [Instana::Backend::HostAgentReportingObserver])
|
25
|
+
discovery.expect(:swap, discovery, [])
|
26
|
+
|
27
|
+
subject = Instana::Backend::HostAgent.new(discovery: discovery)
|
28
|
+
|
29
|
+
FakeFS.with_fresh do
|
30
|
+
FakeFS::FileSystem.clone('test/support/ecs', '/proc')
|
31
|
+
subject.spawn_background_thread
|
32
|
+
end
|
33
|
+
|
34
|
+
subject.future.value!
|
35
|
+
|
36
|
+
discovery.verify
|
37
|
+
ensure
|
38
|
+
::Instana.config[:agent_host] = '127.0.0.1'
|
39
|
+
ENV['INSTANA_TEST'] = 'true'
|
40
|
+
end
|
41
|
+
|
42
|
+
def test_discovery_value
|
43
|
+
discovery = Concurrent::Atom.new({'pid' => 1})
|
44
|
+
subject = Instana::Backend::HostAgent.new(discovery: discovery)
|
45
|
+
assert_equal 1, subject.source[:e]
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
# (c) Copyright IBM Corp. 2021
|
2
|
+
# (c) Copyright Instana Inc. 2021
|
3
|
+
|
4
|
+
require 'test_helper'
|
5
|
+
|
6
|
+
class ProcessInfoTest < Minitest::Test
|
7
|
+
def test_osx_argument_stripping
|
8
|
+
host_os = RbConfig::CONFIG['host_os']
|
9
|
+
RbConfig::CONFIG['host_os'] = 'darwin'
|
10
|
+
|
11
|
+
subject = Instana::Backend::ProcessInfo.new(OpenStruct.new(cmdline: 'test INSTANA_TEST=1 KV=2'))
|
12
|
+
assert_equal ['KV=2'], subject.arguments
|
13
|
+
ensure
|
14
|
+
RbConfig::CONFIG['host_os'] = host_os
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_linux_argument_stripping
|
18
|
+
host_os = RbConfig::CONFIG['host_os']
|
19
|
+
RbConfig::CONFIG['host_os'] = 'linux'
|
20
|
+
|
21
|
+
subject = Instana::Backend::ProcessInfo.new(OpenStruct.new(cmdline: 'test INSTANA_TEST=1 KV=2'))
|
22
|
+
assert_equal ['INSTANA_TEST=1', 'KV=2'], subject.arguments
|
23
|
+
ensure
|
24
|
+
RbConfig::CONFIG['host_os'] = host_os
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_no_proc
|
28
|
+
subject = Instana::Backend::ProcessInfo.new(OpenStruct.new(pid: 0))
|
29
|
+
|
30
|
+
FakeFS.with_fresh do
|
31
|
+
FakeFS::FileSystem.clone('test/support/ecs', '/proc')
|
32
|
+
|
33
|
+
assert_equal 0, subject.parent_pid
|
34
|
+
assert_nil subject.cpuset
|
35
|
+
assert_nil subject.sched_pid
|
36
|
+
refute subject.in_container?
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def test_cpuset_proc
|
41
|
+
subject = Instana::Backend::ProcessInfo.new(OpenStruct.new(pid: 0))
|
42
|
+
|
43
|
+
FakeFS do
|
44
|
+
FakeFS::FileSystem.clone('test/support/proc', '/proc')
|
45
|
+
assert_equal '/', subject.cpuset
|
46
|
+
refute subject.in_container?
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def test_sched_pid
|
51
|
+
subject = Instana::Backend::ProcessInfo.new(OpenStruct.new(pid: 1))
|
52
|
+
|
53
|
+
FakeFS do
|
54
|
+
FakeFS::FileSystem.clone('test/support/proc', '/proc')
|
55
|
+
refute_equal '/', subject.cpuset
|
56
|
+
|
57
|
+
assert subject.in_container?
|
58
|
+
assert_equal 35, subject.sched_pid
|
59
|
+
assert subject.from_parent_namespace
|
60
|
+
assert_equal subject.sched_pid, subject.parent_pid
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# (c) Copyright IBM Corp. 2021
|
2
|
+
# (c) Copyright Instana Inc. 2021
|
3
|
+
|
4
|
+
require 'test_helper'
|
5
|
+
|
6
|
+
class RequestClientTest < Minitest::Test
|
7
|
+
def test_send_request_simple
|
8
|
+
stub_request(:get, 'http://example.com:9292/')
|
9
|
+
.to_return(body: 'ok', status: '200')
|
10
|
+
|
11
|
+
subject = Instana::Backend::RequestClient.new('example.com', 9292)
|
12
|
+
response = subject.send_request('GET', '/')
|
13
|
+
|
14
|
+
assert response.ok?
|
15
|
+
assert 'ok', response.body
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_send_request_json
|
19
|
+
stub_request(:post, 'http://example.com:9292/')
|
20
|
+
.with(body: '{"key":"value"}')
|
21
|
+
.to_return(body: '{"ok": true}', status: '200')
|
22
|
+
|
23
|
+
subject = Instana::Backend::RequestClient.new('example.com', 9292)
|
24
|
+
response = subject.send_request('POST', '/', {key: 'value'})
|
25
|
+
|
26
|
+
assert response.ok?
|
27
|
+
assert_equal({"ok" => true}, response.json)
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_send_request_failure
|
31
|
+
stub_request(:get, 'http://example.com:9292/')
|
32
|
+
.to_return(status: '500')
|
33
|
+
|
34
|
+
subject = Instana::Backend::RequestClient.new('example.com', 9292)
|
35
|
+
response = subject.send_request('GET', '/')
|
36
|
+
|
37
|
+
refute response.ok?
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
# (c) Copyright IBM Corp. 2021
|
2
|
+
# (c) Copyright Instana Inc. 2021
|
3
|
+
|
4
|
+
require 'test_helper'
|
5
|
+
|
6
|
+
class ServerlesAgentTest < Minitest::Test
|
7
|
+
def test_report
|
8
|
+
stub_request(:post, "http://10.10.10.10:9292//bundle")
|
9
|
+
.to_return(status: 500)
|
10
|
+
.to_return(status: 200)
|
11
|
+
|
12
|
+
host_name = Class.new do
|
13
|
+
def host_name
|
14
|
+
'hello'
|
15
|
+
end
|
16
|
+
end.new
|
17
|
+
|
18
|
+
snapshots = [Instana::Snapshot::RubyProcess.new, host_name]
|
19
|
+
subject = Instana::Backend::ServerlessAgent.new(snapshots, timer_class: MockTimer, backend_uri: 'http://10.10.10.10:9292/', logger: Logger.new('/dev/null'))
|
20
|
+
|
21
|
+
subject.timer.block.call
|
22
|
+
subject.timer.block.call
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_ready
|
26
|
+
subject = Instana::Backend::ServerlessAgent.new([], timer_class: MockTimer, backend_uri: 'http://10.10.10.10:9292/')
|
27
|
+
assert subject.ready?
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_extra_headers
|
31
|
+
subject = Instana::Backend::ServerlessAgent.new([], timer_class: MockTimer, backend_uri: 'http://10.10.10.10:9292/')
|
32
|
+
assert_equal [], subject.extra_headers
|
33
|
+
end
|
34
|
+
|
35
|
+
def test_secret_values
|
36
|
+
subject = Instana::Backend::ServerlessAgent.new([], timer_class: MockTimer, backend_uri: 'http://10.10.10.10:9292/')
|
37
|
+
assert_equal({"matcher" => "contains-ignore-case", "list" => %w[key password secret]}, subject.secret_values)
|
38
|
+
end
|
39
|
+
|
40
|
+
def test_spawn_background_thread
|
41
|
+
subject = Instana::Backend::ServerlessAgent.new([], timer_class: MockTimer, backend_uri: 'http://10.10.10.10:9292/')
|
42
|
+
subject.spawn_background_thread
|
43
|
+
|
44
|
+
assert subject.timer.running
|
45
|
+
end
|
46
|
+
|
47
|
+
def test_source
|
48
|
+
snapshot = Class.new do
|
49
|
+
def source
|
50
|
+
{test: 1}
|
51
|
+
end
|
52
|
+
end.new
|
53
|
+
subject = Instana::Backend::ServerlessAgent.new([snapshot], timer_class: MockTimer, backend_uri: 'http://10.10.10.10:9292/')
|
54
|
+
|
55
|
+
assert_equal({test: 1}, subject.source)
|
56
|
+
assert_equal({test: 1}, subject.source)
|
57
|
+
end
|
58
|
+
|
59
|
+
def test_missing_source
|
60
|
+
subject = Instana::Backend::ServerlessAgent.new([], timer_class: MockTimer, backend_uri: 'http://10.10.10.10:9292/', logger: Logger.new('/dev/null'))
|
61
|
+
|
62
|
+
assert_equal({}, subject.source)
|
63
|
+
end
|
64
|
+
|
65
|
+
def test_report_error
|
66
|
+
stub_request(:post, "http://10.10.10.10:9292//bundle")
|
67
|
+
.to_return(status: 500)
|
68
|
+
|
69
|
+
subject = Instana::Backend::ServerlessAgent.new([], timer_class: MockTimer, backend_uri: 'http://10.10.10.10:9292/', logger: Logger.new('/dev/null'))
|
70
|
+
|
71
|
+
subject.timer.block.call
|
72
|
+
end
|
73
|
+
end
|
data/test/config_test.rb
CHANGED
@@ -21,4 +21,14 @@ class ConfigTest < Minitest::Test
|
|
21
21
|
assert_equal true, ::Instana.config[:metrics][k].key?(:enabled)
|
22
22
|
end
|
23
23
|
end
|
24
|
+
|
25
|
+
def test_custom_agent_host
|
26
|
+
subject = Instana::Config.new(logger: Logger.new('/dev/null'), agent_host: 'abc')
|
27
|
+
assert_equal 'abc', subject[:agent_host]
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_custom_agent_port
|
31
|
+
subject = Instana::Config.new(logger: Logger.new('/dev/null'), agent_port: 'abc')
|
32
|
+
assert_equal 'abc', subject[:agent_port]
|
33
|
+
end
|
24
34
|
end
|
data/test/instana_test.rb
CHANGED
@@ -16,10 +16,6 @@ class InstanaTest < Minitest::Test
|
|
16
16
|
refute_nil ::Instana.agent
|
17
17
|
end
|
18
18
|
|
19
|
-
def test_that_it_has_a_collector
|
20
|
-
refute_nil ::Instana.collector
|
21
|
-
end
|
22
|
-
|
23
19
|
def test_that_it_has_a_tracer
|
24
20
|
refute_nil ::Instana.tracer
|
25
21
|
end
|
@@ -27,4 +23,15 @@ class InstanaTest < Minitest::Test
|
|
27
23
|
def test_that_it_has_a_config
|
28
24
|
refute_nil ::Instana.config
|
29
25
|
end
|
26
|
+
|
27
|
+
def test_assign_logger
|
28
|
+
mock = Minitest::Mock.new
|
29
|
+
mock.expect(:info, true, [String])
|
30
|
+
|
31
|
+
::Instana.logger = mock
|
32
|
+
::Instana.logger.info('test')
|
33
|
+
::Instana.logger = Logger.new('/dev/null')
|
34
|
+
|
35
|
+
mock.verify
|
36
|
+
end
|
30
37
|
end
|
@@ -4,6 +4,10 @@
|
|
4
4
|
require 'test_helper'
|
5
5
|
|
6
6
|
class AwsTest < Minitest::Test
|
7
|
+
def setup
|
8
|
+
clear_all!
|
9
|
+
end
|
10
|
+
|
7
11
|
def test_dynamo_db
|
8
12
|
dynamo = Aws::DynamoDB::Client.new(
|
9
13
|
region: "local",
|
@@ -27,7 +31,131 @@ class AwsTest < Minitest::Test
|
|
27
31
|
assert rest.empty?
|
28
32
|
assert_equal entry_span[:s], dynamo_span[:p]
|
29
33
|
assert_equal :dynamodb, dynamo_span[:n]
|
30
|
-
assert_equal
|
31
|
-
assert_equal 'sample_table', dynamo_span[:data][:table]
|
34
|
+
assert_equal 'get', dynamo_span[:data][:dynamodb][:op]
|
35
|
+
assert_equal 'sample_table', dynamo_span[:data][:dynamodb][:table]
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_s3
|
39
|
+
dynamo = Aws::S3::Client.new(
|
40
|
+
region: "local",
|
41
|
+
access_key_id: "minioadmin",
|
42
|
+
secret_access_key: "minioadmin",
|
43
|
+
endpoint: "http://localhost:9000"
|
44
|
+
)
|
45
|
+
|
46
|
+
assert_raises Aws::S3::Errors::NoSuchBucket do
|
47
|
+
Instana::Tracer.start_or_continue_trace(:s3_test, {}) do
|
48
|
+
dynamo.get_object(
|
49
|
+
bucket: 'sample_bucket',
|
50
|
+
key: 'sample_key'
|
51
|
+
)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
spans = ::Instana.processor.queued_spans
|
56
|
+
s3_span, entry_span, *rest = spans
|
57
|
+
|
58
|
+
assert rest.empty?
|
59
|
+
assert_equal entry_span[:s], s3_span[:p]
|
60
|
+
assert_equal :s3, s3_span[:n]
|
61
|
+
assert_equal 'get', s3_span[:data][:s3][:op]
|
62
|
+
assert_equal 'sample_bucket', s3_span[:data][:s3][:bucket]
|
63
|
+
assert_equal 'sample_key', s3_span[:data][:s3][:key]
|
64
|
+
end
|
65
|
+
|
66
|
+
def test_sns_publish
|
67
|
+
sns = Aws::SNS::Client.new(
|
68
|
+
region: "local",
|
69
|
+
access_key_id: "test",
|
70
|
+
secret_access_key: "test",
|
71
|
+
endpoint: "http://localhost:9911"
|
72
|
+
)
|
73
|
+
|
74
|
+
assert_raises Aws::SNS::Errors::NotFound do
|
75
|
+
Instana::Tracer.start_or_continue_trace(:sns_test, {}) do
|
76
|
+
sns.publish(
|
77
|
+
topic_arn: 'topic:arn',
|
78
|
+
target_arn: 'target:arn',
|
79
|
+
phone_number: '555-0100',
|
80
|
+
subject: 'Test Subject',
|
81
|
+
message: 'Test Message'
|
82
|
+
)
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
spans = ::Instana.processor.queued_spans
|
87
|
+
aws_span, entry_span, *rest = spans
|
88
|
+
|
89
|
+
assert rest.empty?
|
90
|
+
assert_equal entry_span[:s], aws_span[:p]
|
91
|
+
assert_equal :sns, aws_span[:n]
|
92
|
+
assert_equal 'topic:arn', aws_span[:data][:sns][:topic]
|
93
|
+
assert_equal 'target:arn', aws_span[:data][:sns][:target]
|
94
|
+
assert_equal '555-0100', aws_span[:data][:sns][:phone]
|
95
|
+
assert_equal 'Test Subject', aws_span[:data][:sns][:subject]
|
96
|
+
end
|
97
|
+
|
98
|
+
def test_sns_other
|
99
|
+
sns = Aws::SNS::Client.new(
|
100
|
+
region: "local",
|
101
|
+
access_key_id: "test",
|
102
|
+
secret_access_key: "test",
|
103
|
+
endpoint: "http://localhost:9911"
|
104
|
+
)
|
105
|
+
|
106
|
+
Instana::Tracer.start_or_continue_trace(:sns_test, {}) do
|
107
|
+
sns.list_subscriptions
|
108
|
+
end
|
109
|
+
|
110
|
+
spans = ::Instana.processor.queued_spans
|
111
|
+
aws_span, entry_span, *rest = spans
|
112
|
+
|
113
|
+
assert rest.empty?
|
114
|
+
assert_equal entry_span[:s], aws_span[:p]
|
115
|
+
assert_equal :"net-http", aws_span[:n]
|
116
|
+
end
|
117
|
+
|
118
|
+
def test_sqs
|
119
|
+
sqs = Aws::SQS::Client.new(
|
120
|
+
region: "local",
|
121
|
+
access_key_id: "test",
|
122
|
+
secret_access_key: "test",
|
123
|
+
endpoint: "http://localhost:9324"
|
124
|
+
)
|
125
|
+
|
126
|
+
create_response = nil
|
127
|
+
get_url_response = nil
|
128
|
+
|
129
|
+
Instana::Tracer.start_or_continue_trace(:sqs_test, {}) do
|
130
|
+
create_response = sqs.create_queue(queue_name: 'test')
|
131
|
+
get_url_response = sqs.get_queue_url(queue_name: 'test')
|
132
|
+
sqs.send_message(queue_url: create_response.queue_url, message_body: 'Sample')
|
133
|
+
end
|
134
|
+
|
135
|
+
received = sqs.receive_message(
|
136
|
+
queue_url: create_response.queue_url,
|
137
|
+
message_attribute_names: ['All']
|
138
|
+
)
|
139
|
+
sqs.delete_queue(queue_url: create_response.queue_url)
|
140
|
+
message = received.messages.first
|
141
|
+
create_span, get_span, send_span, _root = ::Instana.processor.queued_spans
|
142
|
+
|
143
|
+
assert_equal :sqs, create_span[:n]
|
144
|
+
assert_equal create_response.queue_url, create_span[:data][:sqs][:queue]
|
145
|
+
assert_equal 'exit', create_span[:data][:sqs][:sort]
|
146
|
+
assert_equal 'create.queue', create_span[:data][:sqs][:type]
|
147
|
+
|
148
|
+
assert_equal :sqs, get_span[:n]
|
149
|
+
assert_equal get_url_response.queue_url, get_span[:data][:sqs][:queue]
|
150
|
+
assert_equal 'exit', get_span[:data][:sqs][:sort]
|
151
|
+
assert_equal 'get.queue', get_span[:data][:sqs][:type]
|
152
|
+
|
153
|
+
assert_equal :sqs, send_span[:n]
|
154
|
+
assert_equal get_url_response.queue_url, send_span[:data][:sqs][:queue]
|
155
|
+
assert_equal 'exit', send_span[:data][:sqs][:sort]
|
156
|
+
assert_equal 'single.sync', send_span[:data][:sqs][:type]
|
157
|
+
assert_equal send_span[:t], message.message_attributes['X_INSTANA_T'].string_value
|
158
|
+
assert_equal send_span[:s], message.message_attributes['X_INSTANA_S'].string_value
|
159
|
+
assert_equal 'Sample', message.body
|
32
160
|
end
|
33
161
|
end
|
@@ -22,7 +22,7 @@ class ExconTest < Minitest::Test
|
|
22
22
|
url = "http://127.0.0.1:6511"
|
23
23
|
|
24
24
|
connection = Excon.new(url)
|
25
|
-
Instana.tracer.start_or_continue_trace('excon-test') do
|
25
|
+
Instana.tracer.start_or_continue_trace(:'excon-test') do
|
26
26
|
connection.get(:path => '/?basic_get')
|
27
27
|
end
|
28
28
|
|
@@ -40,6 +40,7 @@ class ExconTest < Minitest::Test
|
|
40
40
|
refute_nil excon_span[:data].key?(:http)
|
41
41
|
assert_equal "http://127.0.0.1:6511/", excon_span[:data][:http][:url]
|
42
42
|
assert_equal 200, excon_span[:data][:http][:status]
|
43
|
+
assert_equal 'basic_get', excon_span[:data][:http][:params]
|
43
44
|
|
44
45
|
# excon backtrace not included by default check
|
45
46
|
assert !excon_span.key?(:stack)
|
@@ -146,4 +147,18 @@ class ExconTest < Minitest::Test
|
|
146
147
|
assert_equal :sdk, grandparent_span[:n]
|
147
148
|
end
|
148
149
|
end
|
150
|
+
|
151
|
+
def test_basic_get_no_tracing
|
152
|
+
clear_all!
|
153
|
+
|
154
|
+
# A slight hack but webmock chokes with pipelined requests.
|
155
|
+
# Delete their excon middleware
|
156
|
+
Excon.defaults[:middlewares].delete ::WebMock::HttpLibAdapters::ExconAdapter
|
157
|
+
Excon.defaults[:middlewares].delete ::Excon::Middleware::Mock
|
158
|
+
|
159
|
+
url = "http://127.0.0.1:6511"
|
160
|
+
|
161
|
+
connection = Excon.new(url)
|
162
|
+
connection.get(:path => '/?basic_get')
|
163
|
+
end
|
149
164
|
end
|