instana 1.217.1 → 2.1.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.
Files changed (228) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +2 -1
  3. data/lib/instana/base.rb +4 -2
  4. data/lib/instana/instrumentation/action_cable.rb +8 -4
  5. data/lib/instana/instrumentation/action_controller.rb +2 -4
  6. data/lib/instana/instrumentation/action_mailer.rb +1 -1
  7. data/lib/instana/instrumentation/action_view.rb +4 -4
  8. data/lib/instana/instrumentation/active_job.rb +20 -5
  9. data/lib/instana/instrumentation/active_record.rb +1 -1
  10. data/lib/instana/instrumentation/aws_sdk_dynamodb.rb +1 -1
  11. data/lib/instana/instrumentation/aws_sdk_lambda.rb +1 -1
  12. data/lib/instana/instrumentation/aws_sdk_s3.rb +1 -1
  13. data/lib/instana/instrumentation/aws_sdk_sns.rb +1 -1
  14. data/lib/instana/instrumentation/aws_sdk_sqs.rb +1 -1
  15. data/lib/instana/instrumentation/dalli.rb +1 -1
  16. data/lib/instana/instrumentation/excon.rb +2 -2
  17. data/lib/instana/instrumentation/graphql.rb +3 -3
  18. data/lib/instana/instrumentation/grpc.rb +14 -13
  19. data/lib/instana/instrumentation/mongo.rb +3 -3
  20. data/lib/instana/instrumentation/net-http.rb +5 -4
  21. data/lib/instana/instrumentation/rack.rb +36 -4
  22. data/lib/instana/instrumentation/redis.rb +1 -1
  23. data/lib/instana/instrumentation/resque.rb +10 -8
  24. data/lib/instana/instrumentation/rest-client.rb +4 -4
  25. data/lib/instana/instrumentation/sequel.rb +3 -3
  26. data/lib/instana/instrumentation/shoryuken.rb +4 -1
  27. data/lib/instana/instrumentation/sidekiq-client.rb +21 -19
  28. data/lib/instana/instrumentation/sidekiq-worker.rb +22 -21
  29. data/lib/instana/instrumented_logger.rb +1 -1
  30. data/lib/instana/samplers/result.rb +32 -0
  31. data/lib/instana/samplers/samplers.rb +76 -0
  32. data/lib/instana/serverless.rb +4 -2
  33. data/lib/instana/setup.rb +5 -5
  34. data/lib/instana/span_filtering/condition.rb +134 -0
  35. data/lib/instana/span_filtering/configuration.rb +262 -0
  36. data/lib/instana/span_filtering/filter_rule.rb +31 -0
  37. data/lib/instana/span_filtering.rb +62 -0
  38. data/lib/instana/trace/export.rb +36 -0
  39. data/lib/instana/{tracing → trace}/processor.rb +19 -15
  40. data/lib/instana/trace/span.rb +534 -0
  41. data/lib/instana/{tracing → trace}/span_context.rb +17 -8
  42. data/lib/instana/trace/span_kind.rb +51 -0
  43. data/lib/instana/trace/span_limits.rb +63 -0
  44. data/lib/instana/{tracer.rb → trace/tracer.rb} +106 -54
  45. data/lib/instana/trace/tracer_provider.rb +198 -0
  46. data/lib/instana/trace.rb +74 -0
  47. data/lib/instana/util.rb +11 -0
  48. data/lib/instana/version.rb +1 -1
  49. metadata +89 -267
  50. data/.circleci/config.yml +0 -485
  51. data/.codeclimate.yml +0 -23
  52. data/.editorconfig +0 -10
  53. data/.fasterer.yml +0 -23
  54. data/.github/ISSUE_TEMPLATE/bug.yml +0 -39
  55. data/.github/ISSUE_TEMPLATE/config.yml +0 -8
  56. data/.github/workflows/pr_commits_signed_off.yml +0 -16
  57. data/.github/workflows/release-notification-on-slack.yml +0 -34
  58. data/.gitignore +0 -19
  59. data/.rubocop.yml +0 -34
  60. data/.rubocop_todo.yml +0 -1140
  61. data/.tekton/.currency/docs/report.md +0 -20
  62. data/.tekton/.currency/resources/requirements.txt +0 -4
  63. data/.tekton/.currency/resources/table.json +0 -100
  64. data/.tekton/.currency/scripts/generate_report.py +0 -136
  65. data/.tekton/README.md +0 -278
  66. data/.tekton/github-interceptor-secret.yaml +0 -8
  67. data/.tekton/github-pr-eventlistener.yaml +0 -104
  68. data/.tekton/github-pr-pipeline.yaml.part +0 -38
  69. data/.tekton/github-set-status-task.yaml +0 -43
  70. data/.tekton/github-webhook-ingress.yaml +0 -20
  71. data/.tekton/pipeline.yaml +0 -571
  72. data/.tekton/pipelinerun.yaml +0 -21
  73. data/.tekton/ruby-tracer-prepuller.yaml +0 -87
  74. data/.tekton/run_unittests.sh +0 -87
  75. data/.tekton/scheduled-eventlistener.yaml +0 -108
  76. data/.tekton/task.yaml +0 -449
  77. data/.tekton/tekton-triggers-eventlistener-serviceaccount.yaml +0 -29
  78. data/Appraisals +0 -124
  79. data/CONTRIBUTING.md +0 -86
  80. data/Gemfile +0 -17
  81. data/LICENSE +0 -22
  82. data/MAINTAINERS.md +0 -3
  83. data/Rakefile +0 -49
  84. data/bin/announce_release_on_slack.py +0 -103
  85. data/docker-compose.yml +0 -20
  86. data/download.sh +0 -85
  87. data/examples/opentracing.rb +0 -35
  88. data/examples/tracing.rb +0 -84
  89. data/extras/license_header.rb +0 -44
  90. data/gemfiles/.bundle/config +0 -2
  91. data/gemfiles/aws_30.gemfile +0 -21
  92. data/gemfiles/aws_60.gemfile +0 -16
  93. data/gemfiles/cuba_30.gemfile +0 -16
  94. data/gemfiles/cuba_40.gemfile +0 -13
  95. data/gemfiles/dalli_20.gemfile +0 -15
  96. data/gemfiles/dalli_30.gemfile +0 -12
  97. data/gemfiles/dalli_32.gemfile +0 -12
  98. data/gemfiles/excon_0100.gemfile +0 -14
  99. data/gemfiles/excon_021.gemfile +0 -17
  100. data/gemfiles/excon_079.gemfile +0 -17
  101. data/gemfiles/excon_100.gemfile +0 -14
  102. data/gemfiles/graphql_10.gemfile +0 -16
  103. data/gemfiles/graphql_20.gemfile +0 -15
  104. data/gemfiles/grpc_10.gemfile +0 -15
  105. data/gemfiles/mongo_216.gemfile +0 -15
  106. data/gemfiles/mongo_219.gemfile +0 -12
  107. data/gemfiles/net_http_01.gemfile +0 -17
  108. data/gemfiles/rack_16.gemfile +0 -15
  109. data/gemfiles/rack_20.gemfile +0 -15
  110. data/gemfiles/rack_30.gemfile +0 -13
  111. data/gemfiles/rails_42.gemfile +0 -18
  112. data/gemfiles/rails_50.gemfile +0 -19
  113. data/gemfiles/rails_52.gemfile +0 -19
  114. data/gemfiles/rails_60.gemfile +0 -19
  115. data/gemfiles/rails_61.gemfile +0 -20
  116. data/gemfiles/rails_70.gemfile +0 -17
  117. data/gemfiles/rails_71.gemfile +0 -17
  118. data/gemfiles/rails_80.gemfile +0 -17
  119. data/gemfiles/redis_40.gemfile +0 -15
  120. data/gemfiles/redis_50.gemfile +0 -13
  121. data/gemfiles/redis_51.gemfile +0 -13
  122. data/gemfiles/resque_122.gemfile +0 -16
  123. data/gemfiles/resque_1274_3scale.gemfile +0 -17
  124. data/gemfiles/resque_20.gemfile +0 -16
  125. data/gemfiles/rest_client_16.gemfile +0 -17
  126. data/gemfiles/rest_client_20.gemfile +0 -17
  127. data/gemfiles/roda_20.gemfile +0 -16
  128. data/gemfiles/roda_30.gemfile +0 -16
  129. data/gemfiles/rubocop_162.gemfile +0 -6
  130. data/gemfiles/sequel_56.gemfile +0 -16
  131. data/gemfiles/sequel_57.gemfile +0 -16
  132. data/gemfiles/sequel_58.gemfile +0 -16
  133. data/gemfiles/shoryuken_50.gemfile +0 -16
  134. data/gemfiles/shoryuken_60.gemfile +0 -13
  135. data/gemfiles/sidekiq_42.gemfile +0 -15
  136. data/gemfiles/sidekiq_50.gemfile +0 -15
  137. data/gemfiles/sidekiq_60.gemfile +0 -12
  138. data/gemfiles/sidekiq_65.gemfile +0 -12
  139. data/gemfiles/sidekiq_70.gemfile +0 -12
  140. data/gemfiles/sinatra_14.gemfile +0 -15
  141. data/gemfiles/sinatra_22.gemfile +0 -12
  142. data/gemfiles/sinatra_30.gemfile +0 -12
  143. data/gemfiles/sinatra_40.gemfile +0 -12
  144. data/instana.gemspec +0 -48
  145. data/lib/instana/open_tracing/carrier.rb +0 -7
  146. data/lib/instana/open_tracing/instana_tracer.rb +0 -99
  147. data/lib/instana/tracing/span.rb +0 -431
  148. data/lib/opentracing.rb +0 -32
  149. data/log/.keep +0 -0
  150. data/sonar-project.properties +0 -9
  151. data/test/activator_test.rb +0 -50
  152. data/test/backend/agent_test.rb +0 -80
  153. data/test/backend/gc_snapshot_test.rb +0 -11
  154. data/test/backend/host_agent_activation_observer_test.rb +0 -73
  155. data/test/backend/host_agent_lookup_test.rb +0 -78
  156. data/test/backend/host_agent_reporting_observer_test.rb +0 -276
  157. data/test/backend/host_agent_test.rb +0 -89
  158. data/test/backend/process_info_test.rb +0 -83
  159. data/test/backend/request_client_test.rb +0 -39
  160. data/test/backend/serverless_agent_test.rb +0 -83
  161. data/test/benchmarks/bench_id_generation.rb +0 -15
  162. data/test/benchmarks/bench_opentracing.rb +0 -16
  163. data/test/config_test.rb +0 -34
  164. data/test/frameworks/cuba_test.rb +0 -61
  165. data/test/frameworks/roda_test.rb +0 -60
  166. data/test/frameworks/sinatra_test.rb +0 -71
  167. data/test/instana_test.rb +0 -37
  168. data/test/instrumentation/aws_test.rb +0 -241
  169. data/test/instrumentation/dalli_test.rb +0 -325
  170. data/test/instrumentation/excon_test.rb +0 -204
  171. data/test/instrumentation/graphql_test.rb +0 -289
  172. data/test/instrumentation/grpc_test.rb +0 -420
  173. data/test/instrumentation/mongo_test.rb +0 -68
  174. data/test/instrumentation/net_http_test.rb +0 -220
  175. data/test/instrumentation/rack_instrumented_request_test.rb +0 -211
  176. data/test/instrumentation/rack_test.rb +0 -415
  177. data/test/instrumentation/rails_action_cable_test.rb +0 -135
  178. data/test/instrumentation/rails_action_controller_test.rb +0 -218
  179. data/test/instrumentation/rails_action_mailer_test.rb +0 -66
  180. data/test/instrumentation/rails_action_view_test.rb +0 -154
  181. data/test/instrumentation/rails_active_job_test.rb +0 -65
  182. data/test/instrumentation/rails_active_record_database_missing_test.rb +0 -45
  183. data/test/instrumentation/rails_active_record_test.rb +0 -115
  184. data/test/instrumentation/redis_test.rb +0 -152
  185. data/test/instrumentation/resque_test.rb +0 -188
  186. data/test/instrumentation/rest_client_test.rb +0 -107
  187. data/test/instrumentation/sequel_test.rb +0 -105
  188. data/test/instrumentation/shoryuken_test.rb +0 -47
  189. data/test/instrumentation/sidekiq-client_test.rb +0 -169
  190. data/test/instrumentation/sidekiq-worker_test.rb +0 -180
  191. data/test/secrets_test.rb +0 -112
  192. data/test/serverless_test.rb +0 -369
  193. data/test/snapshot/deltable_test.rb +0 -17
  194. data/test/snapshot/docker_container_test.rb +0 -82
  195. data/test/snapshot/fargate_container_test.rb +0 -82
  196. data/test/snapshot/fargate_process_test.rb +0 -35
  197. data/test/snapshot/fargate_task_test.rb +0 -49
  198. data/test/snapshot/google_cloud_run_instance_test.rb +0 -74
  199. data/test/snapshot/google_cloud_run_process_test.rb +0 -33
  200. data/test/snapshot/lambda_function_test.rb +0 -37
  201. data/test/snapshot/ruby_process_test.rb +0 -32
  202. data/test/support/apps/active_record/active_record.rb +0 -24
  203. data/test/support/apps/grpc/boot.rb +0 -23
  204. data/test/support/apps/grpc/grpc_server.rb +0 -84
  205. data/test/support/apps/http_endpoint/boot.rb +0 -28
  206. data/test/support/apps/rails/boot.rb +0 -219
  207. data/test/support/apps/rails/models/block.rb +0 -21
  208. data/test/support/apps/rails/models/block6.rb +0 -21
  209. data/test/support/apps/resque/boot.rb +0 -5
  210. data/test/support/apps/resque/jobs/resque_error_job.rb +0 -22
  211. data/test/support/apps/resque/jobs/resque_fast_job.rb +0 -23
  212. data/test/support/apps/sidekiq/boot.rb +0 -25
  213. data/test/support/apps/sidekiq/jobs/sidekiq_job_1.rb +0 -9
  214. data/test/support/apps/sidekiq/jobs/sidekiq_job_2.rb +0 -10
  215. data/test/support/apps/sidekiq/worker.rb +0 -37
  216. data/test/support/helpers.rb +0 -85
  217. data/test/support/mock_timer.rb +0 -20
  218. data/test/test_helper.rb +0 -69
  219. data/test/tracing/custom_test.rb +0 -226
  220. data/test/tracing/id_management_test.rb +0 -80
  221. data/test/tracing/instrumented_logger_test.rb +0 -39
  222. data/test/tracing/opentracing_test.rb +0 -382
  223. data/test/tracing/processor_test.rb +0 -58
  224. data/test/tracing/span_context_test.rb +0 -22
  225. data/test/tracing/span_test.rb +0 -179
  226. data/test/tracing/tracer_async_test.rb +0 -230
  227. data/test/tracing/tracer_test.rb +0 -352
  228. data/test/util_test.rb +0 -10
