instana 1.193.4 → 1.195.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (176) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +20 -2
  3. data/.rubocop.yml +7 -0
  4. data/Appraisals +20 -1
  5. data/Gemfile +3 -0
  6. data/LICENSE +2 -1
  7. data/Rakefile +3 -0
  8. data/benchmarks/10k-rack-traces.rb +3 -0
  9. data/benchmarks/Gemfile +4 -0
  10. data/benchmarks/id_generation.rb +4 -0
  11. data/benchmarks/opentracing.rb +4 -0
  12. data/benchmarks/rack_vanilla_vs_traced.rb +3 -0
  13. data/benchmarks/stackprof_rack_tracing.rb +3 -0
  14. data/benchmarks/time_processing.rb +4 -0
  15. data/bin/console +3 -0
  16. data/docker-compose.yml +20 -0
  17. data/examples/opentracing.rb +4 -0
  18. data/examples/tracing.rb +4 -0
  19. data/extras/license_header.rb +44 -0
  20. data/gemfiles/aws_30.gemfile +21 -0
  21. data/gemfiles/cuba_30.gemfile +3 -0
  22. data/gemfiles/dalli_20.gemfile +3 -0
  23. data/gemfiles/excon_02.gemfile +3 -0
  24. data/gemfiles/excon_021.gemfile +18 -0
  25. data/gemfiles/excon_079.gemfile +18 -0
  26. data/gemfiles/graphql_10.gemfile +3 -0
  27. data/gemfiles/grpc_10.gemfile +3 -0
  28. data/gemfiles/net_http_01.gemfile +3 -0
  29. data/gemfiles/rack_16.gemfile +3 -0
  30. data/gemfiles/rack_20.gemfile +3 -0
  31. data/gemfiles/rails_42.gemfile +3 -0
  32. data/gemfiles/rails_50.gemfile +3 -0
  33. data/gemfiles/rails_52.gemfile +3 -0
  34. data/gemfiles/rails_60.gemfile +3 -0
  35. data/gemfiles/redis_40.gemfile +3 -0
  36. data/gemfiles/resque_122.gemfile +3 -0
  37. data/gemfiles/resque_20.gemfile +3 -0
  38. data/gemfiles/rest_client_16.gemfile +3 -0
  39. data/gemfiles/rest_client_20.gemfile +3 -0
  40. data/gemfiles/roda_20.gemfile +3 -0
  41. data/gemfiles/roda_30.gemfile +3 -0
  42. data/gemfiles/shoryuken_50.gemfile +19 -0
  43. data/gemfiles/sidekiq_42.gemfile +3 -0
  44. data/gemfiles/sidekiq_50.gemfile +3 -0
  45. data/gemfiles/sinatra_14.gemfile +3 -0
  46. data/instana.gemspec +4 -0
  47. data/lib/instana.rb +3 -0
  48. data/lib/instana/activator.rb +3 -0
  49. data/lib/instana/activators/action_cable.rb +24 -0
  50. data/lib/instana/activators/action_controller_api.rb +3 -0
  51. data/lib/instana/activators/action_controller_base.rb +3 -0
  52. data/lib/instana/activators/action_view.rb +3 -0
  53. data/lib/instana/activators/active_record.rb +3 -0
  54. data/lib/instana/activators/aws_sdk_dynamodb.rb +20 -0
  55. data/lib/instana/activators/aws_sdk_s3.rb +20 -0
  56. data/lib/instana/activators/aws_sdk_sns.rb +20 -0
  57. data/lib/instana/activators/aws_sdk_sqs.rb +20 -0
  58. data/lib/instana/activators/cuba.rb +3 -0
  59. data/lib/instana/activators/dalli.rb +3 -0
  60. data/lib/instana/activators/excon.rb +4 -1
  61. data/lib/instana/activators/graphql.rb +3 -0
  62. data/lib/instana/activators/grpc_client.rb +3 -0
  63. data/lib/instana/activators/grpc_server.rb +3 -0
  64. data/lib/instana/activators/net_http.rb +3 -0
  65. data/lib/instana/activators/rack.rb +3 -0
  66. data/lib/instana/activators/rails.rb +3 -0
  67. data/lib/instana/activators/redis.rb +3 -0
  68. data/lib/instana/activators/resque_client.rb +3 -0
  69. data/lib/instana/activators/resque_worker.rb +3 -0
  70. data/lib/instana/activators/rest_client.rb +3 -0
  71. data/lib/instana/activators/roda.rb +3 -0
  72. data/lib/instana/activators/shoryuken.rb +24 -0
  73. data/lib/instana/activators/sidekiq_client.rb +3 -0
  74. data/lib/instana/activators/sidekiq_worker.rb +3 -0
  75. data/lib/instana/activators/sinatra.rb +3 -0
  76. data/lib/instana/agent.rb +3 -0
  77. data/lib/instana/agent/helpers.rb +3 -0
  78. data/lib/instana/agent/hooks.rb +3 -0
  79. data/lib/instana/agent/tasks.rb +3 -0
  80. data/lib/instana/base.rb +3 -0
  81. data/lib/instana/collector.rb +3 -0
  82. data/lib/instana/collectors/gc.rb +3 -0
  83. data/lib/instana/collectors/memory.rb +3 -0
  84. data/lib/instana/collectors/thread.rb +3 -0
  85. data/lib/instana/config.rb +6 -0
  86. data/lib/instana/frameworks/cuba.rb +3 -0
  87. data/lib/instana/frameworks/rails.rb +3 -0
  88. data/lib/instana/frameworks/roda.rb +3 -0
  89. data/lib/instana/frameworks/sinatra.rb +3 -0
  90. data/lib/instana/helpers.rb +3 -0
  91. data/lib/instana/instrumentation/action_cable.rb +53 -0
  92. data/lib/instana/instrumentation/action_controller.rb +3 -0
  93. data/lib/instana/instrumentation/action_view.rb +3 -0
  94. data/lib/instana/instrumentation/active_record.rb +3 -0
  95. data/lib/instana/instrumentation/aws_sdk_dynamodb.rb +48 -0
  96. data/lib/instana/instrumentation/aws_sdk_s3.rb +55 -0
  97. data/lib/instana/instrumentation/aws_sdk_sns.rb +29 -0
  98. data/lib/instana/instrumentation/aws_sdk_sqs.rb +98 -0
  99. data/lib/instana/instrumentation/dalli.rb +3 -0
  100. data/lib/instana/instrumentation/excon.rb +13 -4
  101. data/lib/instana/instrumentation/graphql.rb +3 -0
  102. data/lib/instana/instrumentation/grpc.rb +3 -0
  103. data/lib/instana/instrumentation/instrumented_request.rb +68 -7
  104. data/lib/instana/instrumentation/net-http.rb +13 -3
  105. data/lib/instana/instrumentation/rack.rb +38 -15
  106. data/lib/instana/instrumentation/redis.rb +3 -0
  107. data/lib/instana/instrumentation/resque.rb +3 -0
  108. data/lib/instana/instrumentation/rest-client.rb +3 -0
  109. data/lib/instana/instrumentation/shoryuken.rb +44 -0
  110. data/lib/instana/instrumentation/sidekiq-client.rb +4 -1
  111. data/lib/instana/instrumentation/sidekiq-worker.rb +4 -1
  112. data/lib/instana/opentracing/carrier.rb +3 -0
  113. data/lib/instana/opentracing/tracer.rb +3 -0
  114. data/lib/instana/rack.rb +4 -0
  115. data/lib/instana/secrets.rb +5 -2
  116. data/lib/instana/setup.rb +3 -0
  117. data/lib/instana/thread_local.rb +3 -0
  118. data/lib/instana/tracer.rb +17 -11
  119. data/lib/instana/tracing/processor.rb +3 -0
  120. data/lib/instana/tracing/span.rb +12 -3
  121. data/lib/instana/tracing/span_context.rb +28 -1
  122. data/lib/instana/util.rb +3 -0
  123. data/lib/instana/version.rb +4 -1
  124. data/lib/oj_check.rb +3 -0
  125. data/lib/opentracing.rb +3 -0
  126. data/test/activator_test.rb +3 -0
  127. data/test/agent/agent_test.rb +3 -0
  128. data/test/benchmarks/bench_id_generation.rb +3 -0
  129. data/test/benchmarks/bench_opentracing.rb +3 -0
  130. data/test/config_test.rb +3 -0
  131. data/test/frameworks/cuba_test.rb +3 -0
  132. data/test/frameworks/roda_test.rb +4 -0
  133. data/test/frameworks/sinatra_test.rb +3 -0
  134. data/test/instana_test.rb +3 -0
  135. data/test/instrumentation/aws_test.rb +161 -0
  136. data/test/instrumentation/dalli_test.rb +3 -0
  137. data/test/instrumentation/excon_test.rb +4 -0
  138. data/test/instrumentation/graphql_test.rb +3 -0
  139. data/test/instrumentation/grpc_test.rb +3 -0
  140. data/test/instrumentation/net_http_test.rb +21 -0
  141. data/test/instrumentation/rack_instrumented_request_test.rb +53 -3
  142. data/test/instrumentation/rack_test.rb +144 -0
  143. data/test/instrumentation/rails_action_cable_test.rb +131 -0
  144. data/test/instrumentation/rails_action_controller_test.rb +3 -0
  145. data/test/instrumentation/rails_action_view_test.rb +3 -0
  146. data/test/instrumentation/rails_active_record_test.rb +3 -2
  147. data/test/instrumentation/redis_test.rb +3 -0
  148. data/test/instrumentation/resque_test.rb +3 -0
  149. data/test/instrumentation/rest_client_test.rb +3 -0
  150. data/test/instrumentation/shoryuken_test.rb +47 -0
  151. data/test/instrumentation/sidekiq-client_test.rb +3 -0
  152. data/test/instrumentation/sidekiq-worker_test.rb +3 -0
  153. data/test/secrets_test.rb +3 -0
  154. data/test/support/apps/active_record/active_record.rb +3 -0
  155. data/test/support/apps/grpc/boot.rb +3 -0
  156. data/test/support/apps/grpc/grpc_server.rb +3 -0
  157. data/test/support/apps/http_endpoint/boot.rb +3 -0
  158. data/test/support/apps/rails/boot.rb +3 -0
  159. data/test/support/apps/rails/models/block.rb +3 -0
  160. data/test/support/apps/rails/models/block6.rb +3 -0
  161. data/test/support/apps/resque/boot.rb +3 -0
  162. data/test/support/apps/resque/jobs/resque_error_job.rb +3 -0
  163. data/test/support/apps/resque/jobs/resque_fast_job.rb +3 -0
  164. data/test/support/apps/sidekiq/boot.rb +4 -0
  165. data/test/support/apps/sidekiq/jobs/sidekiq_job_1.rb +3 -0
  166. data/test/support/apps/sidekiq/jobs/sidekiq_job_2.rb +3 -0
  167. data/test/support/apps/sidekiq/worker.rb +3 -0
  168. data/test/support/helpers.rb +3 -0
  169. data/test/test_helper.rb +3 -0
  170. data/test/tracing/custom_test.rb +3 -0
  171. data/test/tracing/id_management_test.rb +4 -0
  172. data/test/tracing/opentracing_test.rb +6 -3
  173. data/test/tracing/tracer_async_test.rb +3 -0
  174. data/test/tracing/tracer_test.rb +3 -0
  175. metadata +26 -3
  176. data/Dockerfile +0 -16
