instana 1.214.3 → 1.215.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +1 -10
  3. data/.tekton/.currency/currency-pipeline.yaml +36 -0
  4. data/.tekton/.currency/currency-pipelinerun.yaml +20 -0
  5. data/.tekton/.currency/currency-rbac.yaml +29 -0
  6. data/.tekton/.currency/currency-scheduled-eventlistener.yaml +56 -0
  7. data/.tekton/.currency/currency-tasks.yaml +94 -0
  8. data/.tekton/.currency/docs/report.md +19 -0
  9. data/.tekton/.currency/resources/requirements.txt +5 -0
  10. data/.tekton/.currency/resources/table.json +94 -0
  11. data/.tekton/.currency/scripts/generate_report.py +228 -0
  12. data/.tekton/github-pr-eventlistener.yaml +2 -0
  13. data/.tekton/pipeline.yaml +61 -19
  14. data/.tekton/pipelinerun.yaml +2 -0
  15. data/.tekton/ruby-tracer-prepuller.yaml +83 -0
  16. data/.tekton/scheduled-eventlistener.yaml +2 -0
  17. data/.tekton/task.yaml +3 -26
  18. data/gemfiles/net_http_01.gemfile +1 -0
  19. data/lib/instana/activators/action_view.rb +5 -2
  20. data/lib/instana/config.rb +3 -0
  21. data/lib/instana/instrumentation/action_view.rb +40 -14
  22. data/lib/instana/instrumentation/excon.rb +4 -2
  23. data/lib/instana/instrumentation/net-http.rb +7 -1
  24. data/lib/instana/instrumentation/redis.rb +1 -1
  25. data/lib/instana/tracer.rb +7 -6
  26. data/lib/instana/version.rb +1 -1
  27. data/test/backend/host_agent_test.rb +16 -4
  28. data/test/instrumentation/dalli_test.rb +33 -0
  29. data/test/instrumentation/excon_test.rb +40 -0
  30. data/test/instrumentation/graphql_test.rb +41 -0
  31. data/test/instrumentation/grpc_test.rb +40 -1
  32. data/test/instrumentation/mongo_test.rb +31 -0
  33. data/test/instrumentation/net_http_test.rb +22 -2
  34. data/test/instrumentation/rails_action_mailer_test.rb +18 -0
  35. data/test/instrumentation/rails_action_view_test.rb +0 -41
  36. data/test/instrumentation/redis_test.rb +23 -0
  37. data/test/instrumentation/resque_test.rb +21 -0
  38. data/test/instrumentation/rest_client_test.rb +43 -0
  39. data/test/instrumentation/sidekiq-client_test.rb +37 -3
  40. data/test/instrumentation/sidekiq-worker_test.rb +2 -2
  41. data/test/secrets_test.rb +1 -1
  42. data/test/tracing/tracer_test.rb +2 -2
  43. metadata +12 -2
@@ -25,19 +25,49 @@ spec:
25
25
  params:
26
26
  - name: imageDigest
27
27
  value:
28
- # 3.3.0-bookworm
29
- - "sha256:67ccb9c63d2a2ae9fcc7df5448800b740e140691ac74534f9fc687dbf5ce0da2"
28
+ # 3.3.1-bookworm
29
+ - "sha256:5cf0004738f54bd67e4c4316394208ca38a6726eda7a1b0586d95601aad86e5d"
30
30
  - name: gemfile
31
31
  value:
32
32
  - "gemfiles/rubocop_162.gemfile"
33
+ - name: configuration
34
+ value:
35
+ - "lint"
36
+ taskRef:
37
+ name: ruby-tracer-unittest-default-libraries-task
38
+ workspaces:
39
+ - name: task-pvc
40
+ workspace: ruby-tracer-ci-pipeline-pvc
41
+ - name: core
42
+ runAfter:
43
+ - clone
44
+ matrix:
45
+ params:
46
+ - name: imageDigest
47
+ value:
48
+ # 3.0.6-bullseye
49
+ - "sha256:3166618469ad8a3190d80f43b322818fafb4bfac0b4882255eee3346af2a0a35"
50
+ # 3.1.4-bookworm
51
+ - "sha256:ec69284bcbceb0a23ffc070ef2e0e8eb0fe495c20efbd51846b103338c3da1e4"
52
+ # 3.2.3-bookworm
53
+ - "sha256:007d2edd515f9cfc8c5c571486aca4fc4a25c903d004decee302961bb8c636ed"
54
+ # 3.3.1-bookworm
55
+ - "sha256:5cf0004738f54bd67e4c4316394208ca38a6726eda7a1b0586d95601aad86e5d"
56
+ - name: gemfile
57
+ value:
58
+ - "./Gemfile"
59
+ - name: configuration
60
+ value:
61
+ - "core"
33
62
  taskRef:
