instana 1.193.2 → 1.193.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (188) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +204 -133
  3. data/.gitignore +3 -0
  4. data/.rubocop.yml +10 -1145
  5. data/.rubocop_todo.yml +1140 -0
  6. data/Appraisals +107 -0
  7. data/Gemfile +14 -32
  8. data/LICENSE +2 -1
  9. data/Rakefile +19 -39
  10. data/benchmarks/10k-rack-traces.rb +3 -0
  11. data/benchmarks/Gemfile +4 -0
  12. data/benchmarks/id_generation.rb +4 -0
  13. data/benchmarks/opentracing.rb +4 -0
  14. data/benchmarks/rack_vanilla_vs_traced.rb +3 -0
  15. data/benchmarks/stackprof_rack_tracing.rb +3 -0
  16. data/benchmarks/time_processing.rb +4 -0
  17. data/bin/console +8 -4
  18. data/examples/opentracing.rb +4 -0
  19. data/examples/tracing.rb +4 -0
  20. data/extras/license_header.rb +44 -0
  21. data/gemfiles/.bundle/config +1 -2
  22. data/gemfiles/aws_30.gemfile +18 -0
  23. data/gemfiles/cuba_30.gemfile +18 -0
  24. data/gemfiles/dalli_20.gemfile +18 -0
  25. data/gemfiles/excon_02.gemfile +18 -0
  26. data/gemfiles/graphql_10.gemfile +18 -0
  27. data/gemfiles/grpc_10.gemfile +18 -0
  28. data/gemfiles/net_http_01.gemfile +17 -0
  29. data/gemfiles/rack_16.gemfile +18 -0
  30. data/gemfiles/rack_20.gemfile +18 -0
  31. data/gemfiles/rails_42.gemfile +21 -0
  32. data/gemfiles/rails_50.gemfile +21 -0
  33. data/gemfiles/rails_52.gemfile +21 -0
  34. data/gemfiles/rails_60.gemfile +21 -0
  35. data/gemfiles/redis_40.gemfile +18 -0
  36. data/gemfiles/resque_122.gemfile +19 -0
  37. data/gemfiles/resque_20.gemfile +18 -0
  38. data/gemfiles/rest_client_16.gemfile +18 -0
  39. data/gemfiles/rest_client_20.gemfile +18 -0
  40. data/gemfiles/roda_20.gemfile +18 -0
  41. data/gemfiles/roda_30.gemfile +18 -0
  42. data/gemfiles/sidekiq_42.gemfile +18 -0
  43. data/gemfiles/sidekiq_50.gemfile +18 -0
  44. data/gemfiles/sinatra_14.gemfile +18 -0
  45. data/instana.gemspec +5 -7
  46. data/lib/instana.rb +3 -0
  47. data/lib/instana/activator.rb +44 -0
  48. data/lib/instana/activators/action_cable.rb +24 -0
  49. data/lib/instana/activators/action_controller_api.rb +21 -0
  50. data/lib/instana/activators/action_controller_base.rb +21 -0
  51. data/lib/instana/activators/action_view.rb +21 -0
  52. data/lib/instana/activators/active_record.rb +21 -0
  53. data/lib/instana/activators/aws_sdk_dynamodb.rb +20 -0
  54. data/lib/instana/activators/cuba.rb +21 -0
  55. data/lib/instana/activators/dalli.rb +23 -0
  56. data/lib/instana/activators/excon.rb +20 -0
  57. data/lib/instana/activators/graphql.rb +22 -0
  58. data/lib/instana/activators/grpc_client.rb +20 -0
  59. data/lib/instana/activators/grpc_server.rb +20 -0
  60. data/lib/instana/activators/net_http.rb +20 -0
  61. data/lib/instana/activators/rack.rb +16 -0
  62. data/lib/instana/activators/rails.rb +18 -0
  63. data/lib/instana/activators/redis.rb +20 -0
  64. data/lib/instana/activators/resque_client.rb +21 -0
  65. data/lib/instana/activators/resque_worker.rb +33 -0
  66. data/lib/instana/activators/rest_client.rb +20 -0
  67. data/lib/instana/activators/roda.rb +21 -0
  68. data/lib/instana/activators/sidekiq_client.rb +24 -0
  69. data/lib/instana/activators/sidekiq_worker.rb +24 -0
  70. data/lib/instana/activators/sinatra.rb +21 -0
  71. data/lib/instana/agent.rb +3 -0
  72. data/lib/instana/agent/helpers.rb +3 -0
  73. data/lib/instana/agent/hooks.rb +3 -0
  74. data/lib/instana/agent/tasks.rb +3 -0
  75. data/lib/instana/base.rb +3 -0
  76. data/lib/instana/collector.rb +3 -0
  77. data/lib/instana/collectors/gc.rb +3 -0
  78. data/lib/instana/collectors/memory.rb +3 -0
  79. data/lib/instana/collectors/thread.rb +3 -0
  80. data/lib/instana/config.rb +3 -0
  81. data/lib/instana/frameworks/cuba.rb +9 -13
  82. data/lib/instana/frameworks/rails.rb +22 -32
  83. data/lib/instana/frameworks/roda.rb +10 -13
  84. data/lib/instana/frameworks/sinatra.rb +4 -8
  85. data/lib/instana/helpers.rb +3 -0
  86. data/lib/instana/instrumentation/action_cable.rb +53 -0
  87. data/lib/instana/instrumentation/action_controller.rb +84 -0
  88. data/lib/instana/instrumentation/action_view.rb +30 -0
  89. data/lib/instana/instrumentation/active_record.rb +50 -0
  90. data/lib/instana/instrumentation/aws_sdk_dynamodb.rb +29 -0
  91. data/lib/instana/instrumentation/dalli.rb +3 -6
  92. data/lib/instana/instrumentation/excon.rb +54 -57
  93. data/lib/instana/instrumentation/graphql.rb +19 -18
  94. data/lib/instana/instrumentation/grpc.rb +7 -10
  95. data/lib/instana/instrumentation/instrumented_request.rb +6 -1
  96. data/lib/instana/instrumentation/net-http.rb +6 -6
  97. data/lib/instana/instrumentation/rack.rb +4 -0
  98. data/lib/instana/instrumentation/redis.rb +3 -5
  99. data/lib/instana/instrumentation/resque.rb +3 -25
  100. data/lib/instana/instrumentation/rest-client.rb +3 -5
  101. data/lib/instana/instrumentation/sidekiq-client.rb +4 -10
  102. data/lib/instana/instrumentation/sidekiq-worker.rb +4 -10
  103. data/lib/instana/opentracing/carrier.rb +3 -0
  104. data/lib/instana/opentracing/tracer.rb +3 -0
  105. data/lib/instana/rack.rb +4 -0
  106. data/lib/instana/secrets.rb +3 -0
  107. data/lib/instana/setup.rb +6 -1
  108. data/lib/instana/thread_local.rb +3 -0
  109. data/lib/instana/tracer.rb +3 -0
  110. data/lib/instana/tracing/processor.rb +3 -0
  111. data/lib/instana/tracing/span.rb +11 -2
  112. data/lib/instana/tracing/span_context.rb +3 -0
  113. data/lib/instana/util.rb +3 -0
  114. data/lib/instana/version.rb +4 -1
  115. data/lib/oj_check.rb +3 -0
  116. data/lib/opentracing.rb +3 -0
  117. data/test/activator_test.rb +30 -0
  118. data/test/agent/agent_test.rb +3 -0
  119. data/test/benchmarks/bench_id_generation.rb +3 -0
  120. data/test/benchmarks/bench_opentracing.rb +3 -0
  121. data/test/config_test.rb +3 -0
  122. data/test/frameworks/cuba_test.rb +41 -40
  123. data/test/frameworks/roda_test.rb +43 -41
  124. data/test/frameworks/sinatra_test.rb +64 -64
  125. data/test/instana_test.rb +3 -0
  126. data/test/instrumentation/aws_test.rb +33 -0
  127. data/test/instrumentation/dalli_test.rb +3 -0
  128. data/test/instrumentation/excon_test.rb +4 -0
  129. data/test/instrumentation/graphql_test.rb +3 -0
  130. data/test/instrumentation/grpc_test.rb +5 -1
  131. data/test/instrumentation/{net-http_test.rb → net_http_test.rb} +4 -0
  132. data/test/instrumentation/{instrumented_request_test.rb → rack_instrumented_request_test.rb} +4 -1
  133. data/test/{frameworks → instrumentation}/rack_test.rb +3 -1
  134. data/test/instrumentation/rails_action_cable_test.rb +131 -0
  135. data/test/{frameworks/rails/actioncontroller_test.rb → instrumentation/rails_action_controller_test.rb} +40 -21
  136. data/test/instrumentation/rails_action_view_test.rb +151 -0
  137. data/test/instrumentation/rails_active_record_test.rb +122 -0
  138. data/test/instrumentation/redis_test.rb +3 -0
  139. data/test/instrumentation/resque_test.rb +6 -11
  140. data/test/instrumentation/{rest-client_test.rb → rest_client_test.rb} +9 -0
  141. data/test/instrumentation/sidekiq-client_test.rb +4 -0
  142. data/test/instrumentation/sidekiq-worker_test.rb +4 -0
  143. data/test/secrets_test.rb +3 -0
  144. data/test/support/apps/active_record/active_record.rb +24 -0
  145. data/test/{servers/grpc_50051.rb → support/apps/grpc/boot.rb} +4 -1
  146. data/test/{apps → support/apps/grpc}/grpc_server.rb +3 -0
  147. data/test/{servers/rackapp_6511.rb → support/apps/http_endpoint/boot.rb} +3 -0
  148. data/test/{servers/rails_3205.rb → support/apps/rails/boot.rb} +10 -13
  149. data/test/{models → support/apps/rails/models}/block.rb +4 -1
  150. data/test/{models → support/apps/rails/models}/block6.rb +3 -0
  151. data/test/support/apps/resque/boot.rb +5 -0
  152. data/test/{jobs → support/apps/resque/jobs}/resque_error_job.rb +3 -0
  153. data/test/{jobs → support/apps/resque/jobs}/resque_fast_job.rb +3 -0
  154. data/test/support/apps/sidekiq/boot.rb +25 -0
  155. data/test/{jobs → support/apps/sidekiq/jobs}/sidekiq_job_1.rb +3 -0
  156. data/test/{jobs → support/apps/sidekiq/jobs}/sidekiq_job_2.rb +3 -0
  157. data/test/{servers → support/apps}/sidekiq/worker.rb +5 -2
  158. data/test/support/helpers.rb +97 -0
  159. data/test/test_helper.rb +27 -138
  160. data/test/tracing/custom_test.rb +3 -0
  161. data/test/tracing/id_management_test.rb +4 -0
  162. data/test/tracing/opentracing_test.rb +3 -0
  163. data/test/tracing/tracer_async_test.rb +3 -0
  164. data/test/tracing/tracer_test.rb +3 -0
  165. metadata +110 -96
  166. data/gemfiles/libraries.gemfile +0 -73
  167. data/gemfiles/rails32.gemfile +0 -51
  168. data/gemfiles/rails42.gemfile +0 -50
  169. data/gemfiles/rails50.gemfile +0 -52
  170. data/gemfiles/rails52.gemfile +0 -52
  171. data/gemfiles/rails60.gemfile +0 -72
  172. data/lib/instana/frameworks/instrumentation/abstract_mysql_adapter.rb +0 -56
  173. data/lib/instana/frameworks/instrumentation/action_controller.rb +0 -194
  174. data/lib/instana/frameworks/instrumentation/action_view.rb +0 -39
  175. data/lib/instana/frameworks/instrumentation/active_record.rb +0 -27
  176. data/lib/instana/frameworks/instrumentation/mysql2_adapter.rb +0 -83
  177. data/lib/instana/frameworks/instrumentation/mysql_adapter.rb +0 -60
  178. data/lib/instana/frameworks/instrumentation/postgresql_adapter.rb +0 -99
  179. data/lib/instana/instrumentation.rb +0 -25
  180. data/lib/instana/test.rb +0 -43
  181. data/test/apps/cuba.rb +0 -19
  182. data/test/apps/roda.rb +0 -13
  183. data/test/apps/sinatra.rb +0 -9
  184. data/test/frameworks/rails/actionview3_test.rb +0 -210
  185. data/test/frameworks/rails/actionview4_test.rb +0 -208
  186. data/test/frameworks/rails/actionview5_test.rb +0 -221
  187. data/test/frameworks/rails/activerecord_test.rb +0 -279
  188. data/test/servers/helpers/sidekiq_worker_initializer.rb +0 -27