@@ -1,3 +1,6 @@
1
+ # (c) Copyright IBM Corp. 2021
2
+ # (c) Copyright Instana Inc. 2017
3
+
1
4
  module Instana
2
5
  module Instrumentation
3
6
  module Dalli
@@ -1,13 +1,17 @@
1
+ # (c) Copyright IBM Corp. 2021
2
+ # (c) Copyright Instana Inc. 2016
3
+
1
4
  module Instana
2
5
  module Instrumentation
3
6
  class Excon < ::Excon::Middleware::Base
4
7
  def request_call(datum)
5
- return @stack.request_call(datum) unless ::Instana.tracer.tracing?
8
+ return @stack.request_call(datum) unless ::Instana.tracer.tracing? || !Instana.tracer.current_span.exit_span?
6
9
 
7
10
  payload = { :http => {} }
8
- path = datum[:path].split('?').first
11
+ path, query = datum[:path].split('?', 2)
9
12
  payload[:http][:url] = ::Instana.secrets.remove_from_query("#{datum[:connection].instance_variable_get(:@socket_key)}#{path}")
10
13
  payload[:http][:method] = datum[:method] if datum.key?(:method)
14
+ payload[:http][:params] = ::Instana.secrets.remove_from_query(query || '')
11
15
 
12
16
  if datum[:pipeline] == true
