instana 1.192.1 → 1.193.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (184) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +200 -133
  3. data/.gitignore +3 -0
  4. data/.rubocop.yml +10 -1145
  5. data/.rubocop_todo.yml +1140 -0
  6. data/Appraisals +103 -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/cuba_30.gemfile +18 -0
  23. data/gemfiles/dalli_20.gemfile +18 -0
  24. data/gemfiles/excon_02.gemfile +18 -0
  25. data/gemfiles/graphql_10.gemfile +18 -0
  26. data/gemfiles/grpc_10.gemfile +18 -0
  27. data/gemfiles/net_http_01.gemfile +17 -0
  28. data/gemfiles/rack_16.gemfile +18 -0
  29. data/gemfiles/rack_20.gemfile +18 -0
  30. data/gemfiles/rails_42.gemfile +21 -0
  31. data/gemfiles/rails_50.gemfile +21 -0
  32. data/gemfiles/rails_52.gemfile +21 -0
  33. data/gemfiles/rails_60.gemfile +21 -0
  34. data/gemfiles/redis_40.gemfile +18 -0
  35. data/gemfiles/resque_122.gemfile +19 -0
  36. data/gemfiles/resque_20.gemfile +18 -0
  37. data/gemfiles/rest_client_16.gemfile +18 -0
  38. data/gemfiles/rest_client_20.gemfile +18 -0
  39. data/gemfiles/roda_20.gemfile +18 -0
  40. data/gemfiles/roda_30.gemfile +18 -0
  41. data/gemfiles/sidekiq_42.gemfile +18 -0
  42. data/gemfiles/sidekiq_50.gemfile +18 -0
  43. data/gemfiles/sinatra_14.gemfile +18 -0
  44. data/instana.gemspec +5 -7
  45. data/lib/instana.rb +3 -0
  46. data/lib/instana/activator.rb +44 -0
  47. data/lib/instana/activators/action_cable.rb +24 -0
  48. data/lib/instana/activators/action_controller_api.rb +21 -0
  49. data/lib/instana/activators/action_controller_base.rb +21 -0
  50. data/lib/instana/activators/action_view.rb +21 -0
  51. data/lib/instana/activators/active_record.rb +21 -0
  52. data/lib/instana/activators/cuba.rb +21 -0
  53. data/lib/instana/activators/dalli.rb +23 -0
  54. data/lib/instana/activators/excon.rb +20 -0
  55. data/lib/instana/activators/graphql.rb +22 -0
  56. data/lib/instana/activators/grpc_client.rb +20 -0
  57. data/lib/instana/activators/grpc_server.rb +20 -0
  58. data/lib/instana/activators/net_http.rb +20 -0
  59. data/lib/instana/activators/rack.rb +16 -0
  60. data/lib/instana/activators/rails.rb +18 -0
  61. data/lib/instana/activators/redis.rb +20 -0
  62. data/lib/instana/activators/resque_client.rb +21 -0
  63. data/lib/instana/activators/resque_worker.rb +33 -0
  64. data/lib/instana/activators/rest_client.rb +20 -0
  65. data/lib/instana/activators/roda.rb +21 -0
  66. data/lib/instana/activators/sidekiq_client.rb +24 -0
  67. data/lib/instana/activators/sidekiq_worker.rb +24 -0
  68. data/lib/instana/activators/sinatra.rb +21 -0
  69. data/lib/instana/agent.rb +3 -0
  70. data/lib/instana/agent/helpers.rb +3 -0
  71. data/lib/instana/agent/hooks.rb +3 -0
  72. data/lib/instana/agent/tasks.rb +3 -0
  73. data/lib/instana/base.rb +3 -0
  74. data/lib/instana/collector.rb +3 -0
  75. data/lib/instana/collectors/gc.rb +3 -0
  76. data/lib/instana/collectors/memory.rb +3 -0
  77. data/lib/instana/collectors/thread.rb +3 -0
  78. data/lib/instana/config.rb +3 -0
  79. data/lib/instana/frameworks/cuba.rb +9 -13
  80. data/lib/instana/frameworks/rails.rb +22 -32
  81. data/lib/instana/frameworks/roda.rb +10 -13
  82. data/lib/instana/frameworks/sinatra.rb +4 -8
  83. data/lib/instana/helpers.rb +3 -0
  84. data/lib/instana/instrumentation/action_cable.rb +53 -0
  85. data/lib/instana/instrumentation/action_controller.rb +84 -0
  86. data/lib/instana/instrumentation/action_view.rb +30 -0
  87. data/lib/instana/instrumentation/active_record.rb +50 -0
  88. data/lib/instana/instrumentation/dalli.rb +10 -18
  89. data/lib/instana/instrumentation/excon.rb +54 -57
  90. data/lib/instana/instrumentation/graphql.rb +19 -18
  91. data/lib/instana/instrumentation/grpc.rb +73 -66
  92. data/lib/instana/instrumentation/instrumented_request.rb +6 -1
  93. data/lib/instana/instrumentation/net-http.rb +46 -47
  94. data/lib/instana/instrumentation/rack.rb +4 -0
  95. data/lib/instana/instrumentation/redis.rb +13 -18
  96. data/lib/instana/instrumentation/resque.rb +17 -50
  97. data/lib/instana/instrumentation/rest-client.rb +5 -17
  98. data/lib/instana/instrumentation/sidekiq-client.rb +3 -9
  99. data/lib/instana/instrumentation/sidekiq-worker.rb +3 -9
  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 +10 -7
  104. data/lib/instana/setup.rb +6 -1
  105. data/lib/instana/thread_local.rb +3 -0
  106. data/lib/instana/tracer.rb +3 -0
  107. data/lib/instana/tracing/processor.rb +3 -0
  108. data/lib/instana/tracing/span.rb +3 -0
  109. data/lib/instana/tracing/span_context.rb +3 -0
  110. data/lib/instana/util.rb +4 -41
  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 +30 -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 +41 -40
  120. data/test/frameworks/roda_test.rb +43 -41
  121. data/test/frameworks/sinatra_test.rb +64 -64
  122. data/test/instana_test.rb +3 -0
  123. data/test/instrumentation/dalli_test.rb +3 -0
  124. data/test/instrumentation/excon_test.rb +4 -0
  125. data/test/instrumentation/graphql_test.rb +3 -0
  126. data/test/instrumentation/grpc_test.rb +5 -1
  127. data/test/instrumentation/{net-http_test.rb → net_http_test.rb} +4 -0
  128. data/test/instrumentation/{instrumented_request_test.rb → rack_instrumented_request_test.rb} +4 -1
  129. data/test/{frameworks → instrumentation}/rack_test.rb +3 -1
  130. data/test/instrumentation/rails_action_cable_test.rb +131 -0
  131. data/test/{frameworks/rails/actioncontroller_test.rb → instrumentation/rails_action_controller_test.rb} +40 -21
  132. data/test/instrumentation/rails_action_view_test.rb +151 -0
  133. data/test/instrumentation/rails_active_record_test.rb +122 -0
  134. data/test/instrumentation/redis_test.rb +3 -0
  135. data/test/instrumentation/resque_test.rb +6 -11
  136. data/test/instrumentation/{rest-client_test.rb → rest_client_test.rb} +9 -0
  137. data/test/instrumentation/sidekiq-client_test.rb +4 -0
  138. data/test/instrumentation/sidekiq-worker_test.rb +4 -0
  139. data/test/secrets_test.rb +3 -0
  140. data/test/support/apps/active_record/active_record.rb +24 -0
  141. data/test/{servers/grpc_50051.rb → support/apps/grpc/boot.rb} +4 -1
  142. data/test/{apps → support/apps/grpc}/grpc_server.rb +3 -0
  143. data/test/{servers/rackapp_6511.rb → support/apps/http_endpoint/boot.rb} +3 -0
  144. data/test/{servers/rails_3205.rb → support/apps/rails/boot.rb} +10 -13
  145. data/test/{models → support/apps/rails/models}/block.rb +4 -1
  146. data/test/{models → support/apps/rails/models}/block6.rb +3 -0
  147. data/test/support/apps/resque/boot.rb +5 -0
  148. data/test/{jobs → support/apps/resque/jobs}/resque_error_job.rb +3 -0
  149. data/test/{jobs → support/apps/resque/jobs}/resque_fast_job.rb +3 -0
  150. data/test/support/apps/sidekiq/boot.rb +25 -0
  151. data/test/{jobs → support/apps/sidekiq/jobs}/sidekiq_job_1.rb +3 -0
  152. data/test/{jobs → support/apps/sidekiq/jobs}/sidekiq_job_2.rb +3 -0
  153. data/test/{servers → support/apps}/sidekiq/worker.rb +5 -2
  154. data/test/support/helpers.rb +97 -0
  155. data/test/test_helper.rb +27 -144
  156. data/test/tracing/custom_test.rb +3 -0
  157. data/test/tracing/id_management_test.rb +4 -0
  158. data/test/tracing/opentracing_test.rb +3 -0
  159. data/test/tracing/tracer_async_test.rb +3 -0
  160. data/test/tracing/tracer_test.rb +3 -0
  161. metadata +105 -96
  162. data/gemfiles/libraries.gemfile +0 -73
  163. data/gemfiles/rails32.gemfile +0 -51
  164. data/gemfiles/rails42.gemfile +0 -50
  165. data/gemfiles/rails50.gemfile +0 -52
  166. data/gemfiles/rails52.gemfile +0 -52
  167. data/gemfiles/rails60.gemfile +0 -72
  168. data/lib/instana/frameworks/instrumentation/abstract_mysql_adapter.rb +0 -58
  169. data/lib/instana/frameworks/instrumentation/action_controller.rb +0 -194
  170. data/lib/instana/frameworks/instrumentation/action_view.rb +0 -43
  171. data/lib/instana/frameworks/instrumentation/active_record.rb +0 -27
  172. data/lib/instana/frameworks/instrumentation/mysql2_adapter.rb +0 -87
  173. data/lib/instana/frameworks/instrumentation/mysql_adapter.rb +0 -62
  174. data/lib/instana/frameworks/instrumentation/postgresql_adapter.rb +0 -103
  175. data/lib/instana/instrumentation.rb +0 -25
  176. data/lib/instana/test.rb +0 -43
  177. data/test/apps/cuba.rb +0 -19
  178. data/test/apps/roda.rb +0 -13
  179. data/test/apps/sinatra.rb +0 -9
  180. data/test/frameworks/rails/actionview3_test.rb +0 -210
  181. data/test/frameworks/rails/actionview4_test.rb +0 -208
  182. data/test/frameworks/rails/actionview5_test.rb +0 -221
  183. data/test/frameworks/rails/activerecord_test.rb +0 -279
  184. data/test/servers/helpers/sidekiq_worker_initializer.rb +0 -27
