solarwinds_apm 6.1.1 → 6.1.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.
@@ -169,9 +169,5 @@ if defined?(SolarWindsAPM::Config)
169
169
  # Example:
170
170
  # SELECT `posts`.* FROM `posts` /*traceparent=00-a448f096d441e167d12ebd32a927c1a5-a29655a47e430119-01*/
171
171
  #
172
- # This option can add a small overhead for prepared statements since the traceparent value is unique per execution.
173
- # This feature uses marginalia, see its caveat and possible workaround
174
- # https://github.com/basecamp/marginalia/blob/master/README.md#prepared-statements
175
- #
176
172
  SolarWindsAPM::Config[:tag_sql] = false
177
173
  end
@@ -0,0 +1,80 @@
1
+ # frozen_string_literal: true
2
+
3
+ # © 2024 SolarWinds Worldwide, LLC. All rights reserved.
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at:http://www.apache.org/licenses/LICENSE-2.0
6
+ #
7
+ # Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
8
+
9
+ module SolarWindsAPM
10
+ module API
11
+ module Tracer
12
+ def self.included(base)
13
+ base.extend(ClassMethods)
14
+ end
15
+
16
+ module ClassMethods
17
+ # Helper method to instrument custom method
18
+ #
19
+ # `add_tracer` can add a custom span to the specified instance or class method that is already defined.
20
+ # It requires the custom span name and optionally takes the span kind and additional attributes
21
+ # in hash format.
22
+ #
23
+ # === Argument:
24
+ #
25
+ # * +method_name+ - (String) A non-empty string that match the method name that need to be instrumented
26
+ # * +span_name+ - (String, optional, default = method_name) A non-empty string that define the span name (default to method_name)
27
+ # * +options+ - (Hash, optional, default = {}) A hash with desired options include attributes and span kind e.g. {attributes: {}, kind: :consumer}
28
+ #
29
+ # === Example:
30
+ #
31
+ # class DogfoodsController < ApplicationController
32
+ # include SolarWindsAPM::API::Tracer
33
+ #
34
+ # def create
35
+ # @dogfood = Dogfood.new(params.permit(:brand, :name))
36
+ # @dogfood.save
37
+ # custom_method
38
+ # end
39
+ #
40
+ # def custom_method
41
+ # end
42
+ # add_tracer :custom_method, 'custom_name', { attributes: { 'foo' => 'bar' }, kind: :consumer }
43
+ #
44
+ # end
45
+ #
46
+ # class DogfoodsController < ApplicationController
47
+ # def create
48
+ # @dogfood = Dogfood.new(params.permit(:brand, :name))
49
+ # @dogfood.save
50
+ # custom_method
51
+ # end
52
+ #
53
+ # def self.custom_method
54
+ # end
55
+ #
56
+ # class << self
57
+ # include SolarWindsAPM::API::Tracer
58
+ # add_tracer :custom_method, 'custom_name', { attributes: { 'foo' => 'bar' }, kind: :consumer }
59
+ # end
60
+ #
61
+ # end
62
+ #
63
+ # === Returns:
64
+ # * nil
65
+ #
66
+ def add_tracer(method_name, span_name = nil, options = {})
67
+ span_name = name.nil? ? "#{to_s.split(':').last&.tr('>', '')}/#{__method__}" : "#{name}/#{__method__}" if span_name.nil?
68
+
69
+ original_method = instance_method(method_name)
70
+
71
+ define_method(method_name) do |*args, &block|
72
+ SolarWindsAPM::API.in_span(span_name, **options) do |_span|
73
+ original_method.bind_call(self, *args, &block)
74
+ end
75
+ end
76
+ end
77
+ end
78
+ end
79
+ end
80
+ end
@@ -11,6 +11,7 @@ require_relative 'api/current_trace_info'
11
11
  require_relative 'api/tracing'
12
12
  require_relative 'api/opentelemetry'
13
13
  require_relative 'api/custom_metrics'
14
+ require_relative 'api/custom_instrumentation'
14
15
 
15
16
  module SolarWindsAPM
16
17
  module API
@@ -19,5 +20,6 @@ module SolarWindsAPM
19
20
  extend SolarWindsAPM::API::Tracing
