instana 1.193.3 → 1.195.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (162) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +4 -0
  3. data/.rubocop.yml +7 -0
  4. data/Appraisals +7 -0
  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/examples/opentracing.rb +4 -0
  17. data/examples/tracing.rb +4 -0
  18. data/extras/license_header.rb +44 -0
  19. data/gemfiles/aws_30.gemfile +18 -0
  20. data/gemfiles/cuba_30.gemfile +3 -0
  21. data/gemfiles/dalli_20.gemfile +3 -0
  22. data/gemfiles/excon_02.gemfile +3 -0
  23. data/gemfiles/graphql_10.gemfile +3 -0
  24. data/gemfiles/grpc_10.gemfile +3 -0
  25. data/gemfiles/net_http_01.gemfile +3 -0
  26. data/gemfiles/rack_16.gemfile +3 -0
  27. data/gemfiles/rack_20.gemfile +3 -0
  28. data/gemfiles/rails_42.gemfile +3 -0
  29. data/gemfiles/rails_50.gemfile +3 -0
  30. data/gemfiles/rails_52.gemfile +3 -0
  31. data/gemfiles/rails_60.gemfile +3 -0
  32. data/gemfiles/redis_40.gemfile +3 -0
  33. data/gemfiles/resque_122.gemfile +3 -0
  34. data/gemfiles/resque_20.gemfile +3 -0
  35. data/gemfiles/rest_client_16.gemfile +3 -0
  36. data/gemfiles/rest_client_20.gemfile +3 -0
  37. data/gemfiles/roda_20.gemfile +3 -0
  38. data/gemfiles/roda_30.gemfile +3 -0
  39. data/gemfiles/sidekiq_42.gemfile +3 -0
  40. data/gemfiles/sidekiq_50.gemfile +3 -0
  41. data/gemfiles/sinatra_14.gemfile +3 -0
  42. data/instana.gemspec +4 -0
  43. data/lib/instana.rb +3 -0
  44. data/lib/instana/activator.rb +3 -0
  45. data/lib/instana/activators/action_cable.rb +24 -0
  46. data/lib/instana/activators/action_controller_api.rb +3 -0
  47. data/lib/instana/activators/action_controller_base.rb +3 -0
  48. data/lib/instana/activators/action_view.rb +3 -0
  49. data/lib/instana/activators/active_record.rb +3 -0
  50. data/lib/instana/activators/aws_sdk_dynamodb.rb +20 -0
  51. data/lib/instana/activators/cuba.rb +3 -0
  52. data/lib/instana/activators/dalli.rb +3 -0
  53. data/lib/instana/activators/excon.rb +4 -1
  54. data/lib/instana/activators/graphql.rb +3 -0
  55. data/lib/instana/activators/grpc_client.rb +3 -0
  56. data/lib/instana/activators/grpc_server.rb +3 -0
  57. data/lib/instana/activators/net_http.rb +3 -0
  58. data/lib/instana/activators/rack.rb +3 -0
  59. data/lib/instana/activators/rails.rb +3 -0
  60. data/lib/instana/activators/redis.rb +3 -0
  61. data/lib/instana/activators/resque_client.rb +3 -0
  62. data/lib/instana/activators/resque_worker.rb +3 -0
  63. data/lib/instana/activators/rest_client.rb +3 -0
  64. data/lib/instana/activators/roda.rb +3 -0
  65. data/lib/instana/activators/sidekiq_client.rb +3 -0
  66. data/lib/instana/activators/sidekiq_worker.rb +3 -0
  67. data/lib/instana/activators/sinatra.rb +3 -0
  68. data/lib/instana/agent.rb +3 -0
  69. data/lib/instana/agent/helpers.rb +3 -0
  70. data/lib/instana/agent/hooks.rb +3 -0
  71. data/lib/instana/agent/tasks.rb +3 -0
  72. data/lib/instana/base.rb +3 -0
  73. data/lib/instana/collector.rb +3 -0
  74. data/lib/instana/collectors/gc.rb +3 -0
  75. data/lib/instana/collectors/memory.rb +3 -0
  76. data/lib/instana/collectors/thread.rb +3 -0
  77. data/lib/instana/config.rb +6 -0
  78. data/lib/instana/frameworks/cuba.rb +3 -0
  79. data/lib/instana/frameworks/rails.rb +3 -0
  80. data/lib/instana/frameworks/roda.rb +3 -0
  81. data/lib/instana/frameworks/sinatra.rb +3 -0
  82. data/lib/instana/helpers.rb +3 -0
  83. data/lib/instana/instrumentation/action_cable.rb +53 -0
  84. data/lib/instana/instrumentation/action_controller.rb +4 -1
  85. data/lib/instana/instrumentation/action_view.rb +3 -0
  86. data/lib/instana/instrumentation/active_record.rb +3 -0
  87. data/lib/instana/instrumentation/aws_sdk_dynamodb.rb +29 -0
  88. data/lib/instana/instrumentation/dalli.rb +3 -0
  89. data/lib/instana/instrumentation/excon.rb +11 -3
  90. data/lib/instana/instrumentation/graphql.rb +3 -0
  91. data/lib/instana/instrumentation/grpc.rb +3 -0
  92. data/lib/instana/instrumentation/instrumented_request.rb +62 -6
  93. data/lib/instana/instrumentation/net-http.rb +9 -1
  94. data/lib/instana/instrumentation/rack.rb +38 -15
  95. data/lib/instana/instrumentation/redis.rb +3 -0
  96. data/lib/instana/instrumentation/resque.rb +3 -0
  97. data/lib/instana/instrumentation/rest-client.rb +3 -0
  98. data/lib/instana/instrumentation/sidekiq-client.rb +4 -1
  99. data/lib/instana/instrumentation/sidekiq-worker.rb +4 -1
  100. data/lib/instana/opentracing/carrier.rb +3 -0
  101. data/lib/instana/opentracing/tracer.rb +3 -0
  102. data/lib/instana/rack.rb +4 -0
  103. data/lib/instana/secrets.rb +3 -0
  104. data/lib/instana/setup.rb +3 -0
  105. data/lib/instana/thread_local.rb +3 -0
  106. data/lib/instana/tracer.rb +13 -7
  107. data/lib/instana/tracing/processor.rb +3 -0
  108. data/lib/instana/tracing/span.rb +11 -2
  109. data/lib/instana/tracing/span_context.rb +27 -1
  110. data/lib/instana/util.rb +3 -0
  111. data/lib/instana/version.rb +4 -1
  112. data/lib/oj_check.rb +3 -0
  113. data/lib/opentracing.rb +3 -0
  114. data/test/activator_test.rb +3 -0
  115. data/test/agent/agent_test.rb +3 -0
  116. data/test/benchmarks/bench_id_generation.rb +3 -0
  117. data/test/benchmarks/bench_opentracing.rb +3 -0
  118. data/test/config_test.rb +3 -0
  119. data/test/frameworks/cuba_test.rb +3 -0
  120. data/test/frameworks/roda_test.rb +4 -0
  121. data/test/frameworks/sinatra_test.rb +3 -0
  122. data/test/instana_test.rb +3 -0
  123. data/test/instrumentation/aws_test.rb +33 -0
  124. data/test/instrumentation/dalli_test.rb +3 -0
  125. data/test/instrumentation/excon_test.rb +3 -0
  126. data/test/instrumentation/graphql_test.rb +3 -0
  127. data/test/instrumentation/grpc_test.rb +3 -0
  128. data/test/instrumentation/net_http_test.rb +3 -0
  129. data/test/instrumentation/rack_instrumented_request_test.rb +49 -1
  130. data/test/instrumentation/rack_test.rb +144 -0
  131. data/test/instrumentation/rails_action_cable_test.rb +131 -0
  132. data/test/instrumentation/rails_action_controller_test.rb +3 -0
  133. data/test/instrumentation/rails_action_view_test.rb +13 -0
  134. data/test/instrumentation/rails_active_record_test.rb +3 -2
  135. data/test/instrumentation/redis_test.rb +3 -0
  136. data/test/instrumentation/resque_test.rb +3 -0
  137. data/test/instrumentation/rest_client_test.rb +3 -0
  138. data/test/instrumentation/sidekiq-client_test.rb +3 -0
  139. data/test/instrumentation/sidekiq-worker_test.rb +3 -0
  140. data/test/secrets_test.rb +3 -0
  141. data/test/support/apps/active_record/active_record.rb +3 -0
  142. data/test/support/apps/grpc/boot.rb +3 -0
  143. data/test/support/apps/grpc/grpc_server.rb +3 -0
  144. data/test/support/apps/http_endpoint/boot.rb +3 -0
  145. data/test/support/apps/rails/boot.rb +3 -0
  146. data/test/support/apps/rails/models/block.rb +3 -0
  147. data/test/support/apps/rails/models/block6.rb +3 -0
  148. data/test/support/apps/resque/boot.rb +3 -0
  149. data/test/support/apps/resque/jobs/resque_error_job.rb +3 -0
  150. data/test/support/apps/resque/jobs/resque_fast_job.rb +3 -0
  151. data/test/support/apps/sidekiq/boot.rb +4 -0
  152. data/test/support/apps/sidekiq/jobs/sidekiq_job_1.rb +3 -0
  153. data/test/support/apps/sidekiq/jobs/sidekiq_job_2.rb +3 -0
  154. data/test/support/apps/sidekiq/worker.rb +3 -0
  155. data/test/support/helpers.rb +3 -0
  156. data/test/test_helper.rb +3 -0
  157. data/test/tracing/custom_test.rb +3 -0
  158. data/test/tracing/id_management_test.rb +4 -0
  159. data/test/tracing/opentracing_test.rb +6 -3
  160. data/test/tracing/tracer_async_test.rb +3 -0
  161. data/test/tracing/tracer_test.rb +3 -0
  162. metadata +12 -2