@@ -1,6 +1,11 @@
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
- require "cgi"
3
+
4
+ # (c) Copyright IBM Corp. 2021
5
+ # (c) Copyright Instana Inc. 2021
6
+
7
+ require 'cgi'
8
+ require 'rack/request'
4
9
 
5
10
  module Instana
6
11
  class InstrumentedRequest < Rack::Request
@@ -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
- if defined?(::Net::HTTP) && ::Instana.config[:nethttp][:enabled]
4
- module Instana
6
+ module Instana
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
@@ -54,7 +57,4 @@ if defined?(::Net::HTTP) && ::Instana.config[:nethttp][:enabled]
54
57
  end
55
58
  end
56
59
  end
57
-
58
- ::Instana.logger.debug "Instrumenting Net::HTTP"
59
- Net::HTTP.prepend(::Instana::NetHTTPInstrumentation)
60
60
  end
@@ -1,3 +1,7 @@
1
+ # (c) Copyright IBM Corp. 2021
2
+ # (c) Copyright Instana Inc. 2016
3
+
4
+ require 'rack'
1
5
  require 'instana/instrumentation/instrumented_request'
2
6
 
3
7
  module Instana
@@ -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)
@@ -60,8 +63,3 @@ module Instana
60
63
  end
61
64
  end