13
17
  # Pass the context along in the datum so we get back on response
@@ -23,11 +27,16 @@ module Instana
23
27
  datum[:headers]['X-Instana-T'] = t_context.trace_id_header
24
28
  datum[:headers]['X-Instana-S'] = t_context.span_id_header
25
29
 
30
+ if ::Instana.config[:w3_trace_correlation]
31
+ datum[:headers]['Traceparent'] = t_context.trace_parent_header
32
+ datum[:headers]['Tracestate'] = t_context.trace_state_header
33
+ end
34
+
26
35
  @stack.request_call(datum)
27
36
  end
28
37
 
29
38
  def error_call(datum)
30
- return @stack.error_call(datum) unless ::Instana.tracer.tracing?
39
+ return @stack.error_call(datum) unless ::Instana.tracer.tracing? || !Instana.tracer.current_span.exit_span?
31
40
 
32
41
  if datum[:pipeline] == true
33
42
  ::Instana.tracer.log_async_error(datum[:error], datum[:instana_span])
@@ -40,7 +49,7 @@ module Instana
40
49
  def response_call(datum)
41
50
  # FIXME: Will connect exceptions call a response?
42
51
  #
43
- return @stack.response_call(datum) unless ::Instana.tracer.tracing?
52
+ return @stack.response_call(datum) unless ::Instana.tracer.tracing? || !Instana.tracer.current_span.exit_span?
44
53
 
