instana 1.11.8 → 1.193.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. checksums.yaml +4 -4
  2. data/.editorconfig +10 -0
  3. data/Rakefile +26 -37
  4. data/gemfiles/libraries.gemfile +2 -0
  5. data/lib/instana/agent.rb +6 -0
  6. data/lib/instana/base.rb +2 -0
  7. data/lib/instana/config.rb +11 -0
  8. data/lib/instana/frameworks/cuba.rb +33 -0
  9. data/lib/instana/frameworks/instrumentation/abstract_mysql_adapter.rb +5 -7
  10. data/lib/instana/frameworks/instrumentation/action_controller.rb +11 -0
  11. data/lib/instana/frameworks/instrumentation/action_view.rb +6 -10
  12. data/lib/instana/frameworks/instrumentation/active_record.rb +4 -4
  13. data/lib/instana/frameworks/instrumentation/mysql2_adapter.rb +17 -15
  14. data/lib/instana/frameworks/instrumentation/mysql_adapter.rb +11 -7
  15. data/lib/instana/frameworks/instrumentation/postgresql_adapter.rb +33 -19
  16. data/lib/instana/frameworks/roda.rb +41 -0
  17. data/lib/instana/frameworks/sinatra.rb +17 -0
  18. data/lib/instana/instrumentation/dalli.rb +9 -14
  19. data/lib/instana/instrumentation/excon.rb +1 -1
  20. data/lib/instana/instrumentation/graphql.rb +77 -0
  21. data/lib/instana/instrumentation/grpc.rb +72 -62
  22. data/lib/instana/instrumentation/instrumented_request.rb +68 -0
  23. data/lib/instana/instrumentation/net-http.rb +44 -43
  24. data/lib/instana/instrumentation/rack.rb +17 -52
  25. data/lib/instana/instrumentation/redis.rb +15 -18
  26. data/lib/instana/instrumentation/resque.rb +17 -28
  27. data/lib/instana/instrumentation/rest-client.rb +3 -13
  28. data/lib/instana/secrets.rb +42 -0
  29. data/lib/instana/setup.rb +1 -0
  30. data/lib/instana/tracer.rb +6 -0
  31. data/lib/instana/tracing/span.rb +14 -10
  32. data/lib/instana/util.rb +15 -69
  33. data/lib/instana/version.rb +1 -1
  34. data/test/apps/cuba.rb +4 -0
  35. data/test/apps/roda.rb +3 -0
  36. data/test/apps/sinatra.rb +4 -0
  37. data/test/config_test.rb +1 -17
  38. data/test/frameworks/cuba_test.rb +14 -1
  39. data/test/frameworks/rack_test.rb +52 -19
  40. data/test/frameworks/rails/actioncontroller_test.rb +12 -0
  41. data/test/frameworks/rails/activerecord_test.rb +80 -28
  42. data/test/frameworks/roda_test.rb +14 -0
  43. data/test/frameworks/sinatra_test.rb +14 -0
  44. data/test/instrumentation/excon_test.rb +0 -2
  45. data/test/instrumentation/graphql_test.rb +116 -0
  46. data/test/instrumentation/instrumented_request_test.rb +84 -0
  47. data/test/instrumentation/redis_test.rb +10 -0
  48. data/test/secrets_test.rb +73 -0
  49. data/test/test_helper.rb +3 -9
  50. data/test/tracing/id_management_test.rb +4 -66
  51. metadata +16 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 03473a7a2f7e8a5306869674ff671f1d5b66804e41bd1f687c512a33c0b07f3c
4
- data.tar.gz: aaf1ada0116589a5d33e1f74558a6c32801971e5f5f4e512be56ff6524ab447b
3
+ metadata.gz: 26ea11d0efe2f26610441700b71bc9c2abd4192566a86d00089d1e889d8457d3
4
+ data.tar.gz: 5dde944418b1f34391c08114692b4f34d27acc8328e0d7bd47c7b14834e21d61
5
5
  SHA512:
