instana 1.197.0.pre1 → 1.199.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/lib/instana/backend/agent.rb +9 -1
- data/lib/instana/backend/host_agent.rb +27 -10
- data/lib/instana/backend/host_agent_activation_observer.rb +17 -7
- data/lib/instana/backend/request_client.rb +6 -16
- data/lib/instana/backend/serverless_agent.rb +13 -18
- data/lib/instana/base.rb +2 -0
- data/lib/instana/config.rb +1 -1
- data/lib/instana/instrumentation/excon.rb +7 -5
- 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/serverless.rb +139 -0
- data/lib/instana/setup.rb +5 -0
- data/lib/instana/snapshot/google_cloud_run_instance.rb +69 -0
- data/lib/instana/snapshot/google_cloud_run_process.rb +58 -0
- data/lib/instana/snapshot/lambda_function.rb +39 -0
- data/lib/instana/tracing/processor.rb +11 -1
- data/lib/instana/tracing/span.rb +10 -4
- data/lib/instana/tracing/span_context.rb +14 -9
- data/lib/instana/util.rb +4 -2
- data/lib/instana/version.rb +1 -1
- data/test/backend/agent_test.rb +26 -0
- data/test/backend/host_agent_activation_observer_test.rb +16 -9
- data/test/backend/host_agent_test.rb +17 -2
- data/test/backend/request_client_test.rb +0 -22
- data/test/instrumentation/rack_instrumented_request_test.rb +2 -0
- data/test/serverless_test.rb +323 -0
- data/test/snapshot/google_cloud_run_instance_test.rb +74 -0
- data/test/snapshot/google_cloud_run_process_test.rb +33 -0
- data/test/snapshot/lambda_function_test.rb +37 -0
- data/test/test_helper.rb +1 -1
- data/test/tracing/id_management_test.rb +4 -0
- data/test/tracing/span_context_test.rb +3 -3
- data/test/tracing/span_test.rb +9 -0
- metadata +16 -4
@@ -0,0 +1,74 @@
|
|
1
|
+
# (c) Copyright IBM Corp. 2021
|
2
|
+
# (c) Copyright Instana Inc. 2021
|
3
|
+
|
4
|
+
require 'test_helper'
|
5
|
+
|
6
|
+
class GoogleCloudRunInstanceTest < Minitest::Test
|
7
|
+
def test_snapshot
|
8
|
+
ENV['K_SERVICE'] = 'test_service'
|
9
|
+
ENV['K_CONFIGURATION'] = 'test_config'
|
10
|
+
ENV['K_REVISION'] = 'test_revision'
|
11
|
+
ENV['PORT'] = 'test_port'
|
12
|
+
|
13
|
+
stub_request(:get, 'http://10.10.10.10//computeMetadata/v1/instance/id')
|
14
|
+
.to_return(status: 200, body: 'test_instance_id')
|
15
|
+
stub_request(:get, 'http://10.10.10.10//computeMetadata/v1/instance/zone')
|
16
|
+
.to_return(status: 200, body: 'region/number/test_region')
|
17
|
+
stub_request(:get, 'http://10.10.10.10//computeMetadata/v1/project/numeric-project-id')
|
18
|
+
.to_return(status: 200, body: 'numericProjectId')
|
19
|
+
stub_request(:get, 'http://10.10.10.10//computeMetadata/v1/project/project-id')
|
20
|
+
.to_return(status: 200, body: 'projectId')
|
21
|
+
|
22
|
+
subject = Instana::Snapshot::GoogleCloudRunInstance.new(metadata_uri: 'http://10.10.10.10/')
|
23
|
+
snapshot = subject.snapshot
|
24
|
+
|
25
|
+
assert_equal Instana::Snapshot::GoogleCloudRunInstance::ID, snapshot[:name]
|
26
|
+
assert_equal 'test_instance_id', snapshot[:entityId]
|
27
|
+
|
28
|
+
assert_equal "ruby", snapshot[:data][:runtime]
|
29
|
+
assert_equal "test_region", snapshot[:data][:region]
|
30
|
+
assert_equal "test_service", snapshot[:data][:service]
|
31
|
+
assert_equal "test_config", snapshot[:data][:configuration]
|
32
|
+
assert_equal "test_revision", snapshot[:data][:revision]
|
33
|
+
assert_equal "test_instance_id", snapshot[:data][:instanceId]
|
34
|
+
assert_equal "test_port", snapshot[:data][:port]
|
35
|
+
assert_equal "numericProjectId", snapshot[:data][:numericProjectId]
|
36
|
+
assert_equal "projectId", snapshot[:data][:projectId]
|
37
|
+
ensure
|
38
|
+
ENV['K_SERVICE'] = nil
|
39
|
+
ENV['K_CONFIGURATION'] = nil
|
40
|
+
ENV['K_REVISION'] = nil
|
41
|
+
ENV['PORT'] = nil
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_snapshot_error
|
45
|
+
stub_request(:get, 'http://10.10.10.10//computeMetadata/v1/instance/id')
|
46
|
+
.to_return(status: 500)
|
47
|
+
|
48
|
+
subject = Instana::Snapshot::GoogleCloudRunInstance.new(metadata_uri: 'http://10.10.10.10/')
|
49
|
+
|
50
|
+
assert_raises do
|
51
|
+
subject.snapshot
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def test_source
|
56
|
+
stub_request(:get, 'http://10.10.10.10//computeMetadata/v1/instance/id')
|
57
|
+
.to_return(status: 200, body: 'test_instance_id')
|
58
|
+
subject = Instana::Snapshot::GoogleCloudRunInstance.new(metadata_uri: 'http://10.10.10.10/')
|
59
|
+
source = subject.source
|
60
|
+
|
61
|
+
assert source[:hl]
|
62
|
+
assert_equal 'gcp', source[:cp]
|
63
|
+
assert_equal 'test_instance_id', source[:e]
|
64
|
+
end
|
65
|
+
|
66
|
+
def test_host_name
|
67
|
+
ENV['K_REVISION'] = 'test_revision'
|
68
|
+
subject = Instana::Snapshot::GoogleCloudRunInstance.new(metadata_uri: 'http://10.10.10.10/')
|
69
|
+
|
70
|
+
assert_equal 'gcp:cloud-run:revision:test_revision', subject.host_name
|
71
|
+
ensure
|
72
|
+
ENV['K_REVISION'] = nil
|
73
|
+
end
|
74
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# (c) Copyright IBM Corp. 2021
|
2
|
+
# (c) Copyright Instana Inc. 2021
|
3
|
+
|
4
|
+
require 'test_helper'
|
5
|
+
|
6
|
+
class GoogleCloudRunProcessTest < Minitest::Test
|
7
|
+
def test_snapshot
|
8
|
+
ENV['K_REVISION'] = 'test'
|
9
|
+
stub_request(:get, 'http://10.10.10.10//computeMetadata/v1/instance/id')
|
10
|
+
.to_return(status: 200, body: 'test_instance_id')
|
11
|
+
|
12
|
+
subject = Instana::Snapshot::GoogleCloudRunProcess.new(metadata_uri: 'http://10.10.10.10/')
|
13
|
+
snapshot = subject.snapshot
|
14
|
+
|
15
|
+
assert_equal Instana::Snapshot::GoogleCloudRunProcess::ID, snapshot[:name]
|
16
|
+
assert_equal 'test_instance_id', snapshot[:data][:container]
|
17
|
+
assert_equal 'gcpCloudRunInstance', snapshot[:data][:containerType]
|
18
|
+
assert_equal 'gcp:cloud-run:revision:test', snapshot[:data][:'com.instana.plugin.host.name']
|
19
|
+
ensure
|
20
|
+
ENV['K_REVISION'] = nil
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_snapshot_error
|
24
|
+
stub_request(:get, 'http://10.10.10.10//computeMetadata/v1/instance/id')
|
25
|
+
.to_return(status: 500)
|
26
|
+
|
27
|
+
subject = Instana::Snapshot::GoogleCloudRunProcess.new(metadata_uri: 'http://10.10.10.10/')
|
28
|
+
|
29
|
+
assert_raises do
|
30
|
+
subject.snapshot
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# (c) Copyright IBM Corp. 2021
|
2
|
+
# (c) Copyright Instana Inc. 2021
|
3
|
+
|
4
|
+
require 'test_helper'
|
5
|
+
|
6
|
+
class LambdaFunctionTest < Minitest::Test
|
7
|
+
def setup
|
8
|
+
@subject = Instana::Snapshot::LambdaFunction.new
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_snapshot
|
12
|
+
Thread.current[:instana_function_arn] = 'test'
|
13
|
+
|
14
|
+
assert_equal Instana::Snapshot::LambdaFunction::ID, @subject.snapshot[:name]
|
15
|
+
assert_equal Thread.current[:instana_function_arn], @subject.snapshot[:entityId]
|
16
|
+
ensure
|
17
|
+
Thread.current[:instana_function_arn] = nil
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_source
|
21
|
+
Thread.current[:instana_function_arn] = 'test'
|
22
|
+
|
23
|
+
assert @subject.source[:hl]
|
24
|
+
assert_equal 'aws', @subject.source[:cp]
|
25
|
+
assert_equal Thread.current[:instana_function_arn], @subject.source[:e]
|
26
|
+
ensure
|
27
|
+
Thread.current[:instana_function_arn] = nil
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_host_name
|
31
|
+
Thread.current[:instana_function_arn] = 'test'
|
32
|
+
|
33
|
+
assert_equal Thread.current[:instana_function_arn], @subject.host_name
|
34
|
+
ensure
|
35
|
+
Thread.current[:instana_function_arn] = nil
|
36
|
+
end
|
37
|
+
end
|
data/test/test_helper.rb
CHANGED
@@ -45,7 +45,7 @@ require 'fakefs/safe'
|
|
45
45
|
require 'webmock/minitest'
|
46
46
|
# Webmock: Whitelist local IPs
|
47
47
|
WebMock.disable_net_connect!(
|
48
|
-
allow: ->(uri) { %w[localhost 127.0.0.1 172.17.0.1 172.0.12.100].include?(uri.host) }
|
48
|
+
allow: ->(uri) { %w[localhost 127.0.0.1 172.17.0.1 172.0.12.100].include?(uri.host) && ENV.key?('APPRAISAL_INITIALIZED') }
|
49
49
|
)
|
50
50
|
|
51
51
|
Dir['test/support/*.rb'].each { |f| load(f) }
|
@@ -68,6 +68,10 @@ class TracerIDMgmtTest < Minitest::Test
|
|
68
68
|
# Bogus Array arg
|
69
69
|
bogus_result = Instana::Util.header_to_id([1234])
|
70
70
|
assert_equal '', bogus_result
|
71
|
+
|
72
|
+
# Invalid characters/length
|
73
|
+
bogus_result = Instana::Util.header_to_id('qwerty')
|
74
|
+
assert_equal '', bogus_result
|
71
75
|
end
|
72
76
|
|
73
77
|
def test_long_id_trim
|
@@ -11,12 +11,12 @@ class SpanContextTest < Minitest::Test
|
|
11
11
|
|
12
12
|
def test_invalid
|
13
13
|
subject = Instana::SpanContext.new(nil, nil)
|
14
|
-
|
15
|
-
assert subject.trace_state_header.empty?
|
14
|
+
refute subject.valid?
|
16
15
|
end
|
17
16
|
|
18
17
|
def test_flags_level_zero
|
19
|
-
subject = Instana::SpanContext.new('trace', 'span', 0)
|
18
|
+
subject = Instana::SpanContext.new('trace', 'span', 0, {external_state: 'cn=test'})
|
20
19
|
assert_equal '00-000000000000000000000000000trace-000000000000span-00', subject.trace_parent_header
|
20
|
+
assert_equal 'cn=test', subject.trace_state_header
|
21
21
|
end
|
22
22
|
end
|
data/test/tracing/span_test.rb
CHANGED
@@ -46,6 +46,15 @@ class SpanTest < Minitest::Test
|
|
46
46
|
assert_equal 'test', span.trace_id
|
47
47
|
end
|
48
48
|
|
49
|
+
def test_span_from_contetx_invalid
|
50
|
+
context = Instana::SpanContext.new(nil, nil, 1)
|
51
|
+
span = Instana::Span.new(:test, parent_ctx: context)
|
52
|
+
|
53
|
+
assert_nil span.parent_id
|
54
|
+
refute_equal context.span_id, span.trace_id
|
55
|
+
assert_equal 1, span.context.level
|
56
|
+
end
|
57
|
+
|
49
58
|
def test_span_collect_backtraces
|
50
59
|
Instana.config[:collect_backtraces] = true
|
51
60
|
span = Instana::Span.new(:excon)
|
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.
|
4
|
+
version: 1.199.0
|
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: 2021-
|
11
|
+
date: 2021-04-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -255,12 +255,16 @@ files:
|
|
255
255
|
- lib/instana/open_tracing/instana_tracer.rb
|
256
256
|
- lib/instana/rack.rb
|
257
257
|
- lib/instana/secrets.rb
|
258
|
+
- lib/instana/serverless.rb
|
258
259
|
- lib/instana/setup.rb
|
259
260
|
- lib/instana/snapshot/deltable.rb
|
260
261
|
- lib/instana/snapshot/docker_container.rb
|
261
262
|
- lib/instana/snapshot/fargate_container.rb
|
262
263
|
- lib/instana/snapshot/fargate_process.rb
|
263
264
|
- lib/instana/snapshot/fargate_task.rb
|
265
|
+
- lib/instana/snapshot/google_cloud_run_instance.rb
|
266
|
+
- lib/instana/snapshot/google_cloud_run_process.rb
|
267
|
+
- lib/instana/snapshot/lambda_function.rb
|
264
268
|
- lib/instana/snapshot/ruby_process.rb
|
265
269
|
- lib/instana/tracer.rb
|
266
270
|
- lib/instana/tracing/processor.rb
|
@@ -306,11 +310,15 @@ files:
|
|
306
310
|
- test/instrumentation/sidekiq-client_test.rb
|
307
311
|
- test/instrumentation/sidekiq-worker_test.rb
|
308
312
|
- test/secrets_test.rb
|
313
|
+
- test/serverless_test.rb
|
309
314
|
- test/snapshot/deltable_test.rb
|
310
315
|
- test/snapshot/docker_container_test.rb
|
311
316
|
- test/snapshot/fargate_container_test.rb
|
312
317
|
- test/snapshot/fargate_process_test.rb
|
313
318
|
- test/snapshot/fargate_task_test.rb
|
319
|
+
- test/snapshot/google_cloud_run_instance_test.rb
|
320
|
+
- test/snapshot/google_cloud_run_process_test.rb
|
321
|
+
- test/snapshot/lambda_function_test.rb
|
314
322
|
- test/snapshot/ruby_process_test.rb
|
315
323
|
- test/support/apps/active_record/active_record.rb
|
316
324
|
- test/support/apps/grpc/boot.rb
|
@@ -357,9 +365,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
357
365
|
version: '2.1'
|
358
366
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
359
367
|
requirements:
|
360
|
-
- - "
|
368
|
+
- - ">="
|
361
369
|
- !ruby/object:Gem::Version
|
362
|
-
version:
|
370
|
+
version: '0'
|
363
371
|
requirements: []
|
364
372
|
rubygems_version: 3.2.6
|
365
373
|
signing_key:
|
@@ -367,6 +375,7 @@ specification_version: 4
|
|
367
375
|
summary: Ruby Distributed Tracing & Metrics Sensor for Instana
|
368
376
|
test_files:
|
369
377
|
- test/config_test.rb
|
378
|
+
- test/serverless_test.rb
|
370
379
|
- test/activator_test.rb
|
371
380
|
- test/tracing/span_context_test.rb
|
372
381
|
- test/tracing/span_test.rb
|
@@ -381,7 +390,10 @@ test_files:
|
|
381
390
|
- test/snapshot/deltable_test.rb
|
382
391
|
- test/snapshot/fargate_task_test.rb
|
383
392
|
- test/snapshot/ruby_process_test.rb
|
393
|
+
- test/snapshot/google_cloud_run_process_test.rb
|
394
|
+
- test/snapshot/lambda_function_test.rb
|
384
395
|
- test/snapshot/fargate_container_test.rb
|
396
|
+
- test/snapshot/google_cloud_run_instance_test.rb
|
385
397
|
- test/backend/host_agent_activation_observer_test.rb
|
386
398
|
- test/backend/host_agent_reporting_observer_test.rb
|
387
399
|
- test/backend/gc_snapshot_test.rb
|