20
21
  extend SolarWindsAPM::API::OpenTelemetry
21
22
  extend SolarWindsAPM::API::CustomMetrics
23
+ extend SolarWindsAPM::API::Tracer
22
24
  end
23
25
  end
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright The OpenTelemetry Authors
4
+ #
5
+ # SPDX-License-Identifier: Apache-2.0
6
+
7
+ module SolarWindsAPM
8
+ module Patch
9
+ module TagSql
10
+ module SWODboUtils
11
+ def self.annotate_span_and_sql(sql)
12
+ return sql if sql.to_s.empty?
13
+
14
+ current_span = ::OpenTelemetry::Trace.current_span
15
+
16
+ annotated_sql = ''
17
+ if current_span.context.trace_flags.sampled?
18
+ traceparent = SolarWindsAPM::Utils.traceparent_from_context(current_span.context)
19
+ annotated_traceparent = "/*traceparent='#{traceparent}'*/"
20
+ current_span.add_attributes({ 'sw.query_tag' => annotated_traceparent })
21
+ annotated_sql = "#{sql} #{annotated_traceparent}"
22
+ else
23
+ annotated_sql = sql
24
+ end
25
+
26
+ SolarWindsAPM.logger.debug { "[#{self.class}/#{__method__}] annotated_sql: #{annotated_sql}" }
27
+ annotated_sql
28
+ rescue StandardError => e
29
+ SolarWindsAPM.logger.error { "[#{self.class}/#{__method__}] Failed to annotated sql. Error: #{e.message}" }
30
+ sql
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
@@ -11,18 +11,7 @@ module SolarWindsAPM
11
11
  module TagSql
12
12
  module SWOMysql2Patch
13
13
  def query(sql, options = {})
14
- current_span = ::OpenTelemetry::Trace.current_span
15
-
16
- annotated_sql = ''
17
- if current_span.context.trace_flags.sampled?
18
- traceparent = SolarWindsAPM::Utils.traceparent_from_context(current_span.context)
19
- annotated_traceparent = "/*traceparent='#{traceparent}'*/"
20
- current_span.add_attributes({ 'sw.query_tag' => annotated_traceparent })
21
- annotated_sql = "#{sql} #{annotated_traceparent}"
22
- else
23
- annotated_sql = sql
24
- end
25
-
14
+ annotated_sql = ::SolarWindsAPM::Patch::TagSql::SWODboUtils.annotate_span_and_sql(sql)
26
15
  super(annotated_sql, options)
27
16
  end
28
17
  end
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright The OpenTelemetry Authors
4
+ #
5
+ # SPDX-License-Identifier: Apache-2.0
6
+
7
+ module SolarWindsAPM
8
+ module Patch
9
+ module TagSql
10
+ module SWOPgPatch
11
+ # We target operations covered by the upstream pg instrumentation.
12
+ # These are all alike in that they will have a SQL
13
+ # statement as the first parameter, and they are all
14
+ # non-prepared statement execute.
15
+ EXEC_ISH_METHODS = %i[
16
+ exec
17
+ query
18
+ sync_exec
19
+ async_exec
20
+ exec_params
21
+ async_exec_params
22
+ sync_exec_params
23
+ ].freeze
24
+
25
+ EXEC_ISH_METHODS.each do |method|
26
+ define_method method do |*args|
27
+ annotated_sql = ::SolarWindsAPM::Patch::TagSql::SWODboUtils.annotate_span_and_sql(args[0])
28
+ args[0] = annotated_sql
29
+ super(*args)
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
36
+
37
+ # need to prepend before pg instrumentation patch itself
38
+ # upstream instrumentation -> our patch -> original function
39
+ PG::Connection.prepend(SolarWindsAPM::Patch::TagSql::SWOPgPatch) if defined?(PG::Connection)
@@ -6,4 +6,6 @@
6
6
  #
7
7
  # Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
8
8
 
9
+ require_relative 'tag_sql/sw_dbo_utils'
9
10
  require_relative 'tag_sql/sw_mysql2_patch'
11
+ require_relative 'tag_sql/sw_pg_patch'
@@ -13,7 +13,7 @@ module SolarWindsAPM
13
13
  module Version