45
54
  result = @stack.response_call(datum)
46
55
 
@@ -1,3 +1,6 @@
1
+ # (c) Copyright IBM Corp. 2021
2
+ # (c) Copyright Instana Inc. 2021
3
+
1
4
  module Instana
2
5
  module Instrumentation
3
6
  class GraphqlTracing < GraphQL::Tracing::PlatformTracing
@@ -1,3 +1,6 @@
1
+ # (c) Copyright IBM Corp. 2021
2
+ # (c) Copyright Instana Inc. 2017
3
+
1
4
  call_types = [:request_response, :client_streamer, :server_streamer, :bidi_streamer]
2
5
 
3
6
  module Instana
@@ -1,23 +1,32 @@
1
1
  # Note: We really only need "cgi/util" here but Ruby 2.4.1 has an issue:
2
2
  # https://bugs.ruby-lang.org/issues/13539
3
+
4
+ # (c) Copyright IBM Corp. 2021
5
+ # (c) Copyright Instana Inc. 2021
6
+
3
7
  require 'cgi'
4
8
  require 'rack/request'
5
9
 
6
10
  module Instana
7
11
  class InstrumentedRequest < Rack::Request
12
+ W3_TRACE_PARENT_FORMAT = /00-(?<trace>[0-9a-f]+)-(?<parent>[0-9a-f]+)-(?<flags>[0-9a-f]+)/.freeze
13
+ INSTANA_TRACE_STATE = /in=(?<trace>[0-9a-f]+);(?<span>[0-9a-f]+)/.freeze
14
+
8
15
  def skip_trace?
9
16
  # Honor X-Instana-L
10
17
  @env.has_key?('HTTP_X_INSTANA_L') && @env['HTTP_X_INSTANA_L'].start_with?('0')
