instana 1.193.3.pre1 → 1.193.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +18 -12
- data/.gitignore +2 -1
- data/Appraisals +4 -0
- data/gemfiles/cuba_30.gemfile +1 -0
- data/gemfiles/dalli_20.gemfile +1 -0
- data/gemfiles/excon_02.gemfile +1 -0
- data/gemfiles/graphql_10.gemfile +1 -0
- data/gemfiles/grpc_10.gemfile +1 -0
- data/gemfiles/net_http_01.gemfile +1 -0
- data/gemfiles/rack_16.gemfile +1 -0
- data/gemfiles/rack_20.gemfile +1 -0
- data/gemfiles/rails_42.gemfile +2 -0
- data/gemfiles/rails_50.gemfile +2 -0
- data/gemfiles/rails_52.gemfile +2 -0
- data/gemfiles/rails_60.gemfile +2 -0
- data/gemfiles/redis_40.gemfile +1 -0
- data/gemfiles/resque_122.gemfile +1 -0
- data/gemfiles/resque_20.gemfile +1 -0
- data/gemfiles/rest_client_16.gemfile +1 -0
- data/gemfiles/rest_client_20.gemfile +1 -0
- data/gemfiles/roda_20.gemfile +1 -0
- data/gemfiles/roda_30.gemfile +1 -0
- data/gemfiles/sidekiq_42.gemfile +1 -0
- data/gemfiles/sidekiq_50.gemfile +1 -0
- data/gemfiles/sinatra_14.gemfile +1 -0
- data/lib/instana/activators/action_controller_api.rb +18 -0
- data/lib/instana/activators/action_controller_base.rb +18 -0
- data/lib/instana/activators/action_view.rb +18 -0
- data/lib/instana/activators/active_record.rb +18 -0
- data/lib/instana/frameworks/rails.rb +20 -32
- data/lib/instana/instrumentation/action_controller.rb +81 -0
- data/lib/instana/instrumentation/action_view.rb +27 -0
- data/lib/instana/instrumentation/active_record.rb +47 -0
- data/lib/instana/version.rb +1 -1
- data/test/{frameworks/rails/actioncontroller_test.rb → instrumentation/rails_action_controller_test.rb} +37 -21
- data/test/instrumentation/rails_action_view_test.rb +138 -0
- data/test/instrumentation/rails_active_record_test.rb +121 -0
- data/test/support/apps/active_record/active_record.rb +21 -0
- metadata +19 -23
- data/lib/instana/frameworks/instrumentation/abstract_mysql_adapter.rb +0 -56
- data/lib/instana/frameworks/instrumentation/action_controller.rb +0 -194
- data/lib/instana/frameworks/instrumentation/action_view.rb +0 -39
- data/lib/instana/frameworks/instrumentation/active_record.rb +0 -27
- data/lib/instana/frameworks/instrumentation/mysql2_adapter.rb +0 -83
- data/lib/instana/frameworks/instrumentation/mysql_adapter.rb +0 -60
- data/lib/instana/frameworks/instrumentation/postgresql_adapter.rb +0 -99
- data/test/frameworks/rails/actionview3_test.rb +0 -210
- data/test/frameworks/rails/actionview4_test.rb +0 -208
- data/test/frameworks/rails/actionview5_test.rb +0 -221
- data/test/frameworks/rails/activerecord_test.rb +0 -279
- data/test/frameworks/rails_test.rb +0 -15
@@ -0,0 +1,121 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
require 'support/apps/active_record/active_record'
|
3
|
+
|
4
|
+
require 'irb'
|
5
|
+
|
6
|
+
class RailsActiveRecordTest < Minitest::Test
|
7
|
+
def setup
|
8
|
+
skip unless ENV['DATABASE_URL']
|
9
|
+
@connection = ActiveRecord::Base.establish_connection(ENV['DATABASE_URL'])
|
10
|
+
ActiveRecord::Migration.suppress_messages do
|
11
|
+
ActiveRecord::Migration.run(CreateBlocks, direction: :up)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def teardown
|
16
|
+
ActiveRecord::Migration.suppress_messages do
|
17
|
+
ActiveRecord::Migration.run(CreateBlocks, direction: :down)
|
18
|
+
end
|
19
|
+
ActiveRecord::Base.remove_connection(@connection)
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_config_defaults
|
23
|
+
assert ::Instana.config[:sanitize_sql] == true
|
24
|
+
assert ::Instana.config[:active_record].is_a?(Hash)
|
25
|
+
assert ::Instana.config[:active_record].key?(:enabled)
|
26
|
+
assert_equal true, ::Instana.config[:active_record][:enabled]
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_create
|
30
|
+
Instana::Tracer.start_or_continue_trace(:ar_test, {}) do
|
31
|
+
Block.create(name: 'core', color: 'blue')
|
32
|
+
end
|
33
|
+
|
34
|
+
spans = ::Instana.processor.queued_spans
|
35
|
+
assert_equal 2, spans.length
|
36
|
+
span = find_first_span_by_name(spans, :activerecord)
|
37
|
+
data = span[:data][:activerecord]
|
38
|
+
|
39
|
+
assert data[:sql].start_with?('INSERT INTO')
|
40
|
+
assert 'core', data[:binds][0]
|
41
|
+
assert 'blue', data[:binds][1]
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_read
|
45
|
+
Block.create(name: 'core', color: 'blue')
|
46
|
+
Instana::Tracer.start_or_continue_trace(:ar_test, {}) do
|
47
|
+
Block.find_by(name: 'core')
|
48
|
+
end
|
49
|
+
|
50
|
+
spans = ::Instana.processor.queued_spans
|
51
|
+
assert_equal 2, spans.length
|
52
|
+
span = find_first_span_by_name(spans, :activerecord)
|
53
|
+
data = span[:data][:activerecord]
|
54
|
+
|
55
|
+
assert data[:sql].start_with?('SELECT')
|
56
|
+
assert 'core', data[:binds][0]
|
57
|
+
assert 1, data[:binds][1]
|
58
|
+
end
|
59
|
+
|
60
|
+
def test_update
|
61
|
+
Block.create(name: 'core', color: 'blue')
|
62
|
+
b = Block.find_by(name: 'core')
|
63
|
+
|
64
|
+
Instana::Tracer.start_or_continue_trace(:ar_test, {}) do
|
65
|
+
b.color = 'red'
|
66
|
+
b.save
|
67
|
+
end
|
68
|
+
|
69
|
+
spans = ::Instana.processor.queued_spans
|
70
|
+
assert_equal 2, spans.length
|
71
|
+
span = find_first_span_by_name(spans, :activerecord)
|
72
|
+
data = span[:data][:activerecord]
|
73
|
+
|
74
|
+
assert data[:sql].start_with?('UPDATE')
|
75
|
+
assert 'red', data[:binds][0]
|
76
|
+
assert 1, data[:binds][2]
|
77
|
+
end
|
78
|
+
|
79
|
+
def test_delete
|
80
|
+
b = Block.create(name: 'core', color: 'blue')
|
81
|
+
|
82
|
+
Instana::Tracer.start_or_continue_trace(:ar_test, {}) do
|
83
|
+
b.delete
|
84
|
+
end
|
85
|
+
|
86
|
+
spans = ::Instana.processor.queued_spans
|
87
|
+
assert_equal 2, spans.length
|
88
|
+
span = find_first_span_by_name(spans, :activerecord)
|
89
|
+
data = span[:data][:activerecord]
|
90
|
+
|
91
|
+
assert data[:sql].start_with?('DELETE')
|
92
|
+
assert 1, data[:binds][0]
|
93
|
+
end
|
94
|
+
|
95
|
+
def test_raw
|
96
|
+
Instana::Tracer.start_or_continue_trace(:ar_test, {}) do
|
97
|
+
ActiveRecord::Base.connection.execute('SELECT 1')
|
98
|
+
end
|
99
|
+
|
100
|
+
spans = ::Instana.processor.queued_spans
|
101
|
+
assert_equal 2, spans.length
|
102
|
+
span = find_first_span_by_name(spans, :activerecord)
|
103
|
+
data = span[:data][:activerecord]
|
104
|
+
|
105
|
+
assert 'SELECT 1', data[:sql]
|
106
|
+
end
|
107
|
+
|
108
|
+
def test_raw_error
|
109
|
+
assert_raises ActiveRecord::StatementInvalid do
|
110
|
+
Instana::Tracer.start_or_continue_trace(:ar_test, {}) do
|
111
|
+
ActiveRecord::Base.connection.execute('INVALID')
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
spans = ::Instana.processor.queued_spans
|
116
|
+
assert_equal 2, spans.length
|
117
|
+
span = find_first_span_by_name(spans, :activerecord)
|
118
|
+
|
119
|
+
assert_equal 1, span[:ec]
|
120
|
+
end
|
121
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'rails'
|
2
|
+
require 'active_record/railtie'
|
3
|
+
|
4
|
+
migration_class = if ActiveRecord::Migration.respond_to?(:[])
|
5
|
+
ActiveRecord::Migration[4.2]
|
6
|
+
else
|
7
|
+
ActiveRecord::Migration
|
8
|
+
end
|
9
|
+
|
10
|
+
class CreateBlocks < migration_class
|
11
|
+
def change
|
12
|
+
create_table :blocks do |t|
|
13
|
+
t.string :name
|
14
|
+
t.string :color
|
15
|
+
t.timestamps
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
class Block < ActiveRecord::Base
|
21
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: instana
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.193.3
|
4
|
+
version: 1.193.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Peter Giacomo Lombardo
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-02-
|
11
|
+
date: 2021-02-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -196,6 +196,10 @@ files:
|
|
196
196
|
- instana.gemspec
|
197
197
|
- lib/instana.rb
|
198
198
|
- lib/instana/activator.rb
|
199
|
+
- lib/instana/activators/action_controller_api.rb
|
200
|
+
- lib/instana/activators/action_controller_base.rb
|
201
|
+
- lib/instana/activators/action_view.rb
|
202
|
+
- lib/instana/activators/active_record.rb
|
199
203
|
- lib/instana/activators/cuba.rb
|
200
204
|
- lib/instana/activators/dalli.rb
|
201
205
|
- lib/instana/activators/excon.rb
|
@@ -226,17 +230,13 @@ files:
|
|
226
230
|
- lib/instana/eum/eum-test.js.erb
|
227
231
|
- lib/instana/eum/eum.js.erb
|
228
232
|
- lib/instana/frameworks/cuba.rb
|
229
|
-
- lib/instana/frameworks/instrumentation/abstract_mysql_adapter.rb
|
230
|
-
- lib/instana/frameworks/instrumentation/action_controller.rb
|
231
|
-
- lib/instana/frameworks/instrumentation/action_view.rb
|
232
|
-
- lib/instana/frameworks/instrumentation/active_record.rb
|
233
|
-
- lib/instana/frameworks/instrumentation/mysql2_adapter.rb
|
234
|
-
- lib/instana/frameworks/instrumentation/mysql_adapter.rb
|
235
|
-
- lib/instana/frameworks/instrumentation/postgresql_adapter.rb
|
236
233
|
- lib/instana/frameworks/rails.rb
|
237
234
|
- lib/instana/frameworks/roda.rb
|
238
235
|
- lib/instana/frameworks/sinatra.rb
|
239
236
|
- lib/instana/helpers.rb
|
237
|
+
- lib/instana/instrumentation/action_controller.rb
|
238
|
+
- lib/instana/instrumentation/action_view.rb
|
239
|
+
- lib/instana/instrumentation/active_record.rb
|
240
240
|
- lib/instana/instrumentation/dalli.rb
|
241
241
|
- lib/instana/instrumentation/excon.rb
|
242
242
|
- lib/instana/instrumentation/graphql.rb
|
@@ -270,12 +270,6 @@ files:
|
|
270
270
|
- test/benchmarks/bench_opentracing.rb
|
271
271
|
- test/config_test.rb
|
272
272
|
- test/frameworks/cuba_test.rb
|
273
|
-
- test/frameworks/rails/actioncontroller_test.rb
|
274
|
-
- test/frameworks/rails/actionview3_test.rb
|
275
|
-
- test/frameworks/rails/actionview4_test.rb
|
276
|
-
- test/frameworks/rails/actionview5_test.rb
|
277
|
-
- test/frameworks/rails/activerecord_test.rb
|
278
|
-
- test/frameworks/rails_test.rb
|
279
273
|
- test/frameworks/roda_test.rb
|
280
274
|
- test/frameworks/sinatra_test.rb
|
281
275
|
- test/instana_test.rb
|
@@ -286,12 +280,16 @@ files:
|
|
286
280
|
- test/instrumentation/net_http_test.rb
|
287
281
|
- test/instrumentation/rack_instrumented_request_test.rb
|
288
282
|
- test/instrumentation/rack_test.rb
|
283
|
+
- test/instrumentation/rails_action_controller_test.rb
|
284
|
+
- test/instrumentation/rails_action_view_test.rb
|
285
|
+
- test/instrumentation/rails_active_record_test.rb
|
289
286
|
- test/instrumentation/redis_test.rb
|
290
287
|
- test/instrumentation/resque_test.rb
|
291
288
|
- test/instrumentation/rest_client_test.rb
|
292
289
|
- test/instrumentation/sidekiq-client_test.rb
|
293
290
|
- test/instrumentation/sidekiq-worker_test.rb
|
294
291
|
- test/secrets_test.rb
|
292
|
+
- test/support/apps/active_record/active_record.rb
|
295
293
|
- test/support/apps/grpc/boot.rb
|
296
294
|
- test/support/apps/grpc/grpc_server.rb
|
297
295
|
- test/support/apps/http_endpoint/boot.rb
|
@@ -331,9 +329,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
331
329
|
version: '2.1'
|
332
330
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
333
331
|
requirements:
|
334
|
-
- - "
|
332
|
+
- - ">="
|
335
333
|
- !ruby/object:Gem::Version
|
336
|
-
version:
|
334
|
+
version: '0'
|
337
335
|
requirements: []
|
338
336
|
rubygems_version: 3.2.6
|
339
337
|
signing_key:
|
@@ -351,12 +349,15 @@ test_files:
|
|
351
349
|
- test/secrets_test.rb
|
352
350
|
- test/instrumentation/graphql_test.rb
|
353
351
|
- test/instrumentation/sidekiq-client_test.rb
|
352
|
+
- test/instrumentation/rails_action_controller_test.rb
|
354
353
|
- test/instrumentation/rest_client_test.rb
|
355
354
|
- test/instrumentation/net_http_test.rb
|
356
355
|
- test/instrumentation/resque_test.rb
|
357
356
|
- test/instrumentation/sidekiq-worker_test.rb
|
357
|
+
- test/instrumentation/rails_action_view_test.rb
|
358
358
|
- test/instrumentation/rack_test.rb
|
359
359
|
- test/instrumentation/rack_instrumented_request_test.rb
|
360
|
+
- test/instrumentation/rails_active_record_test.rb
|
360
361
|
- test/instrumentation/redis_test.rb
|
361
362
|
- test/instrumentation/dalli_test.rb
|
362
363
|
- test/instrumentation/excon_test.rb
|
@@ -368,6 +369,7 @@ test_files:
|
|
368
369
|
- test/support/apps/sidekiq/worker.rb
|
369
370
|
- test/support/apps/grpc/boot.rb
|
370
371
|
- test/support/apps/grpc/grpc_server.rb
|
372
|
+
- test/support/apps/active_record/active_record.rb
|
371
373
|
- test/support/apps/resque/boot.rb
|
372
374
|
- test/support/apps/resque/jobs/resque_error_job.rb
|
373
375
|
- test/support/apps/resque/jobs/resque_fast_job.rb
|
@@ -380,11 +382,5 @@ test_files:
|
|
380
382
|
- test/test_helper.rb
|
381
383
|
- test/frameworks/cuba_test.rb
|
382
384
|
- test/frameworks/roda_test.rb
|
383
|
-
- test/frameworks/rails_test.rb
|
384
385
|
- test/frameworks/sinatra_test.rb
|
385
|
-
- test/frameworks/rails/actionview4_test.rb
|
386
|
-
- test/frameworks/rails/activerecord_test.rb
|
387
|
-
- test/frameworks/rails/actioncontroller_test.rb
|
388
|
-
- test/frameworks/rails/actionview5_test.rb
|
389
|
-
- test/frameworks/rails/actionview3_test.rb
|
390
386
|
- test/instana_test.rb
|
@@ -1,56 +0,0 @@
|
|
1
|
-
module Instana
|
2
|
-
module Instrumentation
|
3
|
-
module AbstractMysqlAdapter
|
4
|
-
IGNORED_PAYLOADS = %w(SCHEMA EXPLAIN CACHE).freeze
|
5
|
-
EXPLAINED_SQLS = /\A\s*(with|select|update|delete|insert)\b/i
|
6
|
-
|
7
|
-
# This module supports instrumenting ActiveRecord with the mysql2 adapter.
|
8
|
-
#
|
9
|
-
def self.prepended(klass)
|
10
|
-
if ActiveRecord::VERSION::STRING >= '3.2'
|
11
|
-
@@sanitize_regexp = Regexp.new('(\'[\s\S][^\']*\'|\d*\.\d+|\d+|NULL)', Regexp::IGNORECASE)
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
# Collect up this DB connection info for reporting.
|
16
|
-
#
|
17
|
-
# @param sql [String]
|
18
|
-
# @return [Hash] Hash of collected KVs
|
19
|
-
#
|
20
|
-
def collect(sql)
|
21
|
-
payload = { :activerecord => {} }
|
22
|
-
payload[:activerecord][:sql] = sql.gsub(@@sanitize_regexp, '?')
|
23
|
-
payload[:activerecord][:adapter] = @config[:adapter]
|
24
|
-
payload[:activerecord][:host] = @config[:host]
|
25
|
-
payload[:activerecord][:db] = @config[:database]
|
26
|
-
payload[:activerecord][:username] = @config[:username]
|
27
|
-
payload
|
28
|
-
end
|
29
|
-
|
30
|
-
# In the spirit of ::ActiveRecord::ExplainSubscriber.ignore_payload? There are
|
31
|
-
# only certain calls that we're interested in tracing. e.g. No use to instrument
|
32
|
-
# framework caches.
|
33
|
-
#
|
34
|
-
# @param payload [String]
|
35
|
-
# @return [Boolean]
|
36
|
-
#
|
37
|
-
def ignore_payload?(name, sql)
|
38
|
-
IGNORED_PAYLOADS.include?(name) || sql !~ EXPLAINED_SQLS
|
39
|
-
end
|
40
|
-
|
41
|
-
def execute(sql, name = nil)
|
42
|
-
tracing = ::Instana.tracer.tracing?
|
43
|
-
if !tracing || ignore_payload?(name, sql)
|
44
|
-
return super(sql, name)
|
45
|
-
elsif ::Instana.tracer.current_span[:n] == :activerecord
|
46
|
-
return super(sql, name)
|
47
|
-
end
|
48
|
-
|
49
|
-
kv_payload = collect(sql)
|
50
|
-
::Instana.tracer.trace(:activerecord, kv_payload) do
|
51
|
-
super(sql, name)
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
@@ -1,194 +0,0 @@
|
|
1
|
-
module Instana
|
2
|
-
module Instrumentation
|
3
|
-
|
4
|
-
# Contains the methods common to both ::Instana::Instrumentation::ActionController
|
5
|
-
# and ::Instana::Instrumentation::ActionControllerLegacy
|
6
|
-
#
|
7
|
-
module ActionControllerCommon
|
8
|
-
|
9
|
-
# Indicates whether a Controller rescue handler is in place. If so, this affects
|
10
|
-
# error logging and reporting. (Hence the need for this method).
|
11
|
-
#
|
12
|
-
# @return [Boolean]
|
13
|
-
#
|
14
|
-
def has_rails_handler?(exception)
|
15
|
-
found = false
|
16
|
-
rescue_handlers.detect do |klass_name, _handler|
|
17
|
-
# Rescue handlers can be specified as strings or constant names
|
18
|
-
klass = self.class.const_get(klass_name) rescue nil
|
19
|
-
klass ||= klass_name.constantize rescue nil
|
20
|
-
found = exception.is_a?(klass) if klass
|
21
|
-
end
|
22
|
-
found
|
23
|
-
rescue => e
|
24
|
-
::Instana.logger.debug { "#{__method__}:#{File.basename(__FILE__)}:#{__LINE__}: #{e.message}" }
|
25
|
-
return false
|
26
|
-
end
|
27
|
-
|
28
|
-
# Render can be called with many options across the various supported
|
29
|
-
# versions of Rails. This method attempts to make sense and provide
|
30
|
-
# insight into what is happening (rendering a layout, file, nothing,
|
31
|
-
# plaintext etc.)
|
32
|
-
def get_render_topic(opts)
|
33
|
-
if opts.key?(:layout)
|
34
|
-
case opts[:layout]
|
35
|
-
when FalseClass
|
36
|
-
name = "Without layout"
|
37
|
-
when String
|
38
|
-
name = opts[:layout]
|
39
|
-
when Proc
|
40
|
-
name = "Proc"
|
41
|
-
else
|
42
|
-
name = "Default"
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
return name if name
|
47
|
-
|
48
|
-
if opts.key?(:template)
|
49
|
-
name ||= opts[:template]
|
50
|
-
elsif opts.key?(:file)
|
51
|
-
name ||= opts[:file]
|
52
|
-
elsif opts.key?(:nothing)
|
53
|
-
name = "Nothing"
|
54
|
-
elsif opts.key?(:plain)
|
55
|
-
name = "Plaintext"
|
56
|
-
elsif opts.key?(:json)
|
57
|
-
name = "JSON"
|
58
|
-
elsif opts.key?(:xml)
|
59
|
-
name = "XML"
|
60
|
-
elsif opts.key?(:body)
|
61
|
-
name = "Raw"
|
62
|
-
elsif opts.key?(:js)
|
63
|
-
name = "Javascript"
|
64
|
-
end
|
65
|
-
name
|
66
|
-
end
|
67
|
-
|
68
|
-
def matched_path_template
|
69
|
-
Rails.application.routes.router.recognize(request) do |route, _, _|
|
70
|
-
path = route.path
|
71
|
-
return path.spec.to_s
|
72
|
-
end
|
73
|
-
|
74
|
-
nil
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
# Used in ActionPack versions 5 and beyond, this module provides
|
79
|
-
# instrumentation for ActionController (a part of ActionPack)
|
80
|
-
#
|
81
|
-
module ActionController
|
82
|
-
include ::Instana::Instrumentation::ActionControllerCommon
|
83
|
-
|
84
|
-
# This is the Rails 5 version of the process_action method where we use prepend to
|
85
|
-
# instrument the class method instead of using the older alias_method_chain.
|
86
|
-
#
|
87
|
-
def process_action(*args)
|
88
|
-
kv_payload = { :actioncontroller => {} }
|
89
|
-
kv_payload[:actioncontroller][:controller] = self.class.name
|
90
|
-
kv_payload[:actioncontroller][:action] = action_name
|
91
|
-
|
92
|
-
::Instana.tracer.log_entry(:actioncontroller, kv_payload)
|
93
|
-
|
94
|
-
super(*args)
|
95
|
-
request.env['INSTANA_HTTP_PATH_TEMPLATE'] = matched_path_template
|
96
|
-
rescue Exception => e
|
97
|
-
::Instana.tracer.log_error(e) unless has_rails_handler?(e)
|
98
|
-
raise
|
99
|
-
ensure
|
100
|
-
::Instana.tracer.log_exit(:actioncontroller)
|
101
|
-
end
|
102
|
-
|
103
|
-
# The Instana wrapper method for ActionController::Base.render
|
104
|
-
# for versions 5+.
|
105
|
-
#
|
106
|
-
def render(*args, &blk)
|
107
|
-
# Figure out what's being rendered
|
108
|
-
if args.length > 0 && args[0].is_a?(Hash)
|
109
|
-
name = get_render_topic(args[0])
|
110
|
-
end
|
111
|
-
name ||= "Default"
|
112
|
-
|
113
|
-
::Instana.tracer.log_entry(:actionview, :actionview => { :name => name })
|
114
|
-
|
115
|
-
super(*args, &blk)
|
116
|
-
rescue Exception => e
|
117
|
-
::Instana.tracer.log_error(e) unless has_rails_handler?(e)
|
118
|
-
raise
|
119
|
-
ensure
|
120
|
-
::Instana.tracer.log_exit(:actionview)
|
121
|
-
end
|
122
|
-
end
|
123
|
-
|
124
|
-
# Used in ActionPack versions 4 and earlier, this module provides
|
125
|
-
# instrumentation for ActionController (a part of ActionPack)
|
126
|
-
#
|
127
|
-
module ActionControllerLegacy
|
128
|
-
include ::Instana::Instrumentation::ActionControllerCommon
|
129
|
-
|
130
|
-
def self.included(klass)
|
131
|
-
klass.class_eval do
|
132
|
-
alias_method_chain :process_action, :instana
|
133
|
-
alias_method_chain :render, :instana
|
134
|
-
end
|
135
|
-
end
|
136
|
-
|
137
|
-
# The Instana wrapper method for ActionController::Base.process_action
|
138
|
-
# for versions 3 and 4.
|
139
|
-
#
|
140
|
-
def process_action_with_instana(*args)
|
141
|
-
kv_payload = { :actioncontroller => {} }
|
142
|
-
kv_payload[:actioncontroller][:controller] = self.class.name
|
143
|
-
kv_payload[:actioncontroller][:action] = action_name
|
144
|
-
|
145
|
-
::Instana.tracer.log_entry(:actioncontroller, kv_payload)
|
146
|
-
|
147
|
-
process_action_without_instana(*args)
|
148
|
-
request.env['INSTANA_HTTP_PATH_TEMPLATE'] = matched_path_template
|
149
|
-
rescue Exception => e
|
150
|
-
::Instana.tracer.log_error(e) unless has_rails_handler?(e)
|
151
|
-
raise
|
152
|
-
ensure
|
153
|
-
::Instana.tracer.log_exit(:actioncontroller)
|
154
|
-
end
|
155
|
-
|
156
|
-
# The Instana wrapper method for ActionController::Base.render
|
157
|
-
# for versions 3 and 4.
|
158
|
-
#
|
159
|
-
def render_with_instana(*args, &blk)
|
160
|
-
if args.length > 0 && args[0].is_a?(Hash)
|
161
|
-
name = get_render_topic(args[0])
|
162
|
-
end
|
163
|
-
name ||= "Default"
|
164
|
-
::Instana.tracer.log_entry(:actionview, :actionview => { :name => name })
|
165
|
-
render_without_instana(*args, &blk)
|
166
|
-
rescue Exception => e
|
167
|
-
::Instana.tracer.log_error(e) unless has_rails_handler?(e)
|
168
|
-
raise
|
169
|
-
ensure
|
170
|
-
::Instana.tracer.log_exit(:actionview)
|
171
|
-
end
|
172
|
-
end
|
173
|
-
end
|
174
|
-
end
|
175
|
-
|
176
|
-
if defined?(::ActionController) && ::Instana.config[:action_controller][:enabled] && ::ActionPack::VERSION::MAJOR >= 2
|
177
|
-
::Instana.logger.debug "Instrumenting ActionController"
|
178
|
-
if ActionPack::VERSION::MAJOR >= 5
|
179
|
-
::ActionController::Base.send(:prepend, ::Instana::Instrumentation::ActionController)
|
180
|
-
else
|
181
|
-
::ActionController::Base.send(:include, ::Instana::Instrumentation::ActionControllerLegacy)
|
182
|
-
end
|
183
|
-
end
|
184
|
-
|
185
|
-
# ActionController::API was introduced in Ruby on Rails 5 but was originally an independent project before being
|
186
|
-
# rolled into the Rails ActionPack. In case, someone is using the independent project or potentially backported
|
187
|
-
# the rails version to and older Ruby on Rails version, we only limit in a minimal way re: version checking.
|
188
|
-
#
|
189
|
-
# We allow ActionController::API instrumentation in version of Ruby on Rails 3 and higher.
|
190
|
-
#
|
191
|
-
if defined?(::ActionController::API) && ::Instana.config[:action_controller][:enabled] && ::ActionPack::VERSION::MAJOR >= 3
|
192
|
-
::Instana.logger.debug "Instrumenting ActionController API"
|
193
|
-
::ActionController::API.send(:prepend, ::Instana::Instrumentation::ActionController)
|
194
|
-
end
|