34
- name: ruby-tracer-lint-task
63
+ name: ruby-tracer-unittest-default-libraries-task
35
64
  workspaces:
36
65
  - name: task-pvc
37
66
  workspace: ruby-tracer-ci-pipeline-pvc
38
67
  - name: unittest-default-ruby-30
39
68
  runAfter:
40
69
  - lint
70
+ - core
41
71
  matrix:
42
72
  params:
43
73
  - name: imageDigest
@@ -65,6 +95,9 @@ spec:
65
95
  - "./gemfiles/sinatra_40.gemfile"
66
96
  - "./gemfiles/shoryuken_50.gemfile"
67
97
  - "./gemfiles/shoryuken_60.gemfile"
98
+ - name: configuration
99
+ value:
100
+ - "libraries"
68
101
  taskRef:
69
102
  name: ruby-tracer-unittest-default-libraries-task
70
103
  workspaces:
@@ -100,6 +133,9 @@ spec:
100
133
  - "./gemfiles/sinatra_40.gemfile"
101
134
  - "./gemfiles/shoryuken_50.gemfile"
102
135
  - "./gemfiles/shoryuken_60.gemfile"
136
+ - name: configuration
137
+ value:
138
+ - "libraries"
103
139
  taskRef:
104
140
  name: ruby-tracer-unittest-default-libraries-task
105
141
  workspaces:
@@ -135,6 +171,9 @@ spec:
135
171
  - "./gemfiles/sinatra_40.gemfile"
136
172
  - "./gemfiles/shoryuken_50.gemfile"
137
173
  - "./gemfiles/shoryuken_60.gemfile"
174
+ - name: configuration
175
+ value:
176
+ - "libraries"
138
177
  taskRef:
139
178
  name: ruby-tracer-unittest-default-libraries-task
140
179
  workspaces:
@@ -147,8 +186,8 @@ spec:
147
186
  params:
148
187
  - name: imageDigest
149
188
  value:
150
- # 3.3.0-bookworm
151
- - "sha256:67ccb9c63d2a2ae9fcc7df5448800b740e140691ac74534f9fc687dbf5ce0da2"
189
+ # 3.3.1-bookworm
190
+ - "sha256:5cf0004738f54bd67e4c4316394208ca38a6726eda7a1b0586d95601aad86e5d"
152
191
  - name: gemfile
153
192
  value:
154
193
  - "./gemfiles/cuba_30.gemfile"
@@ -170,6 +209,9 @@ spec:
170
209
  - "./gemfiles/sinatra_40.gemfile"
171
210
  - "./gemfiles/shoryuken_50.gemfile"
172
211
  - "./gemfiles/shoryuken_60.gemfile"
212
+ - name: configuration
213
+ value:
214
+ - "libraries"
173
215
  taskRef:
174
216
  name: ruby-tracer-unittest-default-libraries-task
175
217
  workspaces:
@@ -188,8 +230,8 @@ spec:
188
230
  - "sha256:ec69284bcbceb0a23ffc070ef2e0e8eb0fe495c20efbd51846b103338c3da1e4"
189
231
  # 3.2.3-bookworm
190
232
  - "sha256:007d2edd515f9cfc8c5c571486aca4fc4a25c903d004decee302961bb8c636ed"
191
- # 3.3.0-bookworm
192
- - "sha256:67ccb9c63d2a2ae9fcc7df5448800b740e140691ac74534f9fc687dbf5ce0da2"
233
+ # 3.3.1-bookworm
234
+ - "sha256:5cf0004738f54bd67e4c4316394208ca38a6726eda7a1b0586d95601aad86e5d"
193
235
  - name: gemfile
194
236
  value:
195
237
  - "./gemfiles/mongo_216.gemfile"