11
18
  end
12
19
 
13
20
  def incoming_context
14
- context = {}
21
+ context = if @env['HTTP_X_INSTANA_T']
22
+ context_from_instana_headers
23
+ elsif @env['HTTP_TRACEPARENT'] && ::Instana.config[:w3_trace_correlation]
24
+ context_from_trace_parent
25
+ else
26
+ {}
27
+ end
15
28
 
16
- if @env['HTTP_X_INSTANA_T']
17
- context[:trace_id] = ::Instana::Util.header_to_id(@env['HTTP_X_INSTANA_T'])
18
- context[:span_id] = ::Instana::Util.header_to_id(@env['HTTP_X_INSTANA_S']) if @env['HTTP_X_INSTANA_S']
19
- context[:level] = @env['HTTP_X_INSTANA_L'][0] if @env['HTTP_X_INSTANA_L']
20
- end
29
+ context[:level] = @env['HTTP_X_INSTANA_L'][0] if @env['HTTP_X_INSTANA_L']
21
30
 
22
31
  context
23
32
  end
@@ -37,12 +46,17 @@ module Instana
37
46
  headers
38
47
  end
39
48
 
49
+ def request_params
50
+ ::Instana.secrets.remove_from_query(@env['QUERY_STRING'])
51
+ end
52
+
40
53
  def request_tags
41
54
  {
42
55
  method: request_method,
43
56
  url: CGI.unescape(path_info),
44
57
  host: host_with_port,
45
- header: extra_header_tags
58
+ header: extra_header_tags,
59
+ params: request_params
46
60
  }.compact
47
61
  end
48
62
 
@@ -50,8 +64,55 @@ module Instana
50
64
  @correlation_data ||= parse_correlation_data
51
65
  end
52
66
 
67
+ def instana_ancestor
68
+ @instana_ancestor ||= parse_trace_state
69
+ end
70
+
71
+ def continuing_from_trace_parent?
72
+ incoming_context.include?(:external_trace_id)
73
+ end
74
+
75
+ def synthetic?
76
+ @env.has_key?('HTTP_X_INSTANA_SYNTHETIC') && @env['HTTP_X_INSTANA_SYNTHETIC'].eql?('1')
77
+ end
78
+
53
79
  private
54
80
 
81
+ def context_from_instana_headers
82
+ {
83
+ trace_id: ::Instana::Util.header_to_id(@env['HTTP_X_INSTANA_T']),
84
+ span_id: ::Instana::Util.header_to_id(@env['HTTP_X_INSTANA_S'])
85
+ }.compact
86
+ end
87
+
88
+ def context_from_trace_parent
89
+ return {} unless @env.has_key?('HTTP_TRACEPARENT')
90
+ matches = @env['HTTP_TRACEPARENT'].match(W3_TRACE_PARENT_FORMAT)
91
+ return {} unless matches
92
+
93
+ {
94
+ external_trace_id: matches['trace'],
95
+ external_state: @env['HTTP_TRACESTATE'],
96
+ trace_id: ::Instana::Util.header_to_id(matches['trace'][16..-1]), # rubocop:disable Style/SlicingWithRange, Lint/RedundantCopDisableDirective
97
+ span_id: ::Instana::Util.header_to_id(matches['parent'])
98
+ }
99
+ end
100
+
101
+ def parse_trace_state
102
+ return {} unless @env.has_key?('HTTP_TRACESTATE')
103
+ token = @env['HTTP_TRACESTATE']
104
+ .split(/,/)
105
+ .map { |t| t.match(INSTANA_TRACE_STATE) }
106
+ .reject { |t| t.nil? }
107
+ .first
108
+ return {} unless token
109
+
110
+ {
111
+ t: token['trace'],
112
+ p: token['span']
113
+ }
114
+ end
115
+
55
116
  def parse_correlation_data
56
117
  return {} unless @env.has_key?('HTTP_X_INSTANA_L')
57
118
  _level, *tokens = @env['HTTP_X_INSTANA_L'].split(/[,=;]/)