6
- metadata.gz: 6993a2dcb47b648445c97fea1017bcc9392f889270613078fd32fb2881365d88260ae0082e23eed6f32f9d111f67021dc9f2485f5cb4777b6317b7541352d40d
7
- data.tar.gz: 5c8c34a422def00edda43e613899a59b99bae6c1cf1323d79c135703b1c6ab5d565ece30f8b8f0497e0ea79a7cf1585912c17ddf5e8c363cb33f792e6f7a6903
6
+ metadata.gz: 11c700d01ab267b978d527dd9fcc993b5ae19bb659074690ced25b12f34d1b58c850c241776b3c8932a274138170d885e7f9a0c28b430bc382a81c0df3b99451
7
+ data.tar.gz: 8e4dd40a1d9f87e00905eca337189870f3e8237ce33b3be80853d85e7b11667243fe1e5ca7c6e126b492e0c2ba5d404257bfa908e50984f40d184a65f1067239
@@ -0,0 +1,10 @@
1
+ root = true
2
+
3
+ [*]
4
+ end_of_line = lf
5
+ insert_final_newline = true
6
+
7
+ [*.rb]
8
+ indent_style = space
9
+ indent_size = 2
10
+ trim_trailing_whitespace = true
data/Rakefile CHANGED
@@ -8,44 +8,33 @@ Rake::TestTask.new(:test) do |t|
8
8
 
9
9
  t.libs << "test"
10
10
  t.libs << "lib"
11
- t.test_files = FileList['test/**/*_test.rb']
12
-
13
- if ENV.key?('BUNDLE_GEMFILE')
14
- case File.basename(ENV['BUNDLE_GEMFILE']).split('.').first
15
- when /rails6/
16
- t.test_files = %w(test/frameworks/rails/activerecord_test.rb
17
- test/frameworks/rails/actioncontroller_test.rb
18
- test/frameworks/rails/actionview5_test.rb)
19
- when /rails5/
20
- t.test_files = %w(test/frameworks/rails/activerecord_test.rb
21
- test/frameworks/rails/actioncontroller_test.rb
22
- test/frameworks/rails/actionview5_test.rb)
23
- when /rails42/
24
- t.test_files = %w(test/frameworks/rails/activerecord_test.rb
25
- test/frameworks/rails/actioncontroller_test.rb
26
- test/frameworks/rails/actionview4_test.rb)
27
- when /rails32/
28
- t.test_files = %w(test/frameworks/rails/activerecord_test.rb
29
- test/frameworks/rails/actioncontroller_test.rb
30
- test/frameworks/rails/actionview3_test.rb)
31
- when /libraries/
32
- t.test_files = FileList['test/instrumentation/*_test.rb',
33
- 'test/frameworks/cuba_test.rb',
34
- 'test/frameworks/rack_test.rb',
35
- 'test/frameworks/roda_test.rb',
36
- 'test/frameworks/sinatra_test.rb']
37
- else
38
- t.test_files = FileList['test/agent/*_test.rb'] +
39
- FileList['test/tracing/*_test.rb'] +
40
- FileList['test/profiling/*_test.rb'] +
41
- FileList['test/benchmarks/bench_*.rb']
42
- end
43
- else
44
- t.test_files = FileList['test/agent/*_test.rb'] +
45
- FileList['test/tracing/*_test.rb'] +
46
- FileList['test/profiling/*_test.rb'] +
47
- FileList['test/benchmarks/bench_*.rb']
11
+
12
+ t.test_files = Dir[
13
+ 'test/*_test.rb',
14
+ 'test/{agent,tracing,profiling,benchmarks}/*_test.rb'
15
+ ]
16
+
17
+ case File.basename(ENV.fetch('BUNDLE_GEMFILE', '')).split('.').first
18
+ when /rails6/
19
+ t.test_files = %w(test/frameworks/rails/activerecord_test.rb
20
+ test/frameworks/rails/actioncontroller_test.rb
21
+ test/frameworks/rails/actionview5_test.rb)
22
+ when /rails5/
23
+ t.test_files = %w(test/frameworks/rails/activerecord_test.rb
24
+ test/frameworks/rails/actioncontroller_test.rb
25
+ test/frameworks/rails/actionview5_test.rb)
26
+ when /rails42/
27
+ t.test_files = %w(test/frameworks/rails/activerecord_test.rb
28
+ test/frameworks/rails/actioncontroller_test.rb
29
+ test/frameworks/rails/actionview4_test.rb)
30
+ when /rails32/
31
+ t.test_files = %w(test/frameworks/rails/activerecord_test.rb
32
+ test/frameworks/rails/actioncontroller_test.rb
33
+ test/frameworks/rails/actionview3_test.rb)
34
+ when /libraries/
35
+ t.test_files = Dir['test/{instrumentation,frameworks}/*_test.rb']
48
36
  end
37
+
49
38
  end
50
39
 
51
40
  task :environment do