@@ -212,8 +254,8 @@ spec:
212
254
  - "sha256:ec69284bcbceb0a23ffc070ef2e0e8eb0fe495c20efbd51846b103338c3da1e4"
213
255
  # 3.2.3-bookworm
214
256
  - "sha256:007d2edd515f9cfc8c5c571486aca4fc4a25c903d004decee302961bb8c636ed"
215
- # 3.3.0-bookworm
216
- - "sha256:67ccb9c63d2a2ae9fcc7df5448800b740e140691ac74534f9fc687dbf5ce0da2"
257
+ # 3.3.1-bookworm
258
+ - "sha256:5cf0004738f54bd67e4c4316394208ca38a6726eda7a1b0586d95601aad86e5d"
217
259
  - name: gemfile
218
260
  value:
219
261
  - "./gemfiles/dalli_20.gemfile"
@@ -237,8 +279,8 @@ spec:
237
279
  - "sha256:ec69284bcbceb0a23ffc070ef2e0e8eb0fe495c20efbd51846b103338c3da1e4"
238
280
  # 3.2.3-bookworm
239
281
  - "sha256:007d2edd515f9cfc8c5c571486aca4fc4a25c903d004decee302961bb8c636ed"
240
- # 3.3.0-bookworm
241
- - "sha256:67ccb9c63d2a2ae9fcc7df5448800b740e140691ac74534f9fc687dbf5ce0da2"
282
+ # 3.3.1-bookworm
283
+ - "sha256:5cf0004738f54bd67e4c4316394208ca38a6726eda7a1b0586d95601aad86e5d"
242
284
  - name: gemfile
243
285
  value:
244
286
  - "./gemfiles/aws_30.gemfile"
@@ -285,8 +327,8 @@ spec:
285
327
  value:
286
328
  # 3.2.3-bookworm
287
329
  - "sha256:007d2edd515f9cfc8c5c571486aca4fc4a25c903d004decee302961bb8c636ed"
288
- # 3.3.0-bookworm
289
- - "sha256:67ccb9c63d2a2ae9fcc7df5448800b740e140691ac74534f9fc687dbf5ce0da2"
330
+ # 3.3.1-bookworm
331
+ - "sha256:5cf0004738f54bd67e4c4316394208ca38a6726eda7a1b0586d95601aad86e5d"
290
332
  - name: gemfile
291
333
  value:
292
334
  - "./gemfiles/redis_40.gemfile"
@@ -317,8 +359,8 @@ spec:
317
359
  - "sha256:ec69284bcbceb0a23ffc070ef2e0e8eb0fe495c20efbd51846b103338c3da1e4"
318
360
  # 3.2.3-bookworm
319
361
  - "sha256:007d2edd515f9cfc8c5c571486aca4fc4a25c903d004decee302961bb8c636ed"
320
- # 3.3.0-bookworm
321
- - "sha256:67ccb9c63d2a2ae9fcc7df5448800b740e140691ac74534f9fc687dbf5ce0da2"
362
+ # 3.3.1-bookworm
363
+ - "sha256:5cf0004738f54bd67e4c4316394208ca38a6726eda7a1b0586d95601aad86e5d"
322
364
  - name: gemfile
323
365
  value:
324
366
  - "./gemfiles/rails_61.gemfile"
@@ -342,8 +384,8 @@ spec:
342
384
  - "sha256:ec69284bcbceb0a23ffc070ef2e0e8eb0fe495c20efbd51846b103338c3da1e4"
343
385
  # 3.2.3-bookworm
344
386
  - "sha256:007d2edd515f9cfc8c5c571486aca4fc4a25c903d004decee302961bb8c636ed"
345
- # 3.3.0-bookworm
346
- - "sha256:67ccb9c63d2a2ae9fcc7df5448800b740e140691ac74534f9fc687dbf5ce0da2"
387
+ # 3.3.1-bookworm
388
+ - "sha256:5cf0004738f54bd67e4c4316394208ca38a6726eda7a1b0586d95601aad86e5d"
347
389
  - name: gemfile
348
390
  value:
349
391
  - "./gemfiles/rails_61.gemfile"
@@ -367,8 +409,8 @@ spec:
367
409
  - "sha256:ec69284bcbceb0a23ffc070ef2e0e8eb0fe495c20efbd51846b103338c3da1e4"