@@ -1,10 +1,13 @@
1
+ # (c) Copyright IBM Corp. 2021
2
+ # (c) Copyright Instana Inc. 2016
3
+
1
4
  require 'net/http'
2
5
 
3
6
  module Instana
4
7
  module Instrumentation
5
8
  module NetHTTPInstrumentation
6
9
  def request(*args, &block)
7
- if !Instana.tracer.tracing? || !started?
10
+ if !Instana.tracer.tracing? || Instana.tracer.current_span.exit_span? || !started?
8
11
  do_skip = true
9
12
  return super(*args, &block)
10
13
  end
@@ -19,12 +22,19 @@ module Instana
19
22
  request['X-Instana-T'] = t_context.trace_id_header
20
23
  request['X-Instana-S'] = t_context.span_id_header
21
24
 
25
+ if ::Instana.config[:w3_trace_correlation]
26
+ request['Traceparent'] = t_context.trace_parent_header
27
+ request['Tracestate'] = t_context.trace_state_header
28
+ end
29
+
22
30
  # Collect up KV info now in case any exception is raised
23
31
  kv_payload = { :http => {} }
24
32
  kv_payload[:http][:method] = request.method
25
33
 
26
34
  if request.uri
27
- kv_payload[:http][:url] = request.uri.to_s
35
+ uri_without_query = request.uri.dup.tap { |r| r.query = nil }
36
+ kv_payload[:http][:url] = uri_without_query.to_s.gsub(/\?\z/, '')
37
+ kv_payload[:http][:params] = ::Instana.secrets.remove_from_query(request.uri.query)
28
38
  else
29
39
  if use_ssl?
30
40
  kv_payload[:http][:url] = "https://#{@address}:#{@port}#{request.path}"
@@ -33,7 +43,7 @@ module Instana
33
43
  end
34
44
  end
35
45
 
36
- kv_payload[:http][:url] = ::Instana.secrets.remove_from_query(kv_payload[:http][:url])
46
+ kv_payload[:http][:url] = ::Instana.secrets.remove_from_query(kv_payload[:http][:url]).gsub(/\?\z/, '')
37
47
 
38
48
  # The core call
39
49
  response = super(*args, &block)
@@ -1,3 +1,6 @@
1
+ # (c) Copyright IBM Corp. 2021
2
+ # (c) Copyright Instana Inc. 2016
3
+
1
4
  require 'rack'
2
5
  require 'instana/instrumentation/instrumented_request'
3
6
 
@@ -17,14 +20,26 @@ module Instana
17
20
 
18
21
  current_span = ::Instana.tracer.log_start_or_continue(:rack, {}, req.incoming_context)
19
22
 
20
- unless req.correlation_data.empty?
21
- current_span[:crid] = req.correlation_data[:id]
22
- current_span[:crtp] = req.correlation_data[:type]
23
- end
24
-
25
23
  status, headers, response = @app.call(env)
26
24
 
27
25
  if ::Instana.tracer.tracing?
26
+ unless req.correlation_data.empty?
27
+ current_span[:crid] = req.correlation_data[:id]
28
+ current_span[:crtp] = req.correlation_data[:type]
29
+ end
30
+
31
+ if !req.instana_ancestor.empty? && req.continuing_from_trace_parent?
32
+ current_span[:ia] = req.instana_ancestor
33
+ end
34
+
35
+ if req.continuing_from_trace_parent?
36
+ current_span[:tp] = true
37
+ current_span[:lt] = req.incoming_context[:external_trace_id]
38
+ end
39
+
40
+ if req.synthetic?
41
+ current_span[:sy] = true
42
+ end
28
43
  # In case some previous middleware returned a string status, make sure that we're dealing with
29
44
  # an integer. In Ruby nil.to_i, "asdfasdf".to_i will always return 0 from Ruby versions 1.8.7 and newer.
30
45
  # So if an 0 status is reported here, it indicates some other issue (e.g. no status from previous middleware)
@@ -42,23 +57,31 @@ module Instana
42
57
  # See: https://www.instana.com/docs/tracing/custom-best-practices/#path-templates-visual-grouping-of-http-endpoints