@@ -65,6 +65,8 @@ if RUBY_VERSION < '2.2'
65
65
  gem 'rack', '< 2.0'
66
66
  end
67
67
 
68
+ gem 'graphql'
69
+
68
70
  # Include the Instana Ruby gem's base set of gems
69
71
  gemspec :path => File.expand_path(File.dirname(__FILE__) + '/../')
70
72
 
@@ -25,6 +25,7 @@ module Instana
25
25
  attr_accessor :collect_thread
26
26
  attr_accessor :thread_spawn_lock
27
27
  attr_accessor :extra_headers
28
+ attr_reader :secret_values
28
29
 
29
30
  attr_accessor :testmode
30
31
 
@@ -83,6 +84,10 @@ module Instana
83
84
 
84
85
  # The agent may pass down custom headers for this sensor to capture
85
86
  @extra_headers = nil
87
+
88
+ # The values considered sensitive and removed from http query parameters
89
+ # and database connection strings
90
+ @secret_values = nil
86
91
  end
87
92
 
88
93
  # Spawns the background thread and calls start. This method is separated
@@ -278,6 +283,7 @@ module Instana
278
283
  data = Oj.load(response.body, OJ_OPTIONS)
279
284
  @process[:report_pid] = data['pid']
280
285
  @agent_uuid = data['agentUuid']
286
+ @secret_values = data['secrets']
281
287
 
282
288
  if data.key?('extraHeaders')
283
289
  @extra_headers = data['extraHeaders']
@@ -12,6 +12,7 @@ module Instana
12
12
  attr_accessor :config
13
13
  attr_accessor :logger
14
14
  attr_accessor :pid
15
+ attr_reader :secrets
15
16
 
16
17
  ##
17
18
  # setup
@@ -24,6 +25,7 @@ module Instana
24
25
  @tracer = ::Instana::Tracer.new
25
26
  @processor = ::Instana::Processor.new
26
27
  @collector = ::Instana::Collector.new
28
+ @secrets = ::Instana::Secrets.new
27
29
  end
28
30
  end
29
31
  end
@@ -42,12 +42,23 @@ module Instana
42
42
  # ::Instana.config[:collect_backtraces] = true
43
43
  @config[:collect_backtraces] = false
44
44
 
45
+ # By default, collected SQL will be sanitized to remove potentially sensitive bind params such as:
46
+ # > SELECT "blocks".* FROM "blocks" WHERE "blocks"."name" = "Mr. Smith"
47
+ #
48
+ # ...would be sanitized to be:
49
+ # > SELECT "blocks".* FROM "blocks" WHERE "blocks"."name" = ?
50
+ #
51
+ # This sanitization step can be disabled by setting the following value to false.
52
+ # ::Instana.config[:sanitize_sql] = false
53
+ @config[:sanitize_sql] = true
54
+
45
55
  @config[:action_controller] = { :enabled => true }
46
56
  @config[:action_view] = { :enabled => true }
47
57
  @config[:active_record] = { :enabled => true }
48
58
  @config[:dalli] = { :enabled => true }
49
59
  @config[:excon] = { :enabled => true }
50
60
  @config[:grpc] = { :enabled => true }
61
+ @config[:graphql] = { :enabled => true }
51
62
  @config[:nethttp] = { :enabled => true }
52
63
  @config[:redis] = { :enabled => true }
53
64
  @config[:'resque-client'] = { :enabled => true }
@@ -1,6 +1,39 @@
1
1
  require "instana/rack"
2
2
 
3
+ module Instana
4
+ module CubaPathTemplateExtractor
5
+ REPLACE_TARGET = /:(?<term>[^\/]+)/i
6
+
7
+ def self.prepended(base)
8
+ ::Instana.logger.debug "#{base} prepended #{self}"
9
+ end
10
+
11
+ def on(*args, &blk)
12
+ wrapper = lambda do |*caputres|
13
+ env['INSTANA_PATH_TEMPLATE_FRAGMENTS'] << args
14
+ .select { |a| a.is_a?(String) }
15
+ .join('/')
16
+
17
+ blk.call(*captures)
18
+ end
19
+
20
+ super(*args, &wrapper)
21
+ end
22
+
23
+ def call!(env)
24
+ env['INSTANA_PATH_TEMPLATE_FRAGMENTS'] = []
25
+ response = super(env)
26
+ env['INSTANA_HTTP_PATH_TEMPLATE'] = env['INSTANA_PATH_TEMPLATE_FRAGMENTS']
27
+ .join('/')
28
+ .gsub(REPLACE_TARGET, '{\k<term>}')
29
+ response
30
+ end
31
+ end
32
+ end
33
+
34
+
3
35
  if defined?(::Cuba)