@@ -1,39 +0,0 @@
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
@@ -1,83 +0,0 @@
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
-
74
- def test_start
75
- subject = Instana::Backend::ServerlessAgent.new([], timer_class: MockTimer, backend_uri: 'http://10.10.10.10:9292/', logger: Logger.new('/dev/null'))
76
- assert subject.respond_to? :start
77
- end
78
-
79
- def test_after_fork
80
- subject = Instana::Backend::ServerlessAgent.new([], timer_class: MockTimer, backend_uri: 'http://10.10.10.10:9292/', logger: Logger.new('/dev/null'))
81
- assert subject.respond_to? :after_fork
82
- end
83
- end
@@ -1,15 +0,0 @@
1
- # (c) Copyright IBM Corp. 2021
2
- # (c) Copyright Instana Inc. 2017
3
-
4
- require 'test_helper'
5
-
6
- class BenchIDs < Minitest::Benchmark
7
- def bench_generate_id
8
- # TODO: This performs poorly on JRuby.
9
- assert_performance_constant do |input|
10
- 500_000.times do
11
- ::Instana::Util.generate_id
12
- end
13
- end
14
- end
15
- end
@@ -1,16 +0,0 @@
1
- # (c) Copyright IBM Corp. 2021
2
- # (c) Copyright Instana Inc. 2017
3
-
4
- require 'test_helper'
5
-
6
- class BenchOpenTracing < Minitest::Benchmark
7
- def bench_start_finish_span
8
- assert_performance_constant do |input|
9
- 10_000.times do
10
- span = ::Instana.tracer.start_span(:blah)
11
- span.set_tag(:zero, 0)
12
- span.finish
13
- end
14
- end
15
- end
16
- end
data/test/config_test.rb DELETED
@@ -1,34 +0,0 @@
1
- # (c) Copyright IBM Corp. 2021
2
- # (c) Copyright Instana Inc. 2016
3
-
4
- require 'test_helper'
5
-
6
- class ConfigTest < Minitest::Test
7
- def test_that_config_exists
8
- refute_nil ::Instana.config
9
- assert_instance_of(::Instana::Config, ::Instana.config)
10
- end
11
-
12
- def test_that_it_has_defaults
13
- assert_equal '127.0.0.1', ::Instana.config[:agent_host]
14
- assert_equal 42699, ::Instana.config[:agent_port]
15
-
16
- assert ::Instana.config[:tracing][:enabled]
17
- assert ::Instana.config[:metrics][:enabled]
18
-
19
- ::Instana.config[:metrics].each do |k, v|
20
- next unless v.is_a? Hash
21
- assert_equal true, ::Instana.config[:metrics][k].key?(:enabled)
22
- end
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
34
- end
@@ -1,61 +0,0 @@
1
- # (c) Copyright IBM Corp. 2021
2
- # (c) Copyright Instana Inc. 2016
3
-
4
- require 'test_helper'
5
- require 'rack/test'
6
-
7
- class CubaTest < Minitest::Test
8
- include Rack::Test::Methods
9
-
10
- # rack < 3.0.0 returns a two long array `app, options`
11
- # rack >= 3.0.0 returns only the app
12
- APP, * = Rack::Builder.parse_file('test/support/apps/cuba/config.ru')
13
-
14
- def app
15
- APP
16
- end
17
-
18
- def test_basic_get
19
- clear_all!
20
-
21
- r = get '/hello'
22
- assert last_response.ok?
23
-
24
- assert r.headers.key?("X-Instana-T")
25
- assert r.headers.key?("X-Instana-S")
26
-
27
- spans = ::Instana.processor.queued_spans
28
- assert_equal 1, spans.count
29
-
30
- first_span = spans.first
31
- assert_equal :rack, first_span[:n]
32
- assert first_span.key?(:data)
33
- assert first_span[:data].key?(:http)
34
-
35
- assert first_span[:data][:http].key?(:method)
36
- assert_equal "GET", first_span[:data][:http][:method]
37
-
38
- assert first_span[:data][:http].key?(:url)
39
- assert_equal "/hello", first_span[:data][:http][:url]
40
-
41
- assert first_span[:data][:http].key?(:status)
42
- assert_equal 200, first_span[:data][:http][:status]
43
-
44
- assert first_span[:data][:http].key?(:host)
45
- assert_equal "example.org", first_span[:data][:http][:host]
46
- end
47
-
48
- def test_path_template
49
- clear_all!
50
-
51
- r = get '/greet/instana'
52
- assert last_response.ok?
53
-
54
- spans = ::Instana.processor.queued_spans
55
- assert_equal 1, spans.count
56
-
57
- first_span = spans.first
58
- assert_equal :rack, first_span[:n]
59
- assert_equal '/greet/{name}', first_span[:data][:http][:path_tpl]
60
- end
61
- end
@@ -1,60 +0,0 @@
1
-
2
-
3
- # (c) Copyright IBM Corp. 2021
4
- # (c) Copyright Instana Inc. 2016
5
-
6
- require 'test_helper'
7
- require 'rack/test'
8
-
9
- class RodaTest < Minitest::Test
10
- include Rack::Test::Methods
11
- APP = Rack::Builder.parse_file('test/support/apps/roda/config.ru').first
12
-
13
- def app
14
- APP
15
- end
16
-
17
- def test_basic_get
18
- clear_all!
19
-
20
- r = get '/hello'
21
- assert last_response.ok?
22
-
23
- assert r.headers.key?("X-Instana-T")
24
- assert r.headers.key?("X-Instana-S")
25
-
26
- spans = ::Instana.processor.queued_spans
27
- assert_equal 1, spans.count
28
-
29
- first_span = spans.first
30
- assert_equal :rack, first_span[:n]
31
- assert first_span.key?(:data)
32
- assert first_span[:data].key?(:http)
33
-
34
- assert first_span[:data][:http].key?(:method)
35
- assert_equal "GET", first_span[:data][:http][:method]
36
-
37
- assert first_span[:data][:http].key?(:url)
38
- assert_equal "/hello", first_span[:data][:http][:url]
39
-
40
- assert first_span[:data][:http].key?(:status)
41
- assert_equal 200, first_span[:data][:http][:status]
42
-
43
- assert first_span[:data][:http].key?(:host)
44
- assert_equal "example.org", first_span[:data][:http][:host]
45
- end
46
-
47
- def test_path_template
48
- clear_all!
49
-
50
- r = get '/greet/instana'
51
- assert last_response.ok?
52
-
53
- spans = ::Instana.processor.queued_spans
54
- assert_equal 1, spans.count
55
-
56
- first_span = spans.first
57
- assert_equal :rack, first_span[:n]
58
- assert_equal '/greet/{name}', first_span[:data][:http][:path_tpl]
59
- end
60
- end
@@ -1,71 +0,0 @@
1
- # (c) Copyright IBM Corp. 2021
2
- # (c) Copyright Instana Inc. 2016
3
-
4
- require 'test_helper'
5
- require 'rack/test'
6
-
7
- class SinatraTest < Minitest::Test
8
- include Rack::Test::Methods
9
- APP = Rack::Builder.parse_file('test/support/apps/sinatra/config.ru')
10
-
11
- sinatra_version = Gem::Specification.find_by_name('sinatra').version
12
- if sinatra_version < Gem::Version.new('4.0.0')
13
- APP = APP.first
14
- end
15
-
16
- def app
17
- APP
18
- end
19
-
20
- def test_basic_get
21
- clear_all!
22
- r = get '/'
23
-
24
- assert last_response.ok?
25
-
26
-
27
- spans = ::Instana.processor.queued_spans
28
- assert_equal 1, spans.count
29
-
30
- rack_span = spans.first
31
- assert_equal :rack, rack_span[:n]
32
- # ::Instana::Util.pry!
33
-
34
- assert r.headers.key?("X-Instana-T")
35
- assert r.headers["X-Instana-T"] == ::Instana::Util.id_to_header(rack_span[:t])
36
- assert r.headers.key?("X-Instana-S")
37
- assert r.headers["X-Instana-S"] == ::Instana::Util.id_to_header(rack_span[:s])
38
- assert r.headers.key?("X-Instana-L")
39
- assert r.headers["X-Instana-L"] == '1'
40
- assert r.headers.key?("Server-Timing")
41
- assert r.headers["Server-Timing"] == "intid;desc=#{::Instana::Util.id_to_header(rack_span[:t])}"
42
-
43
- assert rack_span.key?(:data)
44
- assert rack_span[:data].key?(:http)
45
- assert rack_span[:data][:http].key?(:method)
46
- assert_equal "GET", rack_span[:data][:http][:method]
47
-
48
- assert rack_span[:data][:http].key?(:url)
49
- assert_equal "/", rack_span[:data][:http][:url]
50
-
51
- assert rack_span[:data][:http].key?(:status)
52
- assert_equal 200, rack_span[:data][:http][:status]
53
-
54
- assert rack_span[:data][:http].key?(:host)
55
- assert_equal "example.org", rack_span[:data][:http][:host]
56
- end
57
-
58
- def test_path_template
59
- clear_all!
60
-
61
- r = get '/greet/instana'
62
- assert last_response.ok?
63
-
64
- spans = ::Instana.processor.queued_spans
65
- assert_equal 1, spans.count
66
-
67
- first_span = spans.first
68
- assert_equal :rack, first_span[:n]
69
- assert_equal '/greet/:name', first_span[:data][:http][:path_tpl]
70
- end
71
- end
data/test/instana_test.rb DELETED
@@ -1,37 +0,0 @@
1
- # (c) Copyright IBM Corp. 2021
2
- # (c) Copyright Instana Inc. 2016
3
-
4
- require 'test_helper'
5
-
6
- class InstanaTest < Minitest::Test
7
- def test_that_it_has_a_version_number
8
- refute_nil ::Instana::VERSION
9
- end
10
-
11
- def test_that_it_has_a_logger
12
- refute_nil ::Instana.logger
13
- end
14
-
15
- def test_that_it_has_an_agent
16
- refute_nil ::Instana.agent
17
- end
18
-
19
- def test_that_it_has_a_tracer
20
- refute_nil ::Instana.tracer
21
- end
22
-
23
- def test_that_it_has_a_config
24
- refute_nil ::Instana.config
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
37
- end
@@ -1,241 +0,0 @@
1
- # (c) Copyright IBM Corp. 2021
2
- # (c) Copyright Instana Inc. 2021
3
-
4
- require 'test_helper'
5
-
6
- class AwsTest < Minitest::Test
7
- def setup
8
- clear_all!
9
- end
10
-
11
- def test_dynamo_db
12
- dynamo = Aws::DynamoDB::Client.new(
13
- region: "local",
14
- access_key_id: "placeholder",
15
- secret_access_key: "placeholder",
16
- endpoint: "http://localhost:8000"
17
- )
18
-
19
- assert_raises Aws::DynamoDB::Errors::ResourceNotFoundException do
20
- Instana::Tracer.start_or_continue_trace(:dynamo_test, {}) do
21
- dynamo.get_item(
22
- table_name: 'sample_table',
23
- key: { s: 'sample_item' }
24
- )
25
- end
26
- end
27
-
28
- spans = ::Instana.processor.queued_spans
29
- dynamo_span, entry_span, *rest = spans
30
-
31
- assert rest.empty?
32
- assert_equal entry_span[:s], dynamo_span[:p]
33
- assert_equal :dynamodb, dynamo_span[:n]
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
- s3_client = Aws::S3::Client.new(
40
- region: "local",
41
- access_key_id: "minioadmin",
42
- secret_access_key: "minioadmin",
43
- force_path_style: "true",
44
- endpoint: "http://localhost:9000"
45
- )
46
-
47
- assert_raises Aws::S3::Errors::NoSuchBucket do
48
- Instana::Tracer.start_or_continue_trace(:s3_test, {}) do
49
- s3_client.get_object(
50
- bucket: 'sample-bucket',
51
- key: 'sample_key'
52
- )
53
- end
54
- end
55
-
56
- spans = ::Instana.processor.queued_spans
57
- s3_span, entry_span, *rest = spans
58
-
59
- assert rest.empty?
60
- assert_equal entry_span[:s], s3_span[:p]
61
- assert_equal :s3, s3_span[:n]
62
- assert_equal 'get', s3_span[:data][:s3][:op]
63
- assert_equal 'sample-bucket', s3_span[:data][:s3][:bucket]
64
- assert_equal 'sample_key', s3_span[:data][:s3][:key]
65
- end
66
-
67
- def test_sns_publish
68
- sns = Aws::SNS::Client.new(
69
- region: "local",
70
- access_key_id: "test",
71
- secret_access_key: "test",
72
- endpoint: "http://localhost:9911"
73
- )
74
-
75
- assert_raises Aws::SNS::Errors::NotFound do
76
- Instana::Tracer.start_or_continue_trace(:sns_test, {}) do
77
- sns.publish(
78
- topic_arn: 'topic:arn',
79
- target_arn: 'target:arn',
80
- phone_number: '555-0100',
81
- subject: 'Test Subject',
82
- message: 'Test Message'
83
- )
84
- end
85
- end
86
-
87
- spans = ::Instana.processor.queued_spans
88
- aws_span, entry_span, *rest = spans
89
-
90
- assert rest.empty?
91
- assert_equal entry_span[:s], aws_span[:p]
92
- assert_equal :sns, aws_span[:n]
93
- assert_equal 'topic:arn', aws_span[:data][:sns][:topic]
94
- assert_equal 'target:arn', aws_span[:data][:sns][:target]
95
- assert_equal '555-0100', aws_span[:data][:sns][:phone]
96
- assert_equal 'Test Subject', aws_span[:data][:sns][:subject]
97
- end
98
-
99
- def test_sns_other
100
- sns = Aws::SNS::Client.new(
101
- region: "local",
102
- access_key_id: "test",
103
- secret_access_key: "test",
104
- endpoint: "http://localhost:9911"
105
- )
106
-
107
- Instana::Tracer.start_or_continue_trace(:sns_test, {}) do
108
- sns.list_subscriptions
109
- end
110
-
111
- spans = ::Instana.processor.queued_spans
112
- aws_span, entry_span, *rest = spans
113
-
114
- assert rest.empty?
115
- assert_equal entry_span[:s], aws_span[:p]
116
- assert_equal :"net-http", aws_span[:n]
117
- end
118
-
119
- def test_sqs
120
- sqs = Aws::SQS::Client.new(
121
- region: "local",
122
- access_key_id: "test",
123
- secret_access_key: "test",
124
- endpoint: "http://localhost:9324"
125
- )
126
-
127
- create_response = nil
128
- get_url_response = nil
129
-
130
- Instana::Tracer.start_or_continue_trace(:sqs_test, {}) do
131
- create_response = sqs.create_queue(queue_name: 'test')
132
- get_url_response = sqs.get_queue_url(queue_name: 'test')
133
- sqs.send_message(queue_url: create_response.queue_url, message_body: 'Sample')
134
- end
135
-
136
- received = sqs.receive_message(
137
- queue_url: create_response.queue_url,
138
- message_attribute_names: ['All']
139
- )
140
- sqs.delete_queue(queue_url: create_response.queue_url)
141
- message = received.messages.first
142
- create_span, get_span, send_span, _root = ::Instana.processor.queued_spans
143
-
144
- assert_equal :sqs, create_span[:n]
145
- assert_equal create_response.queue_url, create_span[:data][:sqs][:queue]
146
- assert_equal 'exit', create_span[:data][:sqs][:sort]
147
- assert_equal 'create.queue', create_span[:data][:sqs][:type]
148
-
149
- assert_equal :sqs, get_span[:n]
150
- assert_equal get_url_response.queue_url, get_span[:data][:sqs][:queue]
151
- assert_equal 'exit', get_span[:data][:sqs][:sort]
152
- assert_equal 'get.queue', get_span[:data][:sqs][:type]
153
-
154
- assert_equal :sqs, send_span[:n]
155
- assert_equal get_url_response.queue_url, send_span[:data][:sqs][:queue]
156
- assert_equal 'exit', send_span[:data][:sqs][:sort]
157
- assert_equal 'single.sync', send_span[:data][:sqs][:type]
158
- assert_equal send_span[:t], message.message_attributes['X_INSTANA_T'].string_value
159
- assert_equal send_span[:s], message.message_attributes['X_INSTANA_S'].string_value
160
- assert_equal 'Sample', message.body
161
- end
162
-
163
- def test_lambda
164
- stub_request(:post, "https://lambda.local.amazonaws.com/2015-03-31/functions/Test/invocations")
165
- .with(
166
- body: "data",
167
- headers: {
168
- 'X-Amz-Client-Context' => /.+/
169
- }
170
- )
171
- .to_return(status: 200, body: "", headers: {})
172
-
173
- lambda = Aws::Lambda::Client.new(
174
- endpoint: 'https://lambda.local.amazonaws.com',
175
- region: 'local',
176
- access_key_id: "test",
177
- secret_access_key: "test"
178
- )
179
-
180
- Instana::Tracer.start_or_continue_trace(:lambda_test, {}) do
181
- lambda.invoke(
182
- function_name: 'Test',
183
- invocation_type: 'Event',
184
- payload: 'data'
185
- )
186
- end
187
-
188
- spans = ::Instana.processor.queued_spans
189
- lambda_span, _entry_span, *rest = spans
190
-
191
- assert rest.empty?
192
-
193
- assert_equal :"aws.lambda.invoke", lambda_span[:n]
194
- assert_equal 'Test', lambda_span[:data][:aws][:lambda][:invoke][:function]
195
- assert_equal 'Event', lambda_span[:data][:aws][:lambda][:invoke][:type]
196
- assert_equal 200, lambda_span[:data][:http][:status]
197
- assert_nil lambda_span[:ec]
198
- assert_nil lambda_span[:stack]
199
- end
200
-
201
- def test_lambda_with_500_status
202
- stub_request(:post, "https://lambda.local.amazonaws.com/2015-03-31/functions/Test/invocations")
203
- .with(
204
- body: "data",
205
- headers: {
206
- 'X-Amz-Client-Context' => /.+/
207
- }
208
- )
209
- .to_return(status: 500, body: '{"message": "Internal Server Error" }', headers: {})
210
-
211
- lambda = Aws::Lambda::Client.new(
212
- endpoint: 'https://lambda.local.amazonaws.com',
213
- region: 'local',
214
- access_key_id: "test",
215
- secret_access_key: "test"
216
- )
217
-
218
- assert_raises(RuntimeError) do
219
- Instana::Tracer.start_or_continue_trace(:lambda_test, {}) do
220
- lambda.invoke(
221
- function_name: 'Test',
222
- invocation_type: 'Event',
223
- payload: 'data'
224
- )
225
- end
226
- end
227
-
228
- spans = ::Instana.processor.queued_spans
229
- lambda_span, _entry_span, *rest = spans
230
-
231
- assert rest.empty?
232
-
233
- assert_equal :"aws.lambda.invoke", lambda_span[:n]
234
- assert_equal 'Test', lambda_span[:data][:aws][:lambda][:invoke][:function]
235
- assert_equal 'Event', lambda_span[:data][:aws][:lambda][:invoke][:type]
236
- refute_nil lambda_span[:ec]
237
- assert_equal 1, lambda_span[:ec]
238
- refute_nil lambda_span[:stack]
239
- assert_equal 30, lambda_span[:stack].length # default limit is 30 in span.add_stack
240
- end
241
- end