instana 2.0.0 → 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 (186) hide show
  1. checksums.yaml +4 -4
  2. data/lib/instana/setup.rb +1 -0
  3. data/lib/instana/span_filtering/condition.rb +134 -0
  4. data/lib/instana/span_filtering/configuration.rb +262 -0
  5. data/lib/instana/span_filtering/filter_rule.rb +31 -0
  6. data/lib/instana/span_filtering.rb +62 -0
  7. data/lib/instana/trace/span.rb +5 -3
  8. data/lib/instana/version.rb +1 -1
  9. metadata +7 -258
  10. data/.circleci/config.yml +0 -361
  11. data/.codeclimate.yml +0 -23
  12. data/.editorconfig +0 -10
  13. data/.fasterer.yml +0 -23
  14. data/.github/ISSUE_TEMPLATE/bug.yml +0 -39
  15. data/.github/ISSUE_TEMPLATE/config.yml +0 -8
  16. data/.github/workflows/pr_commits_signed_off.yml +0 -16
  17. data/.github/workflows/release-notification-on-slack.yml +0 -34
  18. data/.gitignore +0 -19
  19. data/.rubocop.yml +0 -34
  20. data/.rubocop_todo.yml +0 -1140
  21. data/.tekton/.currency/docs/report.md +0 -20
  22. data/.tekton/.currency/resources/requirements.txt +0 -4
  23. data/.tekton/.currency/resources/table.json +0 -100
  24. data/.tekton/.currency/scripts/generate_report.py +0 -308
  25. data/.tekton/README.md +0 -278
  26. data/.tekton/github-interceptor-secret.yaml +0 -8
  27. data/.tekton/github-pr-eventlistener.yaml +0 -104
  28. data/.tekton/github-pr-pipeline.yaml.part +0 -38
  29. data/.tekton/github-set-status-task.yaml +0 -43
  30. data/.tekton/github-webhook-ingress.yaml +0 -20
  31. data/.tekton/pipeline.yaml +0 -484
  32. data/.tekton/pipelinerun.yaml +0 -21
  33. data/.tekton/prepuller-restart-service-account.yaml +0 -31
  34. data/.tekton/ruby-tracer-prepuller-cronjob.yaml +0 -20
  35. data/.tekton/ruby-tracer-prepuller.yaml +0 -88
  36. data/.tekton/run_unittests.sh +0 -87
  37. data/.tekton/scheduled-eventlistener.yaml +0 -108
  38. data/.tekton/task.yaml +0 -453
  39. data/.tekton/tekton-triggers-eventlistener-serviceaccount.yaml +0 -29
  40. data/Appraisals +0 -124
  41. data/CONTRIBUTING.md +0 -86
  42. data/Gemfile +0 -22
  43. data/LICENSE +0 -22
  44. data/MAINTAINERS.md +0 -3
  45. data/Rakefile +0 -49
  46. data/bin/announce_release_on_slack.py +0 -103
  47. data/docker-compose.yml +0 -20
  48. data/download.sh +0 -85
  49. data/examples/otel.rb +0 -98
  50. data/examples/tracing.rb +0 -85
  51. data/extras/license_header.rb +0 -44
  52. data/gemfiles/.bundle/config +0 -2
  53. data/gemfiles/aws_30.gemfile +0 -21
  54. data/gemfiles/aws_60.gemfile +0 -16
  55. data/gemfiles/cuba_30.gemfile +0 -16
  56. data/gemfiles/cuba_40.gemfile +0 -13
  57. data/gemfiles/dalli_20.gemfile +0 -15
  58. data/gemfiles/dalli_30.gemfile +0 -12
  59. data/gemfiles/dalli_32.gemfile +0 -12
  60. data/gemfiles/excon_0100.gemfile +0 -14
  61. data/gemfiles/excon_021.gemfile +0 -17
  62. data/gemfiles/excon_079.gemfile +0 -17
  63. data/gemfiles/excon_100.gemfile +0 -14
  64. data/gemfiles/graphql_10.gemfile +0 -16
  65. data/gemfiles/graphql_20.gemfile +0 -15
  66. data/gemfiles/grpc_10.gemfile +0 -15
  67. data/gemfiles/mongo_216.gemfile +0 -15
  68. data/gemfiles/mongo_219.gemfile +0 -12
  69. data/gemfiles/net_http_01.gemfile +0 -17
  70. data/gemfiles/rack_16.gemfile +0 -15
  71. data/gemfiles/rack_20.gemfile +0 -15
  72. data/gemfiles/rack_30.gemfile +0 -13
  73. data/gemfiles/rails_42.gemfile +0 -18
  74. data/gemfiles/rails_50.gemfile +0 -19
  75. data/gemfiles/rails_52.gemfile +0 -19
  76. data/gemfiles/rails_60.gemfile +0 -19
  77. data/gemfiles/rails_61.gemfile +0 -21
  78. data/gemfiles/rails_70.gemfile +0 -18
  79. data/gemfiles/rails_71.gemfile +0 -17
  80. data/gemfiles/rails_80.gemfile +0 -17
  81. data/gemfiles/redis_40.gemfile +0 -15
  82. data/gemfiles/redis_50.gemfile +0 -13
  83. data/gemfiles/redis_51.gemfile +0 -13
  84. data/gemfiles/resque_122.gemfile +0 -16
  85. data/gemfiles/resque_1274_3scale.gemfile +0 -17
  86. data/gemfiles/resque_20.gemfile +0 -16
  87. data/gemfiles/rest_client_16.gemfile +0 -17
  88. data/gemfiles/rest_client_20.gemfile +0 -17
  89. data/gemfiles/roda_20.gemfile +0 -16
  90. data/gemfiles/roda_30.gemfile +0 -16
  91. data/gemfiles/rubocop_162.gemfile +0 -6
  92. data/gemfiles/sequel_56.gemfile +0 -16
  93. data/gemfiles/sequel_57.gemfile +0 -16
  94. data/gemfiles/sequel_58.gemfile +0 -16
  95. data/gemfiles/shoryuken_50.gemfile +0 -16
  96. data/gemfiles/shoryuken_60.gemfile +0 -13
  97. data/gemfiles/sidekiq_42.gemfile +0 -15
  98. data/gemfiles/sidekiq_50.gemfile +0 -15
  99. data/gemfiles/sidekiq_60.gemfile +0 -12
  100. data/gemfiles/sidekiq_65.gemfile +0 -12
  101. data/gemfiles/sidekiq_70.gemfile +0 -12
  102. data/gemfiles/sinatra_14.gemfile +0 -15
  103. data/gemfiles/sinatra_22.gemfile +0 -12
  104. data/gemfiles/sinatra_30.gemfile +0 -12
  105. data/gemfiles/sinatra_40.gemfile +0 -12
  106. data/instana.gemspec +0 -53
  107. data/log/.keep +0 -0
  108. data/sonar-project.properties +0 -9
  109. data/test/activator_test.rb +0 -50
  110. data/test/backend/agent_test.rb +0 -80
  111. data/test/backend/gc_snapshot_test.rb +0 -11
  112. data/test/backend/host_agent_activation_observer_test.rb +0 -73
  113. data/test/backend/host_agent_lookup_test.rb +0 -78
  114. data/test/backend/host_agent_reporting_observer_test.rb +0 -276
  115. data/test/backend/host_agent_test.rb +0 -89
  116. data/test/backend/process_info_test.rb +0 -83
  117. data/test/backend/request_client_test.rb +0 -39
  118. data/test/backend/serverless_agent_test.rb +0 -83
  119. data/test/benchmarks/bench_id_generation.rb +0 -15
  120. data/test/benchmarks/bench_opentracing.rb +0 -16
  121. data/test/config_test.rb +0 -34
  122. data/test/frameworks/cuba_test.rb +0 -61
  123. data/test/frameworks/roda_test.rb +0 -60
  124. data/test/frameworks/sinatra_test.rb +0 -71
  125. data/test/instana_test.rb +0 -37
  126. data/test/instrumentation/aws_test.rb +0 -241
  127. data/test/instrumentation/dalli_test.rb +0 -325
  128. data/test/instrumentation/excon_test.rb +0 -204
  129. data/test/instrumentation/graphql_test.rb +0 -289
  130. data/test/instrumentation/grpc_test.rb +0 -420
  131. data/test/instrumentation/mongo_test.rb +0 -68
  132. data/test/instrumentation/net_http_test.rb +0 -220
  133. data/test/instrumentation/rack_instrumented_request_test.rb +0 -211
  134. data/test/instrumentation/rack_test.rb +0 -415
  135. data/test/instrumentation/rails_action_cable_test.rb +0 -135
  136. data/test/instrumentation/rails_action_controller_test.rb +0 -218
  137. data/test/instrumentation/rails_action_mailer_test.rb +0 -66
  138. data/test/instrumentation/rails_action_view_test.rb +0 -154
  139. data/test/instrumentation/rails_active_job_test.rb +0 -65
  140. data/test/instrumentation/rails_active_record_database_missing_test.rb +0 -44
  141. data/test/instrumentation/rails_active_record_test.rb +0 -116
  142. data/test/instrumentation/redis_test.rb +0 -152
  143. data/test/instrumentation/resque_test.rb +0 -188
  144. data/test/instrumentation/rest_client_test.rb +0 -106
  145. data/test/instrumentation/sequel_test.rb +0 -111
  146. data/test/instrumentation/shoryuken_test.rb +0 -47
  147. data/test/instrumentation/sidekiq-client_test.rb +0 -169
  148. data/test/instrumentation/sidekiq-worker_test.rb +0 -180
  149. data/test/secrets_test.rb +0 -112
  150. data/test/serverless_test.rb +0 -369
  151. data/test/snapshot/deltable_test.rb +0 -17
  152. data/test/snapshot/docker_container_test.rb +0 -82
  153. data/test/snapshot/fargate_container_test.rb +0 -82
  154. data/test/snapshot/fargate_process_test.rb +0 -35
  155. data/test/snapshot/fargate_task_test.rb +0 -49
  156. data/test/snapshot/google_cloud_run_instance_test.rb +0 -74
  157. data/test/snapshot/google_cloud_run_process_test.rb +0 -33
  158. data/test/snapshot/lambda_function_test.rb +0 -37
  159. data/test/snapshot/ruby_process_test.rb +0 -32
  160. data/test/support/apps/active_record/active_record.rb +0 -24
  161. data/test/support/apps/grpc/boot.rb +0 -23
  162. data/test/support/apps/grpc/grpc_server.rb +0 -84
  163. data/test/support/apps/http_endpoint/boot.rb +0 -28
  164. data/test/support/apps/rails/boot.rb +0 -219
  165. data/test/support/apps/rails/models/block.rb +0 -21
  166. data/test/support/apps/rails/models/block6.rb +0 -21
  167. data/test/support/apps/resque/boot.rb +0 -5
  168. data/test/support/apps/resque/jobs/resque_error_job.rb +0 -22
  169. data/test/support/apps/resque/jobs/resque_fast_job.rb +0 -23
  170. data/test/support/apps/sidekiq/boot.rb +0 -25
  171. data/test/support/apps/sidekiq/jobs/sidekiq_job_1.rb +0 -9
  172. data/test/support/apps/sidekiq/jobs/sidekiq_job_2.rb +0 -10
  173. data/test/support/apps/sidekiq/worker.rb +0 -37
  174. data/test/support/helpers.rb +0 -85
  175. data/test/support/mock_timer.rb +0 -20
  176. data/test/test_helper.rb +0 -69
  177. data/test/trace/custom_test.rb +0 -233
  178. data/test/trace/id_management_test.rb +0 -78
  179. data/test/trace/instrumented_logger_test.rb +0 -39
  180. data/test/trace/processor_test.rb +0 -58
  181. data/test/trace/span_context_test.rb +0 -22
  182. data/test/trace/span_test.rb +0 -179
  183. data/test/trace/tracer_async_test.rb +0 -243
  184. data/test/trace/tracer_provider_test.rb +0 -148
  185. data/test/trace/tracer_test.rb +0 -363
  186. data/test/util_test.rb +0 -10