14
14
  MAJOR = 6 # breaking,
15
15
  MINOR = 1 # feature,
16
- PATCH = 1 # fix => BFF
16
+ PATCH = 2 # fix => BFF
17
17
  PRE = nil
18
18
 
19
19
  STRING = [MAJOR, MINOR, PATCH, PRE].compact.join('.')
metadata CHANGED
@@ -1,17 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: solarwinds_apm
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.1.1
4
+ version: 6.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Maia Engeli
8
8
  - Peter Giacomo Lombardo
9
9
  - Spiros Eliopoulos
10
10
  - Xuan Cao
11
- autorequire:
11
+ autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2024-12-09 00:00:00.000000000 Z
14
+ date: 2025-02-28 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: opentelemetry-instrumentation-all
@@ -74,6 +74,7 @@ files:
74
74
  - lib/solarwinds_apm.rb
75
75
  - lib/solarwinds_apm/api.rb
76
76
  - lib/solarwinds_apm/api/current_trace_info.rb
77
+ - lib/solarwinds_apm/api/custom_instrumentation.rb
77
78
  - lib/solarwinds_apm/api/custom_metrics.rb
78
79
  - lib/solarwinds_apm/api/opentelemetry.rb
79
80
  - lib/solarwinds_apm/api/tracing.rb
@@ -100,7 +101,9 @@ files:
100
101
  - lib/solarwinds_apm/otel_lambda_config.rb
101
102
  - lib/solarwinds_apm/patch.rb
102
103
  - lib/solarwinds_apm/patch/dummy_patch.rb
104
+ - lib/solarwinds_apm/patch/tag_sql/sw_dbo_utils.rb
103
105
  - lib/solarwinds_apm/patch/tag_sql/sw_mysql2_patch.rb
106
+ - lib/solarwinds_apm/patch/tag_sql/sw_pg_patch.rb
104
107
  - lib/solarwinds_apm/patch/tag_sql_patch.rb
105
108
  - lib/solarwinds_apm/support.rb
106
109
  - lib/solarwinds_apm/support/logger_formatter.rb
@@ -109,13 +112,6 @@ files:
109
112
  - lib/solarwinds_apm/support/oboe_tracing_mode.rb
110
113
  - lib/solarwinds_apm/support/service_key_checker.rb
111
114
  - lib/solarwinds_apm/support/support_report.rb
112
- - lib/solarwinds_apm/support/swomarginalia/LICENSE
113
- - lib/solarwinds_apm/support/swomarginalia/README.md
114
- - lib/solarwinds_apm/support/swomarginalia/comment.rb
115
- - lib/solarwinds_apm/support/swomarginalia/formatter.rb
116
- - lib/solarwinds_apm/support/swomarginalia/load_swomarginalia.rb
117
- - lib/solarwinds_apm/support/swomarginalia/railtie.rb
118
- - lib/solarwinds_apm/support/swomarginalia/swomarginalia.rb
119
115
  - lib/solarwinds_apm/support/transaction_cache.rb
120
116
  - lib/solarwinds_apm/support/transaction_settings.rb
121
117
  - lib/solarwinds_apm/support/txn_name_manager.rb
@@ -131,7 +127,7 @@ metadata:
131
127
  homepage_uri: https://documentation.solarwinds.com/en/success_center/observability/content/intro/landing-page.html
132
128
  source_code_uri: https://github.com/solarwinds/apm-ruby
133
129
  rubygems_mfa_required: 'true'
134
- post_install_message:
130
+ post_install_message:
135
131
  rdoc_options: []
136
132
  require_paths:
137
133
  - lib
@@ -147,7 +143,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
147
143
  version: '0'
148
144
  requirements: []
149
145
  rubygems_version: 3.3.27
150
- signing_key:
146
+ signing_key:
151
147
  specification_version: 4
152
148
  summary: SolarWindsAPM performance instrumentation gem for Ruby
153
149
  test_files: []