62
65
  end
63
-
64
- if defined?(::Redis) && ::Instana.config[:redis][:enabled]
65
- ::Instana.logger.debug "Instrumenting Redis"
66
- Redis::Client.prepend(::Instana::RedisInstrumentation)
67
- end
@@ -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
@@ -93,28 +96,3 @@ module Instana
93
96
  end
94
97
  end
95
98
  end
96
-
97
- if defined?(::Resque) && RUBY_VERSION >= '1.9.3'
98
-
99
- if ::Instana.config[:'resque-client'][:enabled]
100
- ::Instana.logger.debug 'Instrumenting Resque Client'
101
- ::Resque.prepend(::Instana::Instrumentation::ResqueClient)
102
- end
103
-
104
- if ::Instana.config[:'resque-worker'][:enabled]
105
- ::Instana.logger.debug 'Instrumenting Resque Worker'
106
-
107
- ::Resque::Worker.prepend(::Instana::Instrumentation::ResqueWorker)
108
- ::Resque::Job.prepend(::Instana::Instrumentation::ResqueJob)
109
-
110
- ::Resque.before_fork do |job|
111
- ::Instana.agent.before_resque_fork
112
- end
113
- ::Resque.after_fork do |job|
114
- ::Instana.agent.after_resque_fork
115
- end
116
-
117
- # Set this so we assure that any remaining collected traces are reported at_exit
118
- ENV['RUN_AT_EXIT_HOOKS'] = "1"
119
- end
120
- end
@@ -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
@@ -17,8 +20,3 @@ module Instana
17
20
  end