368
410
  # 3.2.3-bookworm
369
411
  - "sha256:007d2edd515f9cfc8c5c571486aca4fc4a25c903d004decee302961bb8c636ed"
370
- # 3.3.0-bookworm
371
- - "sha256:67ccb9c63d2a2ae9fcc7df5448800b740e140691ac74534f9fc687dbf5ce0da2"
412
+ # 3.3.1-bookworm
413
+ - "sha256:5cf0004738f54bd67e4c4316394208ca38a6726eda7a1b0586d95601aad86e5d"
372
414
  - name: gemfile
373
415
  value:
374
416
  - "./gemfiles/rails_61.gemfile"
@@ -3,6 +3,8 @@ kind: PipelineRun
3
3
  metadata:
4
4
  name: ruby-tracer-ci-pipeline-run
5
5
  spec:
6
+ timeouts:
7
+ pipeline: "2h"
6
8
  params:
7
9
  - name: revision
8
10
  value: "tekton"
@@ -0,0 +1,83 @@
1
+ apiVersion: apps/v1
2
+ kind: DaemonSet
3
+ metadata:
4
+ name: ruby-tracer-prepuller
5
+ spec:
6
+ selector:
7
+ matchLabels:
8
+ name: ruby-tracer-prepuller
9
+ template:
10
+ metadata:
11
+ labels:
12
+ name: ruby-tracer-prepuller
13
+ spec:
14
+ # Configure an init container for each image you want to pull
15
+ initContainers:
16
+ - name: prepuller-git
17
+ # alpine/git:2.43.0
18
+ image: alpine/git@sha256:6ff4de047dcc8f0c7d75d2efff63fbc189e87d2f458305f2cc8f165ff83309cf
19
+ command: ["sh", "-c", "'true'"]
20
+ - name: prepuller-dynamodb
21
+ # amazon/dynamodb-local:2.3.0
22
+ image: amazon/dynamodb-local@sha256:0e42a967205042118277be031a59f7aa035c2f90b1695b1b3250d0ce03a7c8f0
23
+ command: ["sh", "-c", "'true'"]
24
+ - name: prepuller-s3
25
+ # minio/minio:RELEASE.2024-03-07T00-43-48Z
26
+ image: minio/minio@sha256:9224601c529f424e5efac79f95606f0c7e1fe234f3f45344a49deaccd66d5bf5
27
+ command: ["sh", "-c", "'true'"]
28
+ - name: prepuller-sns
29
+ # s12v/sns:latest
30
+ image: s12v/sns@sha256:a80f1cd6318d22419cab38650ee6824f72cc2dc902d2b38e4f997d0530fe4e07
31
+ command: ["sh", "-c", "'true'"]
32
+ - name: prepuller-sqs
33
+ # softwaremill/elasticmq-native:1.5.7
34
+ image: softwaremill/elasticmq-native@sha256:9183333a9ea4666686c37dc83a2b1f8cee9c15ffd161a219a131e171039f1ac3
35
+ command: ["sh", "-c", "'true'"]
36
+ - name: prepuller-memcached
37
+ # memcached:1.6.24-bookworm
38
+ image: memcached@sha256:b2b562323463b6cda240a148fb2a5b7ea86e8017a8509e10a3c7f1681f259193
39
+ command: ["sh", "-c", "'true'"]
40
+ - name: prepuller-redis
41
+ # redis:7.2.4-bookworm
42
+ image: redis@sha256:fe98b2d39d462d06a7360e2860dd6ceff930745e3731eccb3c1406dd0dd7f744
43
+ command: ["sh", "-c", "'true'"]
44
+ - name: prepuller-mongo
45
+ # mongo:5.0.25-focal
46
+ image: mongo@sha256:d1b8a7b77424347397653ab8ff500c66b1e9979b4cebf826951d37b0d3966721
47
+ command: ["sh", "-c", "'true'"]
48
+ - name: prepuller-mariadb
49
+ # mariadb:11.3.2
50
+ image: mariadb@sha256:851f05fe1e4cb290442c1b12b7108436a33fd8f6a733d4989950322d06d45c65
51
+ command: ["sh", "-c", "'true'"]
52
+ - name: prepuller-postgres
53
+ # postgres:16.2-bookworm
54
+ image: postgres@sha256:6b841c8f6a819884207402f1209a8116844365df15fca8cf556fc54a24c70800
55
+ command: ["sh", "-c", "'true'"]
56
+ - name: prepuller-30
57
+ # 3.0.6-bullseye
58
+ image: ruby@sha256:3166618469ad8a3190d80f43b322818fafb4bfac0b4882255eee3346af2a0a35
59
+ command: ["sh", "-c", "'true'"]
60
+ - name: prepuller-31
61
+ # 3.1.4-bookworm
62
+ image: ruby@sha256:ec69284bcbceb0a23ffc070ef2e0e8eb0fe495c20efbd51846b103338c3da1e4
63
+ command: ["sh", "-c", "'true'"]
64
+ - name: prepuller-32
65
+ # 3.2.3-bookworm
66
+ image: ruby@sha256:007d2edd515f9cfc8c5c571486aca4fc4a25c903d004decee302961bb8c636ed
67
+ command: ["sh", "-c", "'true'"]
68
+ - name: prepuller-33
69
+ # 3.3.1-bookworm
70
+ image: ruby@sha256:5cf0004738f54bd67e4c4316394208ca38a6726eda7a1b0586d95601aad86e5d
71
+ command: ["sh", "-c", "'true'"]
72
+ # Use the pause container to ensure the Pod goes into a `Running` phase
73
+ # but doesn't take up resource on the cluster
74
+ containers:
75
+ - name: pause
76
+ image: gcr.io/google_containers/pause:3.2
77
+ resources:
78
+ limits:
79
+ cpu: 1m
80
+ memory: 8Mi
81
+ requests:
82
+ cpu: 1m
83
+ memory: 8Mi
@@ -19,6 +19,8 @@ spec:
19
19
  # '[a-z0-9]([-a-z0-9]*[a-z0-9])?(\\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*'