@@ -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
  module ActionController
@@ -35,7 +38,7 @@ module Instana
35
38
  end
36
39
 
37
40
  def describe_render_options(options)
38
- return unless options
41
+ return unless options.is_a?(Hash)
39
42
 
40
43
  describe_layout(options[:layout]) ||
41
44
  describe_direct(options)
@@ -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
  module ActionView
@@ -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
  module ActiveRecord
@@ -0,0 +1,29 @@
1
+ # (c) Copyright IBM Corp. 2021
2
+ # (c) Copyright Instana Inc. 2021
3
+
4
+ module Instana
5
+ module Instrumentation
6
+ class DynamoDB < Seahorse::Client::Plugin
7
+ class Handler < Seahorse::Client::Handler
8
+ def call(context)
9
+ dynamo_tags = {
10
+ op: context.operation_name,
11
+ table: table_name_from(context)
12
+ }
13
+
14
+ ::Instana.tracer.trace(:dynamodb, dynamo_tags) { @handler.call(context) }
15
+ end
16
+
17
+ private
18
+
19
+ def table_name_from(context)
20
+ context.params[:table_name] || context.params[:global_table_name] || 'Unknown'
21
+ end
22
+ end
23
+
24
+ def add_handlers(handlers, _config)
25
+ handlers.add(Handler, step: :initialize)
26
+ end
27
+ end
28
+ end
29
+ 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 Instrumentation
3
6
  module Dalli