4
36
  ::Instana.logger.debug "Instrumenting Cuba"
5
37
  Cuba.use ::Instana::Rack
38
+ Cuba.prepend ::Instana::CubaPathTemplateExtractor
6
39
  end
@@ -6,10 +6,8 @@ module Instana
6
6
 
7
7
  # This module supports instrumenting ActiveRecord with the mysql2 adapter.
8
8
  #
9
- def self.included(klass)
9
+ def self.prepended(klass)
10
10
  if ActiveRecord::VERSION::STRING >= '3.2'
11
- Instana::Util.method_alias(klass, :execute)
12
-
13
11
  @@sanitize_regexp = Regexp.new('(\'[\s\S][^\']*\'|\d*\.\d+|\d+|NULL)', Regexp::IGNORECASE)
14
12
  end
15
13
  end
@@ -40,17 +38,17 @@ module Instana
40
38
  IGNORED_PAYLOADS.include?(name) || sql !~ EXPLAINED_SQLS
41
39
  end
42
40
 
43
- def execute_with_instana(sql, name = nil)
41
+ def execute(sql, name = nil)
44
42
  tracing = ::Instana.tracer.tracing?
45
43
  if !tracing || ignore_payload?(name, sql)
46
- return execute_without_instana(sql, name)
44
+ return super(sql, name)
47
45
  elsif ::Instana.tracer.current_span[:n] == :activerecord
48
- return execute_without_instana(sql, name)
46
+ return super(sql, name)
49
47
  end
50
48
 
51
49
  kv_payload = collect(sql)
52
50
  ::Instana.tracer.trace(:activerecord, kv_payload) do
53
- execute_without_instana(sql, name)
51
+ super(sql, name)
54
52
  end
55
53
  end
56
54
  end
@@ -64,6 +64,15 @@ module Instana
64
64
  end
65
65
  name
66
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
67
76
  end
68
77
 
69
78
  # Used in ActionPack versions 5 and beyond, this module provides
@@ -83,6 +92,7 @@ module Instana
83
92
  ::Instana.tracer.log_entry(:actioncontroller, kv_payload)
84
93
 
85
94
  super(*args)
95
+ request.env['INSTANA_HTTP_PATH_TEMPLATE'] = matched_path_template
86
96
  rescue Exception => e
87
97
  ::Instana.tracer.log_error(e) unless has_rails_handler?(e)
88
98
  raise
@@ -135,6 +145,7 @@ module Instana
135
145
  ::Instana.tracer.log_entry(:actioncontroller, kv_payload)
136
146
 
137
147
  process_action_without_instana(*args)
148
+ request.env['INSTANA_HTTP_PATH_TEMPLATE'] = matched_path_template
138
149
  rescue Exception => e
139
150
  ::Instana.tracer.log_error(e) unless has_rails_handler?(e)
140
151
  raise
@@ -1,18 +1,13 @@
1
1
  module Instana
2
2
  module Instrumentation
3
3
  module ActionViewRenderer
4
- def self.included(klass)
5
- ::Instana::Util.method_alias(klass, :render_partial)
6
- ::Instana::Util.method_alias(klass, :render_collection)
7
- end
8
-
9
- def render_partial_with_instana(*args)
4
+ def render_partial(*args)
10
5
  kv_payload = { :render => {} }
11
6
  kv_payload[:render][:type] = :partial
12
7
  kv_payload[:render][:name] = @options[:partial].to_s if @options.is_a?(Hash)
13
8
 
14
9
  ::Instana.tracer.log_entry(:render, kv_payload)
15
- render_partial_without_instana(*args)
10
+ super(*args)
16
11
  rescue Exception => e
17
12
  ::Instana.tracer.log_error(e)
18
13
  raise
@@ -20,13 +15,14 @@ module Instana
20
15
  ::Instana.tracer.log_exit(:render)
21
16
  end
22
17
 
23
- def render_collection_with_instana(*args)
18
+ def render_collection(*args)
19
+ puts 'called'
24
20
  kv_payload = { :render => {} }
25
21
  kv_payload[:render][:type] = :collection
26
22
  kv_payload[:render][:name] = @path.to_s
27
23
 
28
24
  ::Instana.tracer.log_entry(:render, kv_payload)