20
20
  name: ruby-tracer-scheduled-ci-pipeline-$(tt.params.date-time-normalized)-$(tt.params.git-commit-short-sha)
21
21
  spec:
22
+ timeouts:
23
+ pipeline: "2h"
22
24
  params:
23
25
  - name: revision
24
26
  value: master
data/.tekton/task.yaml CHANGED
@@ -273,30 +273,7 @@ spec:
273
273
  params:
274
274
  - name: imageDigest
275
275
  type: string
276
- - name: gemfile
277
- type: string
278
- workspaces:
279
- - name: task-pvc
280
- mountPath: /workspace
281
- steps:
282
- - name: unittest
283
- image: ruby@$(params.imageDigest)
284
- env:
285
- - name: TEST_CONFIGURATION
286
- value: libraries
287
- - name: BUNDLE_GEMFILE
288
- value: $(params.gemfile)
289
- workingDir: /workspace/ruby-sensor/
290
- command:
291
- - /workspace/ruby-sensor/.tekton/run_unittests.sh
292
- ---
293
- apiVersion: tekton.dev/v1
294
- kind: Task
295
- metadata:
296
- name: ruby-tracer-lint-task
297
- spec:
298
- params:
299
- - name: imageDigest
276
+ - name: configuration
300
277
  type: string
301
278
  - name: gemfile
302
279
  type: string
@@ -304,11 +281,11 @@ spec:
304
281
  - name: task-pvc
305
282
  mountPath: /workspace
306
283
  steps:
307
- - name: lint
284
+ - name: unittest
308
285
  image: ruby@$(params.imageDigest)
309
286
  env:
310
287
  - name: TEST_CONFIGURATION
311
- value: lint
288
+ value: $(params.configuration)
312
289
  - name: BUNDLE_GEMFILE
313
290
  value: $(params.gemfile)
314
291
  workingDir: /workspace/ruby-sensor/
@@ -8,6 +8,7 @@ source "https://rubygems.org"
8
8
  gem "rack"
9
9
  gem "rackup"
10
10
  gem "minitest-reporters"
11
+ gem "net-http"
11
12
  gem "webmock"
12
13
  gem "puma"
13
14
  gem "rack-test"
@@ -12,8 +12,11 @@ module Instana
12
12
  require 'instana/instrumentation/action_view'
13
13
 
14
14
  ::ActionView::PartialRenderer