@@ -0,0 +1,24 @@
1
+ # (c) Copyright IBM Corp. 2021
2
+ # (c) Copyright Instana Inc. 2021
3
+
4
+ module Instana
5
+ module Activators
6
+ class SidekiqWorker < Activator
7
+ def can_instrument?
8
+ defined?(::Sidekiq) && ::Instana.config[:'sidekiq-worker'][:enabled]
9
+ end
10
+
11
+ def instrument
12
+ require 'instana/instrumentation/sidekiq-worker'
13
+
14
+ ::Sidekiq.configure_server do |cfg|
15
+ cfg.server_middleware do |chain|
16
+ chain.add ::Instana::Instrumentation::SidekiqWorker
17
+ end
18
+ end
19
+
20
+ true
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,21 @@
1
+ # (c) Copyright IBM Corp. 2021
2
+ # (c) Copyright Instana Inc. 2021
3
+
4
+ module Instana
5
+ module Activators
6
+ class Sinatra < Activator
7
+ def can_instrument?
8
+ defined?(::Instana::Rack) && defined?(::Sinatra)
9
+ end
10
+
11
+ def instrument
12
+ require 'instana/frameworks/sinatra'
13
+
14
+ ::Sinatra::Base.use ::Instana::Rack
15
+ ::Sinatra::Base.register ::Instana::SinatraPathTemplateExtractor
16
+
17
+ true
18
+ end
19
+ end
20
+ end
21
+ end
data/lib/instana/agent.rb CHANGED
@@ -1,3 +1,6 @@
1
+ # (c) Copyright IBM Corp. 2021
2
+ # (c) Copyright Instana Inc. 2016
3
+
1
4
  require 'net/http'