@@ -1,8 +1,11 @@
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
11
  path = datum[:path].split('?').first
@@ -23,11 +26,16 @@ module Instana
23
26
  datum[:headers]['X-Instana-T'] = t_context.trace_id_header
24
27
  datum[:headers]['X-Instana-S'] = t_context.span_id_header
25
28
 
29
+ if ::Instana.config[:w3_trace_correlation]
30
+ datum[:headers]['Traceparent'] = t_context.trace_parent_header
31
+ datum[:headers]['Tracestate'] = t_context.trace_state_header
32
+ end
33
+
26
34
  @stack.request_call(datum)
27
35
  end
28
36
 
29
37
  def error_call(datum)
30
- return @stack.error_call(datum) unless ::Instana.tracer.tracing?
38
+ return @stack.error_call(datum) unless ::Instana.tracer.tracing? || !Instana.tracer.current_span.exit_span?
31
39
 
32
40
  if datum[:pipeline] == true
33
41
  ::Instana.tracer.log_async_error(datum[:error], datum[:instana_span])
@@ -40,7 +48,7 @@ module Instana
40
48
  def response_call(datum)
41
49
  # FIXME: Will connect exceptions call a response?
42
50
  #
43
- return @stack.response_call(datum) unless ::Instana.tracer.tracing?
51
+ return @stack.response_call(datum) unless ::Instana.tracer.tracing? || !Instana.tracer.current_span.exit_span?
44
52
 
45
53
  result = @stack.response_call(datum)
46
54
 
@@ -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
@@ -50,8 +59,55 @@ module Instana
50
59
  @correlation_data ||= parse_correlation_data