18
21
  end
19
22
  end
20
-
21
- if defined?(::RestClient::Request) && ::Instana.config[:'rest-client'][:enabled]
22
- ::Instana.logger.debug "Instrumenting RestClient"
23
- ::RestClient::Request.send(:prepend, ::Instana::Instrumentation::RestClientRequest)
24
- 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
 
@@ -34,12 +37,3 @@ module Instana
34
37
  end
35
38
  end
36
39
  end
37
-
38
- if defined?(::Sidekiq) && ::Instana.config[:'sidekiq-client'][:enabled]
39
- ::Sidekiq.configure_client do |cfg|
40
- cfg.client_middleware do |chain|
41
- ::Instana.logger.debug "Instrumenting Sidekiq client"
42
- chain.add ::Instana::Instrumentation::SidekiqClient
43
- end
44
- end
45
- 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
  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
@@ -43,12 +46,3 @@ module Instana
43
46
  end
44
47
  end
45
48
  end
46
-
47
- if defined?(::Sidekiq) && ::Instana.config[:'sidekiq-worker'][:enabled]
48
- ::Sidekiq.configure_server do |cfg|
49
- cfg.server_middleware do |chain|
50
- ::Instana.logger.debug "Instrumenting Sidekiq worker"
51
- chain.add ::Instana::Instrumentation::SidekiqWorker
52
- end
53
- end
54
- 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 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"
@@ -7,10 +10,12 @@ require "instana/collector"
7
10
  require "instana/secrets"
8
11
  require "instana/tracer"
9
12
  require "instana/tracing/processor"
10
- require "instana/instrumentation"
13
+
14
+ require 'instana/activator'
11
15
 
12
16
  ::Instana.setup
13
17
  ::Instana.agent.setup
18
+ ::Instana::Activator.start
14
19
 
15
20
  # Register the metric collectors
16
21
  unless RUBY_PLATFORM == 'java'.freeze
@@ -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"
@@ -1,3 +1,6 @@
1
+ # (c) Copyright IBM Corp. 2021
2
+ # (c) Copyright Instana Inc. 2016
3
+
1
4
  require 'thread'
2
5
 
3
6
  module Instana
@@ -1,12 +1,15 @@
1
+ # (c) Copyright IBM Corp. 2021
2
+ # (c) Copyright Instana Inc. 2016
3
+
1
4
  module Instana