2
5
  require 'socket'
3
6
  require 'sys/proctable'
@@ -1,3 +1,6 @@
1
+ # (c) Copyright IBM Corp. 2021
2
+ # (c) Copyright Instana Inc. 2018
3
+
1
4
  module AgentHelpers
2
5
  # Attempts to determine if we're running inside a container.
3
6
  # The qualifications are:
@@ -1,3 +1,6 @@
1
+ # (c) Copyright IBM Corp. 2021
2
+ # (c) Copyright Instana Inc. 2018
3
+
1
4
  module AgentHooks
2
5
  # Used post fork to re-initialize state and restart communications with
3
6
  # the host agent.
@@ -1,3 +1,6 @@
1
+ # (c) Copyright IBM Corp. 2021
2
+ # (c) Copyright Instana Inc. 2018
3
+
1
4
  module AgentTasks
2
5
  # When request(s) are received by the host agent, it is sent here
3
6
  # for handling & processing.
data/lib/instana/base.rb CHANGED
@@ -1,3 +1,6 @@
1
+ # (c) Copyright IBM Corp. 2021
2
+ # (c) Copyright Instana Inc. 2016
3
+
1
4
  require "logger"
2
5
  require "instana/version"
3
6
  require "instana/util"
@@ -1,3 +1,6 @@
1
+ # (c) Copyright IBM Corp. 2021
2
+ # (c) Copyright Instana Inc. 2016
3
+
1
4
  module Instana