51
60
  end
52
61
 
62
+ def instana_ancestor
63
+ @instana_ancestor ||= parse_trace_state
64
+ end
65
+
66
+ def continuing_from_trace_parent?
67
+ incoming_context.include?(:external_trace_id)
68
+ end
69
+
70
+ def synthetic?
71
+ @env.has_key?('HTTP_X_INSTANA_SYNTHETIC') && @env['HTTP_X_INSTANA_SYNTHETIC'].eql?('1')
72
+ end
73
+
53
74
  private
54
75
 
76
+ def context_from_instana_headers
77
+ {
78
+ trace_id: ::Instana::Util.header_to_id(@env['HTTP_X_INSTANA_T']),
79
+ span_id: ::Instana::Util.header_to_id(@env['HTTP_X_INSTANA_S'])
80
+ }.compact
81
+ end
82
+
83
+ def context_from_trace_parent
84
+ return {} unless @env.has_key?('HTTP_TRACEPARENT')
85
+ matches = @env['HTTP_TRACEPARENT'].match(W3_TRACE_PARENT_FORMAT)
86
+ return {} unless matches
87
+
88
+ {
89
+ external_trace_id: matches['trace'],
90
+ external_state: @env['HTTP_TRACESTATE'],
91
+ trace_id: ::Instana::Util.header_to_id(matches['trace'][16..-1]),
92
+ span_id: ::Instana::Util.header_to_id(matches['parent'])
93
+ }
94
+ end
95
+
96
+ def parse_trace_state
97
+ return {} unless @env.has_key?('HTTP_TRACESTATE')
98
+ token = @env['HTTP_TRACESTATE']
99
+ .split(/,/)
100
+ .map { |t| t.match(INSTANA_TRACE_STATE) }
101
+ .reject { |t| t.nil? }
102
+ .first
103
+ return {} unless token
104
+
105
+ {
106
+ t: token['trace'],
107
+ p: token['span']
108
+ }
109
+ end
110
+
55
111
  def parse_correlation_data
56
112
  return {} unless @env.has_key?('HTTP_X_INSTANA_L')
57
113
  _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,6 +22,11 @@ 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
@@ -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
@@ -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
 
data/lib/instana/setup.rb CHANGED
@@ -1,3 +1,6 @@
1
+ # (c) Copyright IBM Corp. 2021
2
+ # (c) Copyright Instana Inc. 2016
3
+
1
4
  require 'oj_check'
2
5
 
3
6
  require "instana/base"
@@ -1,3 +1,6 @@
1
+ # (c) Copyright IBM Corp. 2021
2
+ # (c) Copyright Instana Inc. 2016
3
+
1
4
  module Instana
2
5
  module ThreadLocal
3
6
  def thread_local(name)
@@ -1,3 +1,6 @@
1
+ # (c) Copyright IBM Corp. 2021
2
+ # (c) Copyright Instana Inc. 2016
3
+
1
4
  require "instana/thread_local"
2
5
  require "instana/tracing/span"
3
6
  require "instana/tracing/span_context"
@@ -88,7 +91,15 @@ module Instana
88
91
  if incoming_context
89
92
  if incoming_context.is_a?(Hash)
90
93
  if !incoming_context.empty?
91
- parent_context = SpanContext.new(incoming_context[:trace_id], incoming_context[:span_id], incoming_context[:level])
94
+ parent_context = SpanContext.new(
95
+ incoming_context[:trace_id],
96
+ incoming_context[:span_id],
97
+ incoming_context[:level],
98
+ {
99
+ external_trace_id: incoming_context[:external_trace_id],
100
+ external_state: incoming_context[:external_state]
101
+ }
102
+ )
92
103
  end
93
104
  else
94
105
  parent_context = incoming_context
@@ -100,12 +111,7 @@ module Instana
100
111
  else
101
112
  self.current_span = Span.new(name)
102
113
  end
103
-
104
- if incoming_context.is_a?(Hash) && incoming_context[:correlation] && !incoming_context[:correlation].empty?
105
- self.current_span[:crid] = incoming_context[:correlation][:id]
106
- self.current_span[:crtp] = incoming_context[:correlation][:type]
107
- end
108
-
114
+
109
115
  self.current_span.set_tags(kvs) unless kvs.empty?
110
116
  self.current_span
111
117
  end