43
58
  kvs[:http][:path_tpl] = env['INSTANA_HTTP_PATH_TEMPLATE'] if env['INSTANA_HTTP_PATH_TEMPLATE']
44
59
 
45
- # Save the IDs before the trace ends so we can place
60
+ # Save the span context before the trace ends so we can place
46
61
  # them in the response headers in the ensure block
47
- trace_id = ::Instana.tracer.current_span.trace_id
48
- span_id = ::Instana.tracer.current_span.id
62
+ trace_context = ::Instana.tracer.current_span.context
49
63
  end
50
64
 
51
65
  [status, headers, response]
52
66
  rescue Exception => e
53
- ::Instana.tracer.log_error(e)
67
+ ::Instana.tracer.log_error(e) if ::Instana.tracer.tracing?
54
68
  raise
55
69
  ensure
56
- if headers && ::Instana.tracer.tracing?
57
- # Set reponse headers; encode as hex string
58
- headers['X-Instana-T'] = ::Instana::Util.id_to_header(trace_id)
59
- headers['X-Instana-S'] = ::Instana::Util.id_to_header(span_id)
60
- headers['X-Instana-L'] = '1'
61
- headers['Server-Timing'] = "intid;desc=#{::Instana::Util.id_to_header(trace_id)}"
70
+ if ::Instana.tracer.tracing?
71
+ if headers
72
+ # Set response headers; encode as hex string
73
+ headers['X-Instana-T'] = trace_context.trace_id_header
74
+ headers['X-Instana-S'] = trace_context.span_id_header
75
+ headers['X-Instana-L'] = '1'
76
+
77
+ if ::Instana.config[:w3_trace_correlation]
78
+ headers['Traceparent'] = trace_context.trace_parent_header
79
+ headers['Tracestate'] = trace_context.trace_state_header
80
+ end
81
+
82
+ headers['Server-Timing'] = "intid;desc=#{trace_context.trace_id_header}"
83
+ end
84
+
62
85
  ::Instana.tracer.log_end(:rack, kvs)
63
86
  end
64
87
  end
@@ -1,3 +1,6 @@
1
+ # (c) Copyright IBM Corp. 2021
2
+ # (c) Copyright Instana Inc. 2017
3
+
1
4
  module Instana
2
5
  module RedisInstrumentation
3
6
  def call(*args, &block)
@@ -1,3 +1,6 @@
1
+ # (c) Copyright IBM Corp. 2021
2
+ # (c) Copyright Instana Inc. 2018
3
+
1
4
  require 'socket'
2
5
 
3
6
  module Instana
@@ -1,3 +1,6 @@
1
+ # (c) Copyright IBM Corp. 2021
2
+ # (c) Copyright Instana Inc. 2016
3
+
1
4
  module Instana
2
5
  module Instrumentation
3
6
  module RestClientRequest
@@ -0,0 +1,44 @@
1
+ # (c) Copyright IBM Corp. 2021
2
+ # (c) Copyright Instana Inc. 2021
3
+
4
+ module Instana
5
+ module Instrumentation
6
+ class Shoryuken
7
+ def call(_worker_instance, _queue, sqs_message, _body, &block)
8
+ if sqs_message.is_a? Array
9
+ return yield
10
+ end
11
+
12
+ sqs_tags = {
13
+ sort: 'entry',
14
+ queue: sqs_message.queue_url
15
+ }
16
+
17
+ context = incomming_context_from(sqs_message.message_attributes)
18
+ ::Instana.tracer.start_or_continue_trace(:sqs, {sqs: sqs_tags}, context, &block)
19
+ end
20
+
21
+ private
22
+
23
+ def incomming_context_from(attributes)
24
+ trace_id = try(attributes, 'X_INSTANA_T', 'X_INSTANA_ST')
25
+ span_id = try(attributes, 'X_INSTANA_S', 'X_INSTANA_SS')
26
+ level = try(attributes, 'X_INSTANA_L', 'X_INSTANA_SL')
27
+
28
+ {
29
+ trace_id: trace_id,
30
+ span_id: span_id,
31
+ level: level
32
+ }.compact
33
+ end
34
+
35
+ def try(attributes, *args)
36
+ key = args.detect do |a|
37
+ attributes && attributes[a] && attributes[a].respond_to?(:string_value)
38
+ end
39
+
40
+ attributes[key].string_value if attributes && key
41
+ end
42
+ end
43
+ end
44
+ end
@@ -1,10 +1,13 @@
1
+ # (c) Copyright IBM Corp. 2021
2
+ # (c) Copyright Instana Inc. 2017
3
+
1
4
  module Instana