2
5
  class Span
3
6
  REGISTERED_SPANS = [ :actioncontroller, :actionview, :activerecord, :excon,
4
7
  :memcache, :'net-http', :rack, :render, :'rpc-client',
5
8
  :'rpc-server', :'sidekiq-client', :'sidekiq-worker',
6
- :redis, :'resque-client', :'resque-worker', :'graphql.server' ].freeze
9
+ :redis, :'resque-client', :'resque-worker', :'graphql.server', :dynamodb ].freeze
7
10
  ENTRY_SPANS = [ :rack, :'resque-worker', :'rpc-server', :'sidekiq-worker', :'graphql.server' ].freeze
8
11
  EXIT_SPANS = [ :activerecord, :excon, :'net-http', :'resque-client',
9
- :'rpc-client', :'sidekiq-client', :redis ].freeze
12
+ :'rpc-client', :'sidekiq-client', :redis, :dynamodb ].freeze
10
13
  HTTP_SPANS = [ :rack, :excon, :'net-http' ].freeze
11
14
 
12
15
  attr_accessor :parent
@@ -286,6 +289,12 @@ module Instana
286
289
  @data.inspect
287
290
  end
288
291
 
292
+ # Check to see if the current span indicates an exit from application
293
+ # code and into an external service
294
+ def exit_span?
295
+ EXIT_SPANS.include?(@data[:n])
296
+ end
297
+
289
298
  #############################################################
290
299
  # OpenTracing Compatibility Methods
291
300
  #############################################################
@@ -1,3 +1,6 @@
1
+ # (c) Copyright IBM Corp. 2021
2
+ # (c) Copyright Instana Inc. 2017
3
+
1
4
  module Instana
2
5
  class SpanContext
3
6
  attr_accessor :trace_id
data/lib/instana/util.rb CHANGED
@@ -1,3 +1,6 @@
1
+ # (c) Copyright IBM Corp. 2021
2
+ # (c) Copyright Instana Inc. 2016
3
+
1
4
  module Instana
2
5
  module Util
3
6
  class << self
@@ -1,4 +1,7 @@
1
+ # (c) Copyright IBM Corp. 2021
2
+ # (c) Copyright Instana Inc. 2016
3
+
1
4
  module Instana
2
- VERSION = "1.193.2"
5
+ VERSION = "1.193.6"
3
6
  VERSION_FULL = "instana-#{VERSION}"
4
7
  end
data/lib/oj_check.rb CHANGED
@@ -1,3 +1,6 @@
1
+ # (c) Copyright IBM Corp. 2021
2
+ # (c) Copyright Instana Inc. 2019
3
+
1
4
  begin
2
5
  require 'oj'
3
6
  rescue LoadError => e
data/lib/opentracing.rb CHANGED
@@ -1,3 +1,6 @@
1
+ # (c) Copyright IBM Corp. 2021
2
+ # (c) Copyright Instana Inc. 2017
3
+
1
4
  require "instana/opentracing/tracer"
2
5
  require "instana/opentracing/carrier"
3
6
 
@@ -0,0 +1,30 @@
1
+ # (c) Copyright IBM Corp. 2021
2
+ # (c) Copyright Instana Inc. 2021
3
+
4
+ require 'test_helper'
5
+
6
+ class ActivatorTest < Minitest::Test
7
+ def test_start
8
+ refute_nil Instana::Activator.trace_point
9
+ assert Instana::Activator.trace_point.enabled?
10
+ end
11
+
12
+ def test_klass_call
13
+ assert_equal [], Instana::Activator.call
14
+ end
15
+
16
+ def test_instance_call
17
+ subject = Class.new(Instana::Activator) do
18
+ def can_instrument?
19
+ true
20
+ end
21
+
22
+ def instrument
23
+ true
24
+ end
25
+ end
26
+
27
+ assert_equal 1, Instana::Activator.call.length
28
+ assert subject.call
29
+ end
30
+ end
@@ -1,3 +1,6 @@
1
+ # (c) Copyright IBM Corp. 2021
2
+ # (c) Copyright Instana Inc. 2016
3
+
1
4
  require 'test_helper'
2
5
  require './lib/oj_check'
3
6
 
@@ -1,3 +1,6 @@
1
+ # (c) Copyright IBM Corp. 2021
2
+ # (c) Copyright Instana Inc. 2017
3
+
1
4
  require 'test_helper'
2
5
 
