Skip to content

Commit 2eb54f6

Browse files
committed
NH-94970: remove marginalia code and add psql patch for dbo
1 parent 77162dd commit 2eb54f6

22 files changed

+158
-627
lines changed

CONFIGURATION.md

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -165,24 +165,18 @@ SELECT * FROM SAMPLE_TABLE WHERE user_id = 1;
165165
SELECT * FROM SAMPLE_TABLE WHERE user_id = 1; /* traceparent=7435a9fe510ae4533414d425dadf4e18-49e60702469db05f-01 */
166166
```
167167

168-
For Rails < 7 and non-Rails applications, we use a port of [Marginalia](https://github.com/basecamp/marginalia) that patches ActiveRecord to inject the comment.
168+
#### Limitation
169169

170-
For Rails >= 7, Marginalia is [integrated into ActiveRecord](https://api.rubyonrails.org/classes/ActiveRecord/QueryLogs.html) so enabling this feature should be done through Rails [configuration](https://guides.rubyonrails.org/v7.0/configuring.html#config-active-record-query-log-tags-enabled). For example:
170+
Currently, tag queries don't support prepared statements. Active Record uses the PostgreSQL adapter (pg) by default to prepare statements. So, when you choose to use PostgreSQL and wish to enable trace context, please set `prepared_statements` to false."
171171

172-
```ruby
173-
class Application < Rails::Application
174-
config.active_record.query_log_tags_enabled = true
175-
config.active_record.query_log_tags = [
176-
{
177-
traceparent: -> {
178-
SolarWindsAPM::SWOMarginalia::Comment.traceparent
179-
}
180-
}
181-
]
182-
end
183-
```
172+
e.g.
184173

185-
Note that with Rails >= 7.1 the comment format can be specified via the `config.active_record.query_log_tags_format` option. SolarWinds Observability functionality depends on the default `:sqlcommenter` format, it is not recommended to change this value.
174+
```yaml
175+
development:
176+
adapter: postgresql
177+
# ...
178+
prepared_statements: false
179+
```
186180
187181
### Background Jobs
188182

CONTRIBUTING.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -192,10 +192,6 @@ BUNDLE_GEMFILE=gemfiles/unit.gemfile bundle update
192192

193193
BUNDLE_GEMFILE=gemfiles/unit.gemfile bundle exec ruby -I test test/opentelemetry/solarwinds_exporter_test.rb
194194
BUNDLE_GEMFILE=gemfiles/unit.gemfile bundle exec ruby -I test test/opentelemetry/solarwinds_propagator_test.rb
195-
196-
# marginalia tests require the rails_6x.gemfile dependencies
197-
BUNDLE_GEMFILE=gemfiles/rails_6x.gemfile bundle install
198-
BUNDLE_GEMFILE=gemfiles/rails_6x.gemfile bundle exec ruby -I test test/support/swomarginalia/swomarginalia_test.rb
199195
```
200196

201197
To run a specific test (that requires unit.gemfile):

Rakefile

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,13 @@ Rake::TestTask.new do |t|
2525
gem_file = ENV['BUNDLE_GEMFILE']&.split('/')&.last
2626

2727
case gem_file
28-
when 'rails_6x.gemfile'
29-
t.test_files = FileList['test/support/swomarginalia/*_test.rb']
30-
3128
when 'unit.gemfile'
3229
t.test_files = FileList['test/api/*_test.rb'] +
3330
FileList['test/solarwinds_apm/*_test.rb'] +
3431
FileList['test/opentelemetry/*_test.rb'] +
3532
FileList['test/noop/*_test.rb'] +
3633
FileList['test/ext/*_test.rb'] +
37-
FileList['test/support/*_test.rb'] -
38-
FileList['test/support/swomarginalia/*_test.rb']
34+
FileList['test/support/*_test.rb']
3935
end
4036
end
4137

gemfiles/rails_6x.gemfile

Lines changed: 0 additions & 9 deletions
This file was deleted.

lib/rails/generators/solarwinds_apm/templates/solarwinds_apm_initializer.rb

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -169,9 +169,5 @@
169169
# Example:
170170
# SELECT `posts`.* FROM `posts` /*traceparent=00-a448f096d441e167d12ebd32a927c1a5-a29655a47e430119-01*/
171171
#
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-
#
176172
SolarWindsAPM::Config[:tag_sql] = false
177173
end

lib/solarwinds_apm/patch/tag_sql/sw_mysql2_patch.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
#
77
# 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.
88

9-
require_relative 'swo_dbo_utils'
10-
119
module SolarWindsAPM
1210
module Patch
1311
module TagSql

lib/solarwinds_apm/patch/tag_sql/sw_pg_patch.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
#
55
# SPDX-License-Identifier: Apache-2.0
66

7-
require_relative 'swo_dbo_utils'
8-
97
module SolarWindsAPM
108
module Patch
119
module TagSql

lib/solarwinds_apm/patch/tag_sql_patch.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,6 @@
66
#
77
# 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.
88

9+
require_relative 'tag_sql/sw_dbo_utils'
910
require_relative 'tag_sql/sw_mysql2_patch'
1011
require_relative 'tag_sql/sw_pg_patch'

lib/solarwinds_apm/support/swomarginalia/LICENSE

Lines changed: 0 additions & 20 deletions
This file was deleted.

lib/solarwinds_apm/support/swomarginalia/README.md

Lines changed: 0 additions & 46 deletions
This file was deleted.

0 commit comments

Comments
 (0)