29
- render_collection_without_instana(*args)
25
+ super(*args)
30
26
  rescue Exception => e
31
27
  ::Instana.tracer.log_error(e)
32
28
  raise
@@ -39,5 +35,5 @@ end
39
35
 
40
36
  if defined?(::ActionView) && ::Instana.config[:action_view][:enabled] && ::ActionPack::VERSION::STRING >= '3.1'
41
37
  ::Instana.logger.debug "Instrumenting ActionView"
42
- ::ActionView::PartialRenderer.send(:include, ::Instana::Instrumentation::ActionViewRenderer)
38
+ ::ActionView::PartialRenderer.send(:prepend, ::Instana::Instrumentation::ActionViewRenderer)
43
39
  end
@@ -9,19 +9,19 @@ if defined?(::ActiveRecord) && ::Instana.config[:active_record][:enabled]
9
9
  # Mysql
10
10
  if defined?(ActiveRecord::ConnectionAdapters::MysqlAdapter)
11
11
  ::Instana.logger.debug "Instrumenting ActiveRecord (mysql)"
12
- ActiveRecord::ConnectionAdapters::MysqlAdapter.send(:include, ::Instana::Instrumentation::MysqlAdapter)
13
- ActiveRecord::ConnectionAdapters::AbstractMysqlAdapter.send(:include, ::Instana::Instrumentation::AbstractMysqlAdapter)
12
+ ActiveRecord::ConnectionAdapters::MysqlAdapter.send(:prepend, ::Instana::Instrumentation::MysqlAdapter)
13
+ ActiveRecord::ConnectionAdapters::AbstractMysqlAdapter.send(:prepend, ::Instana::Instrumentation::AbstractMysqlAdapter)
14
14
  end
15
15
 
16
16
  # Mysql2
17
17
  if defined?(ActiveRecord::ConnectionAdapters::Mysql2Adapter)
18
18
  ::Instana.logger.debug "Instrumenting ActiveRecord (mysql2)"
19
- ActiveRecord::ConnectionAdapters::Mysql2Adapter.send(:include, ::Instana::Instrumentation::Mysql2Adapter)
19
+ ActiveRecord::ConnectionAdapters::Mysql2Adapter.send(:prepend, ::Instana::Instrumentation::Mysql2Adapter)
20
20
  end
21
21
 
22
22
  # Postgres
23
23
  if defined?(ActiveRecord::ConnectionAdapters::PostgreSQLAdapter)
24
24
  ::Instana.logger.debug "Instrumenting ActiveRecord (postgresql)"
25
- ActiveRecord::ConnectionAdapters::PostgreSQLAdapter.send(:include, ::Instana::Instrumentation::PostgreSQLAdapter)
25
+ ActiveRecord::ConnectionAdapters::PostgreSQLAdapter.send(:prepend, ::Instana::Instrumentation::PostgreSQLAdapter)
26
26
  end
27
27
  end
@@ -6,13 +6,9 @@ module Instana
6
6
 
7
7
  # This module supports instrumenting ActiveRecord with the mysql2 adapter.
8
8
  #
9
- def self.included(klass)
9
+ def self.prepended(klass)
10
10
  # ActiveRecord 3.1 and up only (for now possibly)
11
11
  if ActiveRecord::VERSION::STRING > '3.0'
12
- Instana::Util.method_alias(klass, :exec_delete)
13
- Instana::Util.method_alias(klass, :exec_insert)
14
- Instana::Util.method_alias(klass, :exec_query)
15
-
16
12
  @@sanitize_regexp = Regexp.new('(\'[\s\S][^\']*\'|\d*\.\d+|\d+|NULL)', Regexp::IGNORECASE)
17
13
  end
18
14
  end
@@ -24,7 +20,13 @@ module Instana
24
20
  #
25
21
  def collect(sql)
26
22
  payload = { :activerecord => {} }
27
- payload[:activerecord][:sql] = sql.gsub(@@sanitize_regexp, '?')
23
+
24
+ if ::Instana.config[:sanitize_sql]
25
+ payload[:activerecord][:sql] = sql.gsub(@@sanitize_regexp, '?')
26
+ else
27
+ payload[:activerecord][:sql] = sql
28
+ end
29
+
28
30
  payload[:activerecord][:adapter] = @config[:adapter]
29
31
  payload[:activerecord][:host] = @config[:host]
30
32
  payload[:activerecord][:db] = @config[:database]