2
5
  class Collector
3
6
  attr_accessor :collectors
@@ -1,3 +1,6 @@
1
+ # (c) Copyright IBM Corp. 2021
2
+ # (c) Copyright Instana Inc. 2016
3
+
1
4
  module Instana
2
5
  module Collectors
3
6
  class GC
@@ -1,3 +1,6 @@
1
+ # (c) Copyright IBM Corp. 2021
2
+ # (c) Copyright Instana Inc. 2016
3
+
1
4
  require 'get_process_mem'
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 Collectors
3
6
  class Thread
@@ -1,3 +1,6 @@
1
+ # (c) Copyright IBM Corp. 2021
2
+ # (c) Copyright Instana Inc. 2016
3
+
1
4
  module Instana
2
5
  class Config
3
6
 
@@ -1,25 +1,28 @@
1
+ # (c) Copyright IBM Corp. 2021
2
+ # (c) Copyright Instana Inc. 2016
3
+
1
4
  require "instana/rack"
2
5
 
3
6
  module Instana
4
7
  module CubaPathTemplateExtractor
5
8
  REPLACE_TARGET = /:(?<term>[^\/]+)/i
6
-
9
+
7
10
  def self.prepended(base)
8
11
  ::Instana.logger.debug "#{base} prepended #{self}"
9
12
  end
10
-
11
- def on(*args, &blk)
13
+
14
+ def on(*args, &blk)
12
15
  wrapper = lambda do |*caputres|
13
16
  env['INSTANA_PATH_TEMPLATE_FRAGMENTS'] << args
14
17
  .select { |a| a.is_a?(String) }
15
18
  .join('/')
16
-
19
+
17
20
  blk.call(*captures)
18
21
  end
19
-
22
+
20
23
  super(*args, &wrapper)
21
24
  end
22
-
25
+
23
26
  def call!(env)
24
27
  env['INSTANA_PATH_TEMPLATE_FRAGMENTS'] = []
25
28
  response = super(env)
@@ -30,10 +33,3 @@ module Instana
30
33
  end
31
34
  end
32
35
  end
33
-
34
-
35
- if defined?(::Cuba)
36
- ::Instana.logger.debug "Instrumenting Cuba"
37
- Cuba.use ::Instana::Rack
38
- Cuba.prepend ::Instana::CubaPathTemplateExtractor
39
- end
@@ -1,40 +1,30 @@
1
- require "instana/rack"
1
+ # (c) Copyright IBM Corp. 2021
2
+ # (c) Copyright Instana Inc. 2016
2
3
 
3
- if defined?(::Rails)
4
+ if ::Rails::VERSION::MAJOR < 3
5
+ ::Rails.configuration.after_initialize do
6
+ # In Rails, let's use the Rails logger
7
+ ::Instana.logger = ::Rails.logger if ::Rails.logger
4
8
 
5
- if ::Rails::VERSION::MAJOR < 3
6
- ::Rails.configuration.after_initialize do
7
- # In Rails, let's use the Rails logger
8
- ::Instana.logger = ::Rails.logger if ::Rails.logger
9
-
10
- if ::Instana.config[:tracing][:enabled]
11
- ::Instana.logger.debug "Instrumenting Rack"
12
- ::Rails.configuration.middleware.insert 0, ::Instana::Rack
13
- else
14
- ::Instana.logger.info "Rack: Tracing disabled via config. Not enabling middleware."
15
- end
9
+ if ::Instana.config[:tracing][:enabled]
10
+ ::Instana.logger.debug "Instrumenting Rack"
11
+ ::Rails.configuration.middleware.insert 0, ::Instana::Rack
12
+ else
13
+ ::Instana.logger.info "Rack: Tracing disabled via config. Not enabling middleware."
16
14
  end