2
5
  module Instrumentation
3
6
  class SidekiqClient
4
7
  def call(worker_class, msg, queue, _redis_pool)
5
8
  kv_payload = { :'sidekiq-client' => {} }
6
9
  kv_payload[:'sidekiq-client'][:queue] = queue
7
- kv_payload[:'sidekiq-client'][:job] = worker_class
10
+ kv_payload[:'sidekiq-client'][:job] = worker_class.to_s
8
11
  kv_payload[:'sidekiq-client'][:retry] = msg['retry'].to_s
9
12
  ::Instana.tracer.log_entry(:'sidekiq-client', kv_payload)
10
13
 
@@ -1,3 +1,6 @@
1
+ # (c) Copyright IBM Corp. 2021
2
+ # (c) Copyright Instana Inc. 2017
3
+
1
4
  module Instana
2
5
  module Instrumentation
3
6
  class SidekiqWorker
@@ -5,7 +8,7 @@ module Instana
5
8
  kv_payload = { :'sidekiq-worker' => {} }
6
9
  kv_payload[:'sidekiq-worker'][:job_id] = msg['jid']
7
10
  kv_payload[:'sidekiq-worker'][:queue] = msg['queue']
8
- kv_payload[:'sidekiq-worker'][:job] = msg['class']
11
+ kv_payload[:'sidekiq-worker'][:job] = msg['class'].to_s
9
12
  kv_payload[:'sidekiq-worker'][:retry] = msg['retry'].to_s
10
13
 
11
14
  # Temporary until we move connection collection to redis
@@ -1,3 +1,6 @@
1
+ # (c) Copyright IBM Corp. 2021
2
+ # (c) Copyright Instana Inc. 2017
3
+
1
4
  module OpenTracing
2
5
  class Carrier < Hash
3
6
  end
@@ -1,3 +1,6 @@
1
+ # (c) Copyright IBM Corp. 2021
2
+ # (c) Copyright Instana Inc. 2017
3
+
1
4
  module OpenTracing
2
5
  class << self
3
6
  # Text format for #inject and #extract
data/lib/instana/rack.rb CHANGED
@@ -7,4 +7,8 @@
7
7
  # require 'instana/rack'
8
8
  # config.middleware.use ::Instana::Rack
9
9
  #
10
+
11
+ # (c) Copyright IBM Corp. 2021
12
+ # (c) Copyright Instana Inc. 2016
13
+
10
14
  require 'instana/instrumentation/rack'
@@ -1,3 +1,6 @@
1
+ # (c) Copyright IBM Corp. 2021
2
+ # (c) Copyright Instana Inc. 2021
3
+
1
4
  require 'uri'
2
5
  require 'cgi'
3
6
 
@@ -7,7 +10,7 @@ module Instana
7
10
  return str unless secret_values
8
11
 
9
12
  url = URI(str)
10
- params = CGI.parse(url.query || '')
13
+ params = url.scheme ? CGI.parse(url.query || '') : CGI.parse(url.to_s)
11
14
 
12
15
  redacted = params.map do |k, v|
13
16
  needs_redaction = secret_values['list']
@@ -16,7 +19,7 @@ module Instana
16
19
  end
17
20
 
18
21
  url.query = URI.encode_www_form(redacted)
19
- CGI.unescape(url.to_s)
22
+ url.scheme ? CGI.unescape(url.to_s) : CGI.unescape(url.query)
20
23
  end
21
24
 
22
25
  private