15
- .prepend(Instana::Instrumentation::ActionView)
16
-
15
+ .prepend(Instana::Instrumentation::ActionView::PartialRenderer)
16
+ if defined?(::ActionView::CollectionRenderer)
17
+ ::ActionView::CollectionRenderer
18
+ .prepend(Instrumentation::ActionView::CollectionRenderer)
19
+ end
17
20
  true
18
21
  end
19
22
  end
@@ -27,6 +27,9 @@ module Instana
27
27
  # Enable/disable tracing (default: enabled)
28
28
  @config[:tracing] = { :enabled => true }
29
29
 
30
+ # Enable/disable tracing exit spans as root spans
31
+ @config[:allow_exit_as_root] = ENV['INSTANA_ALLOW_EXIT_AS_ROOT'] == '1'
32
+
30
33
  # Enable/Disable logging
31
34
  @config[:logging] = { :enabled => true }
32
35
 
@@ -4,26 +4,52 @@
4
4
  module Instana
5
5
  module Instrumentation
6
6
  module ActionView
7
- def render_partial(*args)
8
- call_payload = {
9
- render: {
10
- type: :partial,
11
- name: @options.is_a?(Hash) ? @options[:partial].to_s : 'Unknown'
7
+ module PartialRenderer
8
+ def render_partial(*args)
9
+ call_payload = {
10
+ render: {
11
+ type: :partial,
12
+ name: @options.is_a?(Hash) ? @options[:partial].to_s : 'Unknown'
13
+ }
12
14
  }
13
- }
14
15
 
15
- ::Instana::Tracer.trace(:render, call_payload) { super(*args) }
16
+ ::Instana::Tracer.trace(:render, call_payload) { super(*args) }
17
+ end
18
+
19
+ def render_collection(*args)
20
+ call_payload = {
21
+ render: {
22
+ type: :collection,
23
+ name: @path.to_s
24
+ }
25
+ }
26
+
27
+ ::Instana::Tracer.trace(:render, call_payload) { super(*args) }
28
+ end
29
+
30
+ def render_partial_template(*args)
31
+ call_payload = {
32
+ render: {
33
+ type: :partial,
34
+ name: @options.is_a?(Hash) ? @options[:partial].to_s : 'Unknown'
35
+ }
36
+ }
37
+
38
+ ::Instana::Tracer.trace(:render, call_payload) { super(*args) }
39
+ end
16
40
  end
17
41
 
18
- def render_collection(*args)
19
- call_payload = {
20
- render: {
21
- type: :collection,
22
- name: @path.to_s
42
+ module CollectionRenderer
43
+ def render_collection(*args)
44
+ call_payload = {
45
+ render: {
46
+ type: :collection,
47
+ name: @options.is_a?(Hash) ? @options[:partial].to_s : 'Unknown'
48
+ }
23
49
  }
24
- }
25
50
 
26
- ::Instana::Tracer.trace(:render, call_payload) { super(*args) }
51
+ ::Instana::Tracer.trace(:render, call_payload) { super(*args) }
52
+ end
27
53
  end
28
54
  end
29
55
  end
@@ -78,8 +78,10 @@ module Instana
78
78
  private
79
79
 
80
80
  def traceable?
81
- ::Instana.tracer.tracing? &&
82
- (!Instana.tracer.current_span.exit_span? || Instana.tracer.current_span.name == :excon)
81
+ ::Instana.tracer.tracing? && ::Instana.tracer.current_span.nil? ||
82
+ !::Instana.tracer.current_span.nil? &&
83
+ (!Instana.tracer.current_span.exit_span? ||
84
+ Instana.tracer.current_span.exit_span? && Instana.tracer.current_span.name == :excon)
83
85
  end
84
86
  end
85
87
  end
@@ -7,7 +7,7 @@ module Instana
7
7
  module Instrumentation
8
8
  module NetHTTPInstrumentation
9
9
  def request(*args, &block)
10
- if !Instana.tracer.tracing? || Instana.tracer.current_span.exit_span? || !started?
10
+ if skip_instrumentation?
11
11
  do_skip = true
12
12
  return super(*args, &block)
13
13
  end
@@ -64,6 +64,12 @@ module Instana
64
64
  ensure
65
65
  ::Instana.tracer.log_exit(:'net-http', kv_payload) unless do_skip
66
66
  end
67
+
68
+ def skip_instrumentation?
69
+ dnt_spans = [:dynamodb, :sqs, :sns, :s3]
70
+ !Instana.tracer.tracing? || !started? || !Instana.config[:nethttp][:enabled] ||
71
+ (!::Instana.tracer.current_span.nil? && dnt_spans.include?(::Instana.tracer.current_span.name))
72
+ end
67
73
  end
68
74
  end
69
75
  end
@@ -59,7 +59,7 @@ module Instana
59
59
 
60
60
  def skip_instrumentation?
61
61
  dnt_spans = [:redis, :'resque-client', :'sidekiq-client']
62
- !Instana.tracer.tracing? || dnt_spans.include?(::Instana.tracer.current_span.name) || !Instana.config[:redis][:enabled]
62
+ !Instana.tracer.tracing? || (!::Instana.tracer.current_span.nil? && dnt_spans.include?(::Instana.tracer.current_span.name)) || !Instana.config[:redis][:enabled]
63
63
  end
64
64
 
65
65
  def call_with_instana(command, original_super, args, kwargs, &block)
@@ -133,12 +133,12 @@ module Instana
133
133
  # @param kvs [Hash] list of key values to be reported in the span
134
134
  #
135
135
  def log_entry(name, kvs = nil, start_time = ::Instana::Util.now_in_ms, child_of = nil)
136
- return unless self.current_span || child_of
136
+ return unless tracing? || child_of
137
137
 
138
- new_span = if child_of.is_a?(::Instana::Span) || child_of.is_a?(::Instana::SpanContext)
139
- Span.new(name, parent_ctx: child_of, start_time: start_time)
140
- else
138
+ new_span = if child_of.nil? && !self.current_span.nil?
141
139
  Span.new(name, parent_ctx: self.current_span, start_time: start_time)
140
+ else
141
+ Span.new(name, parent_ctx: child_of, start_time: start_time)
142
142
  end
143
143
  new_span.set_tags(kvs) if kvs
144
144
  self.current_span = new_span
@@ -218,7 +218,7 @@ module Instana
218
218
  # :span_id => 12345
219
219
  #
220
220
  def log_async_entry(name, kvs)
221
- return unless self.current_span
221
+ return unless tracing?
222
222
 
223
223
  new_span = Span.new(name, parent_ctx: self.current_span)
224
224
  new_span.set_tags(kvs) unless kvs.empty?
@@ -268,7 +268,8 @@ module Instana
268
268
  # The non-nil value of this instance variable
269
269
  # indicates if we are currently tracing
270
270
  # in this thread or not.
271
- self.current_span ? true : false
271
+ (self.current_span ? true : false) ||
272
+ (::Instana.config[:allow_exit_as_root] && ::Instana.config[:tracing][:enabled])
272
273
  end
273
274
 
274
275
  # Indicates if we're tracing and the current span name matches
@@ -2,6 +2,6 @@
2
2
  # (c) Copyright Instana Inc. 2016
3
3
 
4
4
  module Instana
5
- VERSION = "1.214.3"
5
+ VERSION = "1.215.0"
6
6
  VERSION_FULL = "instana-#{VERSION}"
7
7
  end
@@ -6,15 +6,27 @@ require 'test_helper'
6
6
  class HostAgentTest < Minitest::Test
7
7
  def test_spawn_background_thread
8
8
  ENV['INSTANA_TEST'] = nil
9
- ::Instana.config[:agent_host] = '10.10.10.10'
9
+ agent_host = '10.10.10.10'
10
+ ::Instana.config[:agent_host] = agent_host
10
11
 
11
- if File.exist?('/sbin/ip')
12
- addr = `/sbin/ip route | awk '/default/ { print $3 }'`.strip
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('.')
13
25
  stub_request(:get, "http://#{addr}:42699/")
14
26
  .to_timeout
15
27
  end
16
28
 
17
- stub_request(:get, "http://10.10.10.10:42699/")
29
+ stub_request(:get, "http://#{agent_host}:42699/")
18
30
  .to_timeout.times(3).then
19
31
  .to_return(status: 200, body: "", headers: {})
20
32
 
@@ -9,6 +9,10 @@ class DalliTest < Minitest::Test
9
9
  @dc = Dalli::Client.new(@memcached_host, :namespace => "instana_test")
10
10
  end
11
11
 
12
+ def teardown
13
+ ::Instana.config[:allow_exit_as_root] = false
14
+ end
15
+
12
16
  def test_config_defaults
13
17
  assert ::Instana.config[:dalli].is_a?(Hash)
14
18
  assert ::Instana.config[:dalli].key?(:enabled)
@@ -50,6 +54,35 @@ class DalliTest < Minitest::Test
50
54
  assert_equal @memcached_host, second_span[:data][:memcache][:server]
51
55
  end
52
56
 
57
+ def test_basic_get_as_root_exit_span
58
+ clear_all!
59
+ @dc.set(:instana, :boom)
60
+
61
+ ::Instana.config[:allow_exit_as_root] = true
62
+ result = @dc.get(:instana)
63
+
64
+ assert_equal :boom, result
65
+
66
+ spans = ::Instana.processor.queued_spans
67
+ assert_equal 1, spans.length
68
+
69
+ first_span = spans[0]
70
+
71
+ assert_equal :memcache, first_span[:n]
72
+ assert_equal false, first_span.key?(:error)
73
+ assert_nil first_span[:p]
74
+ assert first_span[:t] == first_span[:s]
75
+ assert first_span[:data].key?(:memcache)
76
+ assert first_span[:data][:memcache].key?(:command)
77
+ assert_equal :get, first_span[:data][:memcache][:command]
78
+ assert first_span[:data][:memcache].key?(:key)
79
+ assert_equal :instana, first_span[:data][:memcache][:key]
80
+ assert first_span[:data][:memcache].key?(:namespace)
81
+ assert_equal 'instana_test', first_span[:data][:memcache][:namespace]
82
+ assert first_span[:data][:memcache].key?(:server)
83
+ assert_equal @memcached_host, first_span[:data][:memcache][:server]
84
+ end
85
+
53
86
  def test_basic_set
54
87
  clear_all!
55
88
 
@@ -5,6 +5,10 @@ require 'test_helper'
5
5
  require 'support/apps/http_endpoint/boot'
6
6
 
7
7
  class ExconTest < Minitest::Test
8
+ def teardown
9
+ ::Instana.config[:allow_exit_as_root] = false
10
+ end
11
+
8
12
  def test_config_defaults
9
13
  assert ::Instana.config[:excon].is_a?(Hash)
10
14
  assert ::Instana.config[:excon].key?(:enabled)
@@ -52,6 +56,42 @@ class ExconTest < Minitest::Test
52
56
  assert_equal excon_span[:p], sdk_span[:s]
53
57
  end
54
58
 
59
+ def test_basic_get_as_root_exit_span
60
+ clear_all!
61
+
62
+ # A slight hack but webmock chokes with pipelined requests.
63
+ # Delete their excon middleware
64
+ Excon.defaults[:middlewares].delete ::WebMock::HttpLibAdapters::ExconAdapter
65
+ Excon.defaults[:middlewares].delete ::Excon::Middleware::Mock
66
+
67
+ url = "http://127.0.0.1:6511"
68
+
69
+ ::Instana.config[:allow_exit_as_root] = true
70
+ connection = Excon.new(url)
71
+ connection.get(:path => '/?basic_get')
72
+
73
+ spans = ::Instana.processor.queued_spans
74
+ assert_equal 2, spans.length
75
+
76
+ excon_span = find_first_span_by_name(spans, :excon)
77
+ rack_span = find_first_span_by_name(spans, :rack)
78
+
79
+ # data keys/values
80
+ refute_nil excon_span.key?(:data)
81
+ refute_nil excon_span[:data].key?(:http)
82
+ assert_equal "http://127.0.0.1:6511/", excon_span[:data][:http][:url]
83
+ assert_equal 200, excon_span[:data][:http][:status]
84
+ assert_equal 'basic_get', excon_span[:data][:http][:params]
85
+
86
+ # excon backtrace not included by default check
87
+ assert !excon_span.key?(:stack)
88
+
89
+ assert_equal rack_span[:t], excon_span[:t]
90
+
91
+ assert_equal rack_span[:p], excon_span[:s]
92
+ assert_nil excon_span[:p]
93
+ end
94
+
55
95
  def test_basic_get_with_error
56
96
  clear_all!
57
97