17
- else
18
- module ::Instana
19
- class Railtie < ::Rails::Railtie
20
- initializer 'instana.rack' do |app|
21
- # In Rails, let's use the Rails logger
22
- ::Instana.logger = ::Rails.logger if ::Rails.logger
23
-
24
- if ::Instana.config[:tracing][:enabled]
25
- ::Instana.logger.debug "Instrumenting Rack"
26
- app.config.middleware.insert 0, ::Instana::Rack
27
- else
28
- ::Instana.logger.info "Rack: Tracing disabled via config. Not enabling middleware."
29
- end
30
- end
15
+ end
16
+ else
17
+ module ::Instana
18
+ class Railtie < ::Rails::Railtie
19
+ initializer 'instana.rack' do |app|
20
+ # In Rails, let's use the Rails logger
21
+ ::Instana.logger = ::Rails.logger if ::Rails.logger
31
22
 
32
23
  if ::Instana.config[:tracing][:enabled]
33
- config.after_initialize do
34
- require "instana/frameworks/instrumentation/active_record"
35
- require "instana/frameworks/instrumentation/action_controller"
36
- require "instana/frameworks/instrumentation/action_view"
37
- end
24
+ ::Instana.logger.debug "Instrumenting Rack"
25
+ app.config.middleware.insert 0, ::Instana::Rack
26
+ else
27
+ ::Instana.logger.info "Rack: Tracing disabled via config. Not enabling middleware."
38
28
  end
39
29
  end
40
30
  end
@@ -1,14 +1,17 @@
1
+ # (c) Copyright IBM Corp. 2021
2
+ # (c) Copyright Instana Inc. 2016
3
+
1
4
  require "instana/rack"
2
5
 
3
6
  module Instana
4
7
  module RodaPathTemplateExtractor
5
8
  module RequestMethods
6
9
  TERM = defined?(::Roda) ? ::Roda::RodaPlugins::Base::RequestMethods::TERM : Object
7
-
10
+
8
11
  def if_match(args, &blk)
9
12
  path = @remaining_path
10
13
  captures = @captures.clear
11
-
14
+
12
15
  if match_all(args)
13
16
  (env['INSTANA_PATH_TEMPLATE_FRAGMENTS'] ||= []).concat(named_args(args, blk))
14
17
  block_result(blk.(*captures))
@@ -21,10 +24,10 @@ module Instana
21
24
  false
22
25
  end
23
26
  end
24
-
25
- def named_args(args, blk)
26
- parameters = blk.parameters
27
- args.map do |a|
27
+
28
+ def named_args(args, blk)
29
+ parameters = blk.parameters
30
+ args.map do |a|
28
31
  case a
29
32
  when String
30
33
  a
@@ -35,13 +38,7 @@ module Instana
35
38
  "{#{name}}"
36
39
  end
37
40
  end.compact
38
- end
41
+ end
39
42
  end
40
43
  end
41
44
  end
42
-
43
- if defined?(::Roda)
44
- ::Instana.logger.debug "Instrumenting Roda"
45
- Roda.use ::Instana::Rack
46
- Roda.plugin ::Instana::RodaPathTemplateExtractor
47
- end
@@ -1,3 +1,6 @@
1
+ # (c) Copyright IBM Corp. 2021
2
+ # (c) Copyright Instana Inc. 2016
3
+
1
4
  require "instana/rack"
2
5
 
3
6
  # This instrumentation will insert Rack into Sinatra _and_ Padrino since
@@ -6,10 +9,9 @@ require "instana/rack"
6
9
  module Instana
7
10
  module SinatraPathTemplateExtractor
8
11
  def self.extended(base)
9
- ::Instana.logger.debug "#{base} extended #{self}"
10
12
  base.store_path_template
11
13
  end
12
-
14
+
13
15
  def store_path_template
14
16
  after do
15
17
  @env["INSTANA_HTTP_PATH_TEMPLATE"] = @env["sinatra.route"]
@@ -18,9 +20,3 @@ module Instana
18
20
  end
19
21
  end
20
22
  end