@@ -43,37 +45,37 @@ module Instana
43
45
  IGNORED_PAYLOADS.include?(name) || sql !~ EXPLAINED_SQLS
44
46
  end
45
47
 
46
- def exec_delete_with_instana(sql, name = nil, binds = [])
48
+ def exec_delete(sql, name = nil, binds = [])
47
49
  if !::Instana.tracer.tracing? || ignore_payload?(name, sql)
48
- return exec_delete_without_instana(sql, name, binds)
50
+ return super(sql, name, binds)
49
51
  end
50
52
 
51
53
  kv_payload = collect(sql)
52
54
  ::Instana.tracer.trace(:activerecord, kv_payload) do
53
- exec_delete_without_instana(sql, name, binds)
55
+ super(sql, name, binds)
54
56
  end
55
57
  end
56
58
 
57
- def exec_insert_with_instana(sql, name = 'SQL', binds = [], *args)
59
+ def exec_insert(sql, name = 'SQL', binds = [], *args)
58
60
  if !::Instana.tracer.tracing? || ignore_payload?(name, sql)
59
- return exec_insert_without_instana(sql, name, binds, *args)
61
+ return super(sql, name, binds, *args)
60
62
  end
61
63
 
62
64
  kv_payload = collect(sql)
63
65
  ::Instana.tracer.trace(:activerecord, kv_payload) do
64
- exec_insert_without_instana(sql, name, binds, *args)
66
+ super(sql, name, binds, *args)
65
67
  end
66
68
  end
67
69
 
68
- def exec_query_with_instana(sql, name = 'SQL', binds = [], *args)
70
+ def exec_query(sql, name = 'SQL', binds = [], *args)
69
71
  if !::Instana.tracer.tracing? || ignore_payload?(name, sql) ||
70
72
  ::Instana.tracer.current_span[:n] == :activerecord
71
- return exec_query_without_instana(sql, name, binds, *args)
73
+ return super(sql, name, binds, *args)
72
74
  end
73
75
 
74
76
  kv_payload = collect(sql)
75
77
  ::Instana.tracer.trace(:activerecord, kv_payload) do
76
- exec_query_without_instana(sql, name, binds, *args)
78
+ super(sql, name, binds, *args)
77
79
  end
78
80
  end
79
81
  end
@@ -6,10 +6,8 @@ module Instana
6
6
 
7
7
  # This module supports instrumenting ActiveRecord with the mysql2 adapter.
8
8
  #
9
- def self.included(klass)
9
+ def self.prepended(klass)
10
10
  if ActiveRecord::VERSION::STRING >= '3.2'
11
- Instana::Util.method_alias(klass, :exec_query)
12
-
13
11
  @@sanitize_regexp = Regexp.new('(\'[\s\S][^\']*\'|\d*\.\d+|\d+|NULL)', Regexp::IGNORECASE)
14
12
  end
15
13
  end
@@ -21,7 +19,13 @@ module Instana
21
19
  #
22
20
  def collect(sql)
23
21
  payload = { :activerecord => {} }
24
- payload[:activerecord][:sql] = sql.gsub(@@sanitize_regexp, '?')
22
+
23
+ if ::Instana.config[:sanitize_sql]
24
+ payload[:activerecord][:sql] = sql.gsub(@@sanitize_regexp, '?')
25
+ else
26
+ payload[:activerecord][:sql] = sql
27
+ end
28
+
25
29
  payload[:activerecord][:adapter] = @config[:adapter]
26
30
  payload[:activerecord][:host] = @config[:host]
27
31
  payload[:activerecord][:db] = @config[:database]
@@ -40,15 +44,15 @@ module Instana
40
44
  IGNORED_PAYLOADS.include?(name) || sql !~ EXPLAINED_SQLS
41
45
  end
42
46
 
43
- def exec_query_with_instana(sql, name = 'SQL', binds = [], *args)
47
+ def exec_query(sql, name = 'SQL', binds = [], *args)
44
48
  if !::Instana.tracer.tracing? || ignore_payload?(name, sql) ||
45
49
  ::Instana.tracer.current_span[:n] == :activerecord
46
- return exec_query_without_instana(sql, name, binds, *args)
50
+ return super(sql, name, binds, *args)
47
51
  end
48
52
 
49
53
  kv_payload = collect(sql)
50
54
  ::Instana.tracer.trace(:activerecord, kv_payload) do
51
- exec_query_without_instana(sql, name, binds, *args)
55
+ super(sql, name, binds, *args)
52
56
  end
53
57
  end
54
58
  end