@@ -1,20 +0,0 @@
1
- # Copyright (c) 2012 37signals, LLC
2
- #
3
- # Permission is hereby granted, free of charge, to any person obtaining
4
- # a copy of this software and associated documentation files (the
5
- # "Software"), to deal in the Software without restriction, including
6
- # without limitation the rights to use, copy, modify, merge, publish,
7
- # distribute, sublicense, and/or sell copies of the Software, and to
8
- # permit persons to whom the Software is furnished to do so, subject to
9
- # the following conditions:
10
- #
11
- # The above copyright notice and this permission notice shall be
12
- # included in all copies or substantial portions of the Software.
13
- #
14
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
- # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
- # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
- # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
- # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
- # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
- # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -1,46 +0,0 @@
1
- # swomarginalia
2
-
3
- This folder contains the code that is copied from original [marginalia](https://github.com/basecamp/marginalia)
4
-
5
- ## File structure
6
-
7
- ```console
8
- |-- swomarginalia
9
- | |-- LICENSE
10
- | |-- README.md
11
- | |-- comment.rb
12
- | |-- railtie.rb
13
- | |-- load_swomarginalia.rb
14
- | `-- swomarginalia.rb
15
- ```
16
-
17
- ## Modification
18
-
19
- ### railitie.rb
20
-
21
- 1. Moved prepend logic into load_swomarginalia.rb in case that non-rails app using activerecord
22
-
23
- ### swomarginlia.rb
24
-
25
- 1. Removed the alias_method to achieve function override; instead, we use prepend.
26
- 2. Added step of cleaning-up previous transparent comments
27
-
28
- ### comment.rb
29
-
30
- 1. Added the traceparent comment (trace string constructed based on opentelemetry)
31
-
32
- ### load_swomarginalia.rb
33
-
34
- 1. (new file) prepend the ActiveRecordInstrumentation to activerecord adapter
35
-
36
- ## Example
37
-
38
- ### Sample output of rails application
39
-
40
- ```console
41
- Post Load (1.1ms) SELECT `posts`.* FROM `posts` /*application=SqlcommenterRailsDemo,controller=posts,action=index,traceparent=00-a448f096d441e167d12ebd32a927c1a5-a29655a47e430119-01*/
42
- ```
43
-
44
- ## License
45
-
46
- This project is licensed under the [MIT License](https://github.com/solarwinds/apm-ruby/blob/main/lib/solarwinds_apm/support/swomarginalia/LICENSE).
@@ -1,206 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'socket'
4
- require 'opentelemetry-api'
5
-
6
- module SolarWindsAPM
7
- module SWOMarginalia
8
- module Comment
9
- mattr_accessor :components, :lines_to_ignore, :prepend_comment
10
- SWOMarginalia::Comment.components ||= [:traceparent]
11
- # To add new components:
12
- # Create file and load after loading solarwinds_apm, and add following:
13
- # SolarWindsAPM::SWOMarginalia::Comment.component = [:user_defined]
14
-
15
- def self.update!(controller = nil)
16
- self.marginalia_controller = controller
17
- end
18
-
19
- def self.update_job!(job)
20
- self.marginalia_job = job
21
- end
22
-
23
- def self.update_adapter!(adapter)
24
- self.marginalia_adapter = adapter
25
- end
26
-
27
- def self.construct_comment
28
- ret = +''
29
- components.each do |c|
30
- component_value = send(c)
31
- ret << "#{c}='#{component_value}'," if component_value.present?
32
- end
33
- ret.chop!
34
- escape_sql_comment(ret)
35
- end
36
-
37
- def self.construct_inline_comment
38
- return nil if inline_annotations.none?
39
-
40
- escape_sql_comment(inline_annotations.join)
41
- end
42
-
43
- def self.escape_sql_comment(str)
44
- str = str.gsub('/*', '').gsub('*/', '') while str.include?('/*') || str.include?('*/')
45
- str
46
- end
47
-
48
- def self.clear!
49
- self.marginalia_controller = nil
50
- end
51
-
52
- def self.clear_job!
53
- self.marginalia_job = nil
54
- end
55
-
56
- def self.marginalia_controller=(controller)
57
- Thread.current[:marginalia_controller] = controller
58
- end
59
-
60
- def self.marginalia_controller
61
- Thread.current[:marginalia_controller]
62
- end
63
-
64
- def self.marginalia_job=(job)
65
- Thread.current[:marginalia_job] = job
66
- end
67
-
68
- def self.marginalia_job
69
- Thread.current[:marginalia_job]
70
- end
71
-
72
- def self.marginalia_adapter=(adapter)
73
- Thread.current[:marginalia_adapter] = adapter
74
- end
75
-
76
- def self.marginalia_adapter
77
- Thread.current[:marginalia_adapter]
78
- end
79
-
80
- def self.application
81
- SWOMarginalia.application_name ||= if defined?(::Rails.application)
82
- ::Rails.application.class.name.split('::').first
83
- else
84
- 'rails'
85
- end
86
-
87
- SWOMarginalia.application_name
88
- end
89
-
90
- def self.job
91
- marginalia_job&.class&.name
92
- end
93
-
94
- def self.controller
95
- marginalia_controller.controller_name if marginalia_controller.respond_to? :controller_name
96
- end
97
-
98
- def self.controller_with_namespace
99
- marginalia_controller&.class&.name
100
- end
101
-
102
- def self.action
103
- marginalia_controller.action_name if marginalia_controller.respond_to? :action_name
104
- end
105
-
106
- def self.sidekiq_job
107
- marginalia_job['class'] if marginalia_job.respond_to?(:[])
108
- end
109
-
110
- DEFAULT_LINES_TO_IGNORE_REGEX = %r{\.rvm|/ruby/gems/|vendor/|marginalia|rbenv|monitor\.rb.*mon_synchronize}
111
-
112
- def self.line
113
- SWOMarginalia::Comment.lines_to_ignore ||= DEFAULT_LINES_TO_IGNORE_REGEX
114
-
115
- last_line = caller.detect do |line|
116
- line !~ SWOMarginalia::Comment.lines_to_ignore
117
- end
118
- return unless last_line
119
-
120
- root = if defined?(Rails) && Rails.respond_to?(:root)
121
- Rails.root.to_s
122
- elsif defined?(RAILS_ROOT)
123
- RAILS_ROOT
124
- else
125
- ''
126
- end
127
- last_line = last_line[root.length..] if last_line.start_with? root
128
- last_line
129
- end
130
-
131
- def self.hostname
132
- @hostname ||= Socket.gethostname
133
- end
134
-
135
- def self.pid
136
- Process.pid
137
- end
138
-
139
- def self.request_id
140
- return unless marginalia_controller.respond_to?(:request) && marginalia_controller.request.respond_to?(:uuid)
141
-
142
- marginalia_controller.request.uuid
143
- end
144
-
145
- def self.socket
146
- return unless connection_config.present?
147
-
148
- connection_config[:socket]
149
- end
150
-
151
- def self.db_host
152
- return unless connection_config.present?
153
-
154
- connection_config[:host]
155
- end
156
-
157
- def self.database
158
- return unless connection_config.present?
159
-
160
- connection_config[:database]
161
- end
162
-
163
- ##
164
- # Insert trace string as traceparent to sql statement
165
- # Not insert if:
166
- # there is no valid current trace context
167
- # current trace context is not sampled
168
- #
169
- def self.traceparent
170
- span_context = ::OpenTelemetry::Trace.current_span.context
171
- return '' if span_context == ::OpenTelemetry::Trace::SpanContext::INVALID
172
-
173
- trace_flag = span_context.trace_flags.sampled? ? '01' : '00'
174
- return '' if trace_flag == '00'
175
-
176
- format(
177
- '00-%<trace_id>s-%<span_id>s-%<trace_flags>.2d',
178
- trace_id: span_context.hex_trace_id,
179
- span_id: span_context.hex_span_id,
180
- trace_flags: trace_flag
181
- )
182
- rescue NameError => e
183
- SolarWindsAPM.logger.error { "[#{name}/#{__method__}] Couldn't find OpenTelemetry. Error: #{e.message}" }
184
- end
185
-
186
- if Gem::Version.new(ActiveRecord::VERSION::STRING) < Gem::Version.new('6.1')
187
- def self.connection_config
188
- return if marginalia_adapter.pool.nil?
189
-
190
- marginalia_adapter.pool.spec.config
191
- end
192
- else
193
- def self.connection_config
194
- # `pool` might be a NullPool which has no db_config
195
- return unless marginalia_adapter.pool.respond_to?(:db_config)
196
-
197
- marginalia_adapter.pool.db_config.configuration_hash
198
- end
199
- end
200
-
201
- def self.inline_annotations
202
- Thread.current[:marginalia_inline_annotations] ||= []
203
- end
204
- end
205
- end
206
- end
@@ -1,20 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module SolarWindsAPM
4
- module SWOMarginalia
5
- module Formatter
6
- def tag_content
7
- comment = super
8
- comment.tr!(':', '=')
9
- comment
10
- end
11
- end
12
- end
13
- end
14
-
15
- # Prepend the Formatter module to the singleton class of ActiveRecord::QueryLogs
16
- if defined?(ActiveRecord::QueryLogs)
17
- class << ActiveRecord::QueryLogs
18
- prepend SolarWindsAPM::SWOMarginalia::Formatter
19
- end
20
- end
@@ -1,55 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # © 2023 SolarWinds Worldwide, LLC. All rights reserved.
4
- #
5
- # Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at:http://www.apache.org/licenses/LICENSE-2.0
6
- #
7
- # Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
8
-
9
- require_relative 'swomarginalia'
10
-
11
- module SolarWindsAPM
12
- module SWOMarginalia
13
- module LoadSWOMarginalia
14
- def self.insert
15
- insert_into_active_record
16
- insert_into_action_controller
17
- insert_into_active_job
18
- end
19
-
20
- def self.insert_into_active_job
21
- return unless defined? ::ActiveJob::Base
22
-
23
- ::ActiveJob::Base.class_eval do
24
- around_perform do |job, block|
25
- SWOMarginalia::Comment.update_job! job
26
- block.call
27
- ensure
28
- SWOMarginalia::Comment.clear_job!
29
- end
30
- end
31
- end
32
-
33
- def self.insert_into_action_controller
34
- return unless defined? ::ActionController::Base
35
-
36
- ::ActionController::Base.include SWOMarginalia::ActionControllerInstrumentation
37
-
38
- return unless defined? ::ActionController::API
39
-
40
- ::ActionController::API.include SWOMarginalia::ActionControllerInstrumentation
41
- end
42
-
43
- def self.insert_into_active_record
44
- ActiveRecord::ConnectionAdapters::Mysql2Adapter.prepend(SWOMarginalia::ActiveRecordInstrumentation) if defined? ActiveRecord::ConnectionAdapters::Mysql2Adapter
45
- ActiveRecord::ConnectionAdapters::MysqlAdapter.prepend(SWOMarginalia::ActiveRecordInstrumentation) if defined? ActiveRecord::ConnectionAdapters::MysqlAdapter
46
- ActiveRecord::ConnectionAdapters::PostgreSQLAdapter.prepend(SWOMarginalia::ActiveRecordInstrumentation) if defined? ActiveRecord::ConnectionAdapters::PostgreSQLAdapter
47
- return unless defined? ActiveRecord::ConnectionAdapters::SQLite3Adapter
48
-
49
- return unless defined? ActiveRecord::ConnectionAdapters::SQLite3Adapter
50
-
51
- ActiveRecord::ConnectionAdapters::SQLite3Adapter.prepend(SWOMarginalia::ActiveRecordInstrumentation)
52
- end
53
- end
54
- end
55
- end
@@ -1,24 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'rails/railtie'
4
- require_relative 'load_swomarginalia'
5
-
6
- module SolarWindsAPM
7
- module SWOMarginalia
8
- class Railtie < Rails::Railtie
9
- initializer 'swomarginalia.insert' do
10
- ActiveSupport.on_load :active_record do
11
- ::SolarWindsAPM::SWOMarginalia::LoadSWOMarginalia.insert_into_active_record
12
- end
13
-
14
- ActiveSupport.on_load :action_controller do
15
- ::SolarWindsAPM::SWOMarginalia::LoadSWOMarginalia.insert_into_action_controller
16
- end
17
-
18
- ActiveSupport.on_load :active_job do
19
- ::SolarWindsAPM::SWOMarginalia::LoadSWOMarginalia.insert_into_active_job
20
- end
21
- end
22
- end
23
- end
24
- end