21
-
22
- if defined?(::Sinatra)
23
- ::Instana.logger.debug "Instrumenting Sinatra"
24
- ::Sinatra::Base.use ::Instana::Rack
25
- ::Sinatra::Base.register ::Instana::SinatraPathTemplateExtractor
26
- 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 Helpers
3
6
  EUM_SNIPPET= (File.read(File.dirname(__FILE__) + '/eum/eum.js.erb')).freeze
@@ -0,0 +1,53 @@
1
+ # (c) Copyright IBM Corp. 2021
2
+ # (c) Copyright Instana Inc. 2021
3
+
4
+ module Instana
5
+ module Instrumentation
6
+ module ActionCableConnection
7
+ def instana_trace_context
8
+ @instana_trace_context
9
+ end
10
+
11
+ def process
12
+ @instana_trace_context ||= ::Instana.tracer.tracing? ? ::Instana.tracer.current_span.context : {}
13
+ super
14
+ end
15
+ end
16
+
17
+ module ActionCableChannel
18
+ def transmit(*args)
19
+ rpc_tags = {
20
+ service: ::Instana::Util.get_app_name,
21
+ rpc: {
22
+ flavor: :actioncable,
23
+ call: self.class.to_s,
24
+ call_type: :transmit,
25
+ host: Socket.gethostname
26
+ }
27
+ }
28
+
29
+ context = connection.instana_trace_context
30
+ ::Instana.tracer.start_or_continue_trace(:'rpc-server', rpc_tags, context) do
31
+ super(*args)
32
+ end
33
+ end
34
+
35
+ def dispatch_action(action, data)
36
+ rpc_tags = {
37
+ service: ::Instana::Util.get_app_name,
38
+ rpc: {
39
+ flavor: :actioncable,
40
+ call: "#{self.class}##{action}",
41
+ call_type: :action,
42
+ host: Socket.gethostname
43
+ }
44
+ }
45
+
46
+ context = connection.instana_trace_context
47
+ ::Instana.tracer.start_or_continue_trace(:'rpc-server', rpc_tags, context) do
48
+ super(action, data)
49
+ end
50
+ end
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,84 @@
1
+ # (c) Copyright IBM Corp. 2021
2
+ # (c) Copyright Instana Inc. 2021
3
+
4
+ module Instana
5
+ module Instrumentation
6
+ module ActionController
7
+ def process_action(*args)
8
+ call_payload = {
9
+ actioncontroller: {
10
+ controller: self.class.name,
11
+ action: action_name
12
+ }
13
+ }
14
+
15
+ request.env['INSTANA_HTTP_PATH_TEMPLATE'] = matched_path_template
16
+ ::Instana::Tracer.trace(:actioncontroller, call_payload) { super(*args) }
17
+ end
18
+
19
+ def render(*args, &block)
20
+ call_payload = {
21
+ actionview: {
22
+ name: describe_render_options(args.first) || 'Default'
23
+ }
24
+ }
25
+
26
+ ::Instana::Tracer.trace(:actionview, call_payload) { super(*args, &block) }
27
+ end
28
+
29
+ private
30
+
31
+ def matched_path_template
32
+ Rails.application.routes.router.recognize(request) do |route, _, _|
33
+ path = route.path
34
+ return path.spec.to_s
35
+ end
36
+
37
+ nil
38
+ end
39
+
40
+ def describe_render_options(options)
41
+ return unless options.is_a?(Hash)
42
+
43
+ describe_layout(options[:layout]) ||
44
+ describe_direct(options)
45
+ end
46
+
47
+ def describe_layout(layout)
48
+ return unless layout
49
+
50
+ case layout
51
+ when FalseClass
52
+ 'Without layout'
53
+ when String
54
+ layout
55
+ when Proc
56
+ 'Proc'
57
+ else
58
+ 'Default'
59
+ end
60
+ end
61
+
62
+ def describe_direct(options)
63
+ case options
64
+ when ->(o) { o.key?(:nothing) }
65
+ 'Nothing'
66
+ when ->(o) { o.key?(:plain) }
67
+ 'Plaintext'
68
+ when ->(o) { o.key?(:json) }
69
+ 'JSON'
70
+ when ->(o) { o.key?(:xml) }
71
+ 'XML'
72
+ when ->(o) { o.key?(:body) }
73
+ 'Raw'
74
+ when ->(o) { o.key?(:js) }
75
+ 'Javascript'
76
+ when ->(o) { o.key?(:template) }
77
+ options[:template]
78
+ when ->(o) { o.key?(:file) }
79
+ options[:file]
80
+ end
81
+ end
82
+ end
83
+ end
84
+ end