@@ -1,78 +0,0 @@
1
- # (c) Copyright IBM Corp. 2021
2
- # (c) Copyright Instana Inc. 2021
3
-
4
- require 'test_helper'
5
-
6
- class HostAgentLookupTest < Minitest::Test
7
- def test_lookup
8
- stub_request(:get, "http://10.10.10.10:42699/")
9
- .to_return(status: 200)
10
-
11
- subject = Instana::Backend::HostAgentLookup.new('10.10.10.10', 42699)
12
- client = subject.call
13
-
14
- assert client
15
- assert client.send_request('GET', '/').ok?
16
- end
17
-
18
- def test_lookup_no_agent
19
- stub_request(:get, "http://10.10.10.10:42699/")
20
- .to_timeout
21
-
22
- subject = Instana::Backend::HostAgentLookup.new('10.10.10.10', 42699)
23
-
24
- client = FakeFS.with_fresh do
25
- FakeFS::FileSystem.clone('test/support/ecs', '/proc')
26
-
27
- subject.call
28
- end
29
-
30
- assert_nil client
31
- end
32
-
33
- def test_lookup_agent_error
34
- stub_request(:get, "http://10.10.10.10:42699/")
35
- .to_return(status: 500)
36
-
37
- subject = Instana::Backend::HostAgentLookup.new('10.10.10.10', 42699)
38
-
39
- client = FakeFS.with_fresh do
40
- FakeFS::FileSystem.clone('test/support/ecs', '/proc')
41
-
42
- subject.call
43
- end
44
-
45
- assert_nil client
46
- end
47
-
48
- def test_lookup_with_gateway
49
- stub_request(:get, "http://10.10.10.10:42699/")
50
- .to_timeout
51
- stub_request(:get, "http://172.18.0.1:42699/")
52
- .to_return(status: 200)
53
-
54
- subject = Instana::Backend::HostAgentLookup.new('10.10.10.10', 42699)
55
-
56
- client = FakeFS do
57
- FakeFS::FileSystem.clone('test/support/proc', '/proc')
58
- subject.call
59
- end
60
-
61
- assert client
62
- assert client.send_request('GET', '/').ok?
63
- end
64
-
65
- def test_lookup_with_gateway_no_destination
66
- stub_request(:get, "http://10.10.10.10:42699/")
67
- .to_timeout
68
-
69
- subject = Instana::Backend::HostAgentLookup.new('10.10.10.10', 42699, destination: '11111111')
70
-
71
- client = FakeFS do
72
- FakeFS::FileSystem.clone('test/support/proc', '/proc')
73
- subject.call
74
- end
75
-
76
- assert_nil client
77
- end
78
- end
@@ -1,276 +0,0 @@
1
- # (c) Copyright IBM Corp. 2021
2
- # (c) Copyright Instana Inc. 2021
3
-
4
- require 'test_helper'
5
-
6
- class HostAgentReportingObserverTest < Minitest::Test
7
- def test_start_stop
8
- client = Instana::Backend::RequestClient.new('10.10.10.10', 9292)
9
- discovery = Concurrent::Atom.new(nil)
10
-
11
- subject = Instana::Backend::HostAgentReportingObserver.new(client, discovery, timer_class: MockTimer)
12
-
13
- refute subject.report_timer.running
14
-
15
- subject.update(Time.now, nil, true)
16
- assert subject.report_timer.running
17
-
18
- subject.update(Time.now, nil, nil)
19
- refute subject.report_timer.running
20
-
21
- subject.update(Time.now - 500, nil, true)
22
- refute subject.report_timer.running
23
- end
24
-
25
- def test_report
26
- stub_request(:post, "http://10.10.10.10:9292/tracermetrics")
27
- .to_return(status: 200)
28
- stub_request(:post, "http://10.10.10.10:9292/com.instana.plugin.ruby.0")
29
- .to_return(status: 200)
30
-
31
- client = Instana::Backend::RequestClient.new('10.10.10.10', 9292)
32
- discovery = Concurrent::Atom.new({'pid' => 0})
33
-
34
- subject = Instana::Backend::HostAgentReportingObserver.new(client, discovery, timer_class: MockTimer)
35
-
36
- subject.report_timer.block.call
37
- end
38
-
39
- def test_report_fail
40
- stub_request(:post, "http://10.10.10.10:9292/tracermetrics")
41
- .to_return(status: 200)
42
- stub_request(:post, "http://10.10.10.10:9292/com.instana.plugin.ruby.0")
43
- .to_return(status: 500)
44
-
45
- client = Instana::Backend::RequestClient.new('10.10.10.10', 9292)
46
- discovery = Concurrent::Atom.new({'pid' => 0})
47
-
48
- subject = Instana::Backend::HostAgentReportingObserver.new(client, discovery, timer_class: MockTimer)
49
-
50
- subject.report_timer.block.call
51
- assert_nil discovery.value
52
- end
53
-
54
- def test_agent_action
55
- action = JSON.dump(
56
- {
57
- action: 'ruby.source',
58
- messageId: 'test',
59
- args: {file: 'test_helper.rb'}
60
- }
61
- )
62
-
63
- stub_request(:post, "http://10.10.10.10:9292/tracermetrics")
64
- .to_return(status: 200)
65
-
66
- stub_request(:post, "http://10.10.10.10:9292/com.instana.plugin.ruby.0")
67
- .to_return(status: 200, body: action)
68
-
69
- stub_request(:post, "http://10.10.10.10:9292/com.instana.plugin.ruby/response.0?messageId=test")
70
- .to_return(status: 200)
71
-
72
- client = Instana::Backend::RequestClient.new('10.10.10.10', 9292)
73
- discovery = Concurrent::Atom.new({'pid' => 0})
74
-
75
- subject = Instana::Backend::HostAgentReportingObserver.new(client, discovery, timer_class: MockTimer)
76
-
77
- subject.report_timer.block.call
78
- end
79
-
80
- def test_agent_actions
81
- action = JSON.dump([
82
- action: 'ruby.source',
83
- messageId: 'test',
84
- args: {file: 'test_helper.rb'}
85
- ])
86
-
87
- stub_request(:post, "http://10.10.10.10:9292/tracermetrics")
88
- .to_return(status: 200)
89
-
90
- stub_request(:post, "http://10.10.10.10:9292/com.instana.plugin.ruby.0")
91
- .to_return(status: 200, body: action)
92
-
93
- stub_request(:post, "http://10.10.10.10:9292/com.instana.plugin.ruby/response.0?messageId=test")
94
- .to_return(status: 200)
95
-
96
- client = Instana::Backend::RequestClient.new('10.10.10.10', 9292)
97
- discovery = Concurrent::Atom.new({'pid' => 0})
98
-
99
- subject = Instana::Backend::HostAgentReportingObserver.new(client, discovery, timer_class: MockTimer)
100
-
101
- subject.report_timer.block.call
102
- end
103
-
104
- def test_agent_action_error
105
- stub_request(:post, "http://10.10.10.10:9292/tracermetrics")
106
- .to_return(status: 200)
107
-
108
- stub_request(:post, "http://10.10.10.10:9292/com.instana.plugin.ruby.0")
109
- .to_return(status: 200, body: 'INVALID')
110
-
111
- client = Instana::Backend::RequestClient.new('10.10.10.10', 9292)
112
- discovery = Concurrent::Atom.new({'pid' => 0})
113
-
114
- subject = Instana::Backend::HostAgentReportingObserver.new(client, discovery, timer_class: MockTimer)
115
-
116
- subject.report_timer.block.call
117
- end
118
-
119
- def test_disable_metrics
120
- ::Instana.config[:metrics][:enabled] = false
121
-
122
- client = Instana::Backend::RequestClient.new('10.10.10.10', 9292)
123
- discovery = Concurrent::Atom.new(nil)
124
-
125
- subject = Instana::Backend::HostAgentReportingObserver.new(client, discovery, timer_class: MockTimer)
126
-
127
- subject.report_timer.block.call
128
- ensure
129
- ::Instana.config[:metrics][:enabled] = true
130
- end
131
-
132
- def test_disable_metrics_memory
133
- ::Instana.config[:metrics][:memory][:enabled] = false
134
-
135
- stub_request(:post, "http://10.10.10.10:9292/tracermetrics")
136
- .to_return(status: 200)
137
-
138
- stub_request(:post, "http://10.10.10.10:9292/com.instana.plugin.ruby.0")
139
- .with(body: ->(data) { (JSON.parse(data).keys & ['exec_args', 'memory']).length.eql?(0) })
140
- .to_return(status: 200)
141
-
142
- stub_request(:post, "http://10.10.10.10:9292/com.instana.plugin.ruby/traces.0")
143
- .to_return(status: 200)
144
-
145
- client = Instana::Backend::RequestClient.new('10.10.10.10', 9292)
146
- discovery = Concurrent::Atom.new({'pid' => 0})
147
-
148
- subject = Instana::Backend::HostAgentReportingObserver.new(client, discovery, timer_class: MockTimer)
149
-
150
- subject.report_timer.block.call
151
- ensure
152
- ::Instana.config[:metrics][:memory][:enabled] = true
153
- end
154
-
155
- def test_disable_gc
156
- ::Instana.config[:metrics][:gc][:enabled] = false
157
-
158
- stub_request(:post, "http://10.10.10.10:9292/tracermetrics")
159
- .to_return(status: 200)
160
-
161
- stub_request(:post, "http://10.10.10.10:9292/com.instana.plugin.ruby.0")
162
- .with(body: ->(data) { (JSON.parse(data).keys & ['gc']).length.eql?(0) })
163
- .to_return(status: 200)
164
-
165
- stub_request(:post, "http://10.10.10.10:9292/com.instana.plugin.ruby/traces.0")
166
- .to_return(status: 200)
167
-
168
- client = Instana::Backend::RequestClient.new('10.10.10.10', 9292)
169
- discovery = Concurrent::Atom.new({'pid' => 0})
170
-
171
- subject = Instana::Backend::HostAgentReportingObserver.new(client, discovery, timer_class: MockTimer)
172
-
173
- subject.report_timer.block.call
174
- ensure
175
- ::Instana.config[:metrics][:gc][:enabled] = true
176
- end
177
-
178
- def test_disable_thread
179
- ::Instana.config[:metrics][:thread][:enabled] = false
180
-
181
- stub_request(:post, "http://10.10.10.10:9292/tracermetrics")
182
- .to_return(status: 200)
183
-
184
- stub_request(:post, "http://10.10.10.10:9292/com.instana.plugin.ruby.0")
185
- .with(body: ->(data) { (JSON.parse(data).keys & ['thread']).length.eql?(0) })
186
- .to_return(status: 200)
187
-
188
- stub_request(:post, "http://10.10.10.10:9292/com.instana.plugin.ruby/traces.0")
189
- .to_return(status: 200)
190
-
191
- client = Instana::Backend::RequestClient.new('10.10.10.10', 9292)
192
- discovery = Concurrent::Atom.new({'pid' => 0})
193
-
194
- subject = Instana::Backend::HostAgentReportingObserver.new(client, discovery, timer_class: MockTimer)
195
-
196
- subject.report_timer.block.call
197
- ensure
198
- ::Instana.config[:metrics][:thread][:enabled] = true
199
- end
200
-
201
- def test_disable_tracing
202
- ::Instana.config[:tracing][:enabled] = false
203
-
204
- client = Instana::Backend::RequestClient.new('10.10.10.10', 9292)
205
- discovery = Concurrent::Atom.new(nil)
206
-
207
- subject = Instana::Backend::HostAgentReportingObserver.new(client, discovery, timer_class: MockTimer)
208
-
209
- subject.report_timer.block.call
210
- ensure
211
- ::Instana.config[:tracing][:enabled] = true
212
- end
213
-
214
- def test_report_traces
215
- stub_request(:post, "http://10.10.10.10:9292/com.instana.plugin.ruby.1234")
216
- .to_return(status: 200)
217
-
218
- stub_request(:post, "http://10.10.10.10:9292/com.instana.plugin.ruby/traces.1234")
219
- .to_return(status: 200)
220
-
221
- client = Instana::Backend::RequestClient.new('10.10.10.10', 9292)
222
- discovery = Concurrent::Atom.new({'pid' => 1234})
223
-
224
- processor = Class.new do
225
- def send
226
- yield([{n: 'test'}])
227
- end
228
- end.new
229
-
230
- subject = Instana::Backend::HostAgentReportingObserver.new(client, discovery, timer_class: MockTimer, processor: processor)
231
-
232
- subject.report_timer.block.call
233
- refute_nil discovery.value
234
- end
235
-
236
- def test_report_traces_error
237
- stub_request(:post, "http://10.10.10.10:9292/com.instana.plugin.ruby.1234")
238
- .to_return(status: 200)
239
-
240
- stub_request(:post, "http://10.10.10.10:9292/com.instana.plugin.ruby/traces.1234")
241
- .to_return(status: 500)
242
-
243
- client = Instana::Backend::RequestClient.new('10.10.10.10', 9292)
244
- discovery = Concurrent::Atom.new({'pid' => 1234})
245
-
246
- processor = Class.new do
247
- def send
248
- yield([{n: 'test'}])
249
- end
250
- end.new
251
-
252
- subject = Instana::Backend::HostAgentReportingObserver.new(client, discovery, timer_class: MockTimer, processor: processor)
253
-
254
- subject.report_timer.block.call
255
- assert_nil discovery.value
256
- end
257
-
258
- def test_report_standard_error
259
- stub_request(:post, "http://10.10.10.10:9292/com.instana.plugin.ruby.1234")
260
- .to_return(status: 200)
261
-
262
- client = Instana::Backend::RequestClient.new('10.10.10.10', 9292)
263
- discovery = Concurrent::Atom.new({'pid' => 1234})
264
-
265
- processor = Class.new do
266
- def send
267
- raise 'Standard Error'
268
- end
269
- end.new
270
-
271
- subject = Instana::Backend::HostAgentReportingObserver.new(client, discovery, timer_class: MockTimer, processor: processor, logger: Logger.new('/dev/null'))
272
-
273
- subject.report_timer.block.call
274
- assert_equal({"pid" => 1234}, discovery.value)
275
- end
276
- end
@@ -1,89 +0,0 @@
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
- agent_host = '10.10.10.10'
10
- ::Instana.config[:agent_host] = agent_host
11
-
12
- if File.exist?('/proc/net/route')
13
- default_gateway_hex = lambda {
14
- File.open('/proc/net/route', 'r') do |file|
15
- file.each_line do |line|
16
- columns = line.split("\t")
17
- if columns[1] == '00000000' && columns[1] == columns[7]
18
- return columns[2]
19
- end
20
- end
21
- end
22
- }.call
23
-
24
- addr = default_gateway_hex.scan(/.{2}/).map(&:hex).reverse.join('.')
25
- stub_request(:get, "http://#{addr}:42699/")
26
- .to_timeout
27
- end
28
-
29
- stub_request(:get, "http://#{agent_host}:42699/")
30
- .to_timeout.times(3).then
31
- .to_return(status: 200, body: "", headers: {})
32
-
33
- discovery = Minitest::Mock.new
34
- discovery.expect(:delete_observers, discovery, [])
35
- discovery.expect(:observers, discovery, [])
36
- discovery.expect(:notify_and_delete_observers, discovery, [Object, nil, nil])
37
- discovery.expect(:with_observer, discovery, [Instana::Backend::HostAgentActivationObserver])
38
- discovery.expect(:with_observer, discovery, [Instana::Backend::HostAgentReportingObserver])
39
- discovery.expect(:swap, discovery, [])
40
-
41
- subject = Instana::Backend::HostAgent.new(discovery: discovery)
42
-
43
- FakeFS.with_fresh do
44
- FakeFS::FileSystem.clone('test/support/ecs', '/proc')
45
- subject.spawn_background_thread
46
- end
47
-
48
- subject.future.value!
49
-
50
- discovery.verify
51
- ensure
52
- ::Instana.config[:agent_host] = '127.0.0.1'
53
- ENV['INSTANA_TEST'] = 'true'
54
- end
55
-
56
- def test_discovery_value
57
- discovery = Concurrent::Atom.new({'pid' => 1})
58
- subject = Instana::Backend::HostAgent.new(discovery: discovery)
59
- assert_equal 1, subject.source[:e]
60
- end
61
-
62
- def test_extra_headers_from_tracing_config
63
- discovery = Concurrent::Atom.new(
64
- {
65
- 'tracing' => {
66
- 'extra-http-headers' => ["X-Header-1", "X-Header-2"]
67
- }
68
- }
69
- )
70
- subject = Instana::Backend::HostAgent.new(discovery: discovery)
71
- assert_equal ["X-Header-1", "X-Header-2"], subject.extra_headers
72
- end
73
-
74
- def test_extra_headers_legacy
75
- discovery = Concurrent::Atom.new({'extraHeaders' => ["X-Header-3", "X-Header-4"]})
76
- subject = Instana::Backend::HostAgent.new(discovery: discovery)
77
- assert_equal ["X-Header-3", "X-Header-4"], subject.extra_headers
78
- end
79
-
80
- def test_start
81
- subject = Instana::Backend::HostAgent.new
82
- assert subject.respond_to? :start
83
- end
84
-
85
- def test_after_fork
86
- subject = Instana::Backend::HostAgent.new
87
- assert subject.respond_to? :after_fork
88
- end
89
- 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 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
-
64
- def test_osx_memory_used
65
- host_os = RbConfig::CONFIG['host_os']
66
- RbConfig::CONFIG['host_os'] = 'darwin'
67
-
68
- subject = Instana::Backend::ProcessInfo.new(OpenStruct.new(rss: 1))
69
- assert_equal 1, subject.memory_used
70
- ensure
71
- RbConfig::CONFIG['host_os'] = host_os
72
- end
73
-
74
- def test_linux_memory_used
75
- host_os = RbConfig::CONFIG['host_os']
76
- RbConfig::CONFIG['host_os'] = 'linux'
77
-
78
- subject = Instana::Backend::ProcessInfo.new(OpenStruct.new(rss: 1))
79
- assert_equal 4096, subject.memory_used
80
- ensure
81
- RbConfig::CONFIG['host_os'] = host_os
82
- end
83
- end
@@ -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