3
6
  class BenchIDs < Minitest::Benchmark
@@ -1,3 +1,6 @@
1
+ # (c) Copyright IBM Corp. 2021
2
+ # (c) Copyright Instana Inc. 2017
3
+
1
4
  require 'test_helper'
2
5
 
3
6
  class BenchOpenTracing < Minitest::Benchmark
data/test/config_test.rb CHANGED
@@ -1,3 +1,6 @@
1
+ # (c) Copyright IBM Corp. 2021
2
+ # (c) Copyright Instana Inc. 2016
3
+
1
4
  require 'test_helper'
2
5
 
3
6
  class ConfigTest < Minitest::Test
@@ -1,57 +1,58 @@
1
- if defined?(::Cuba)
2
- require 'test_helper'
3
- require File.expand_path(File.dirname(__FILE__) + '/../apps/cuba')
4
- require 'rack/test'
1
+ # (c) Copyright IBM Corp. 2021
2
+ # (c) Copyright Instana Inc. 2016
5
3
 
6
- class CubaTest < Minitest::Test
7
- include Rack::Test::Methods
4
+ require 'test_helper'
5
+ require 'rack/test'
8
6
 
9
- def app
10
- Cuba
11
- end
7
+ class CubaTest < Minitest::Test
8
+ include Rack::Test::Methods
9
+ APP = Rack::Builder.parse_file('test/support/apps/cuba/config.ru').first
12
10
 
13
- def test_basic_get
14
- clear_all!
11
+ def app
12
+ APP
13
+ end
14
+
15
+ def test_basic_get
16
+ clear_all!
15
17
 
16
- r = get '/hello'
17
- assert last_response.ok?
18
+ r = get '/hello'
19
+ assert last_response.ok?
18
20
 
19
- assert r.headers.key?("X-Instana-T")
20
- assert r.headers.key?("X-Instana-S")
21
+ assert r.headers.key?("X-Instana-T")
22
+ assert r.headers.key?("X-Instana-S")
21
23
 
22
- spans = ::Instana.processor.queued_spans
23
- assert_equal 1, spans.count
24
+ spans = ::Instana.processor.queued_spans
25
+ assert_equal 1, spans.count
24
26
 
25
- first_span = spans.first
26
- assert_equal :rack, first_span[:n]
27
- assert first_span.key?(:data)
28
- assert first_span[:data].key?(:http)
27
+ first_span = spans.first
28
+ assert_equal :rack, first_span[:n]
29
+ assert first_span.key?(:data)
30
+ assert first_span[:data].key?(:http)
29
31
 
30
- assert first_span[:data][:http].key?(:method)
31
- assert_equal "GET", first_span[:data][:http][:method]
32
+ assert first_span[:data][:http].key?(:method)
33
+ assert_equal "GET", first_span[:data][:http][:method]
32
34
 
33
- assert first_span[:data][:http].key?(:url)
34
- assert_equal "/hello", first_span[:data][:http][:url]
35
+ assert first_span[:data][:http].key?(:url)
36
+ assert_equal "/hello", first_span[:data][:http][:url]
35
37
 
36
- assert first_span[:data][:http].key?(:status)
37
- assert_equal 200, first_span[:data][:http][:status]
38
+ assert first_span[:data][:http].key?(:status)
39
+ assert_equal 200, first_span[:data][:http][:status]
38
40
 
39
- assert first_span[:data][:http].key?(:host)
40
- assert_equal "example.org", first_span[:data][:http][:host]
41
- end
41
+ assert first_span[:data][:http].key?(:host)
42
+ assert_equal "example.org", first_span[:data][:http][:host]
43
+ end
42
44
 
43
- def test_path_template
44
- clear_all!
45
+ def test_path_template
46
+ clear_all!
45
47
 
46
- r = get '/greet/instana'
47
- assert last_response.ok?
48
+ r = get '/greet/instana'
49
+ assert last_response.ok?
48
50
 
49
- spans = ::Instana.processor.queued_spans
50
- assert_equal 1, spans.count
51
+ spans = ::Instana.processor.queued_spans
52
+ assert_equal 1, spans.count
51
53
 
52
- first_span = spans.first
53
- assert_equal :rack, first_span[:n]
54
- assert_equal '/greet/{name}', first_span[:data][:http][:path_tpl]
55
- end
54
+ first_span = spans.first
55
+ assert_equal :rack, first_span[:n]
56
+ assert_equal '/greet/{name}', first_span[:data][:http][:path_tpl]
56
57
  end
57
58
  end