marginalia 1.10.1 → 1.11.0
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.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +2 -0
- data.tar.gz.sig +0 -0
- data/.github/workflows/ci.yml +49 -0
- data/.ruby-version +1 -1
- data/Gemfile +4 -24
- data/README.md +18 -27
- data/Rakefile +0 -5
- data/lib/marginalia.rb +8 -20
- data/lib/marginalia/comment.rb +20 -14
- data/lib/marginalia/railtie.rb +11 -16
- data/lib/marginalia/sidekiq_instrumentation.rb +0 -1
- data/marginalia.gemspec +3 -3
- data/test/query_comments_test.rb +52 -67
- metadata +32 -18
- metadata.gz.sig +1 -0
- data/.travis.yml +0 -34
- data/gemfiles/4.2.api.gemfile +0 -9
- data/gemfiles/4.2.gemfile +0 -8
- data/gemfiles/5.0.gemfile +0 -8
- data/gemfiles/5.1.gemfile +0 -8
- data/gemfiles/5.2.gemfile +0 -8
- data/init.rb +0 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2ca9d762a046a9a5baaa90aef990ffe83876738ed85938efd86d2e21e5dd1a61
|
4
|
+
data.tar.gz: d16943aa0b01bdacecf53dfc7be986d7c6c9f8eacb676e46fcc24a536af7299a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9f7e9f0d294d7f97931631aa527947bfab592885676cba533f210733516809a615c11bbdd6b2f1cca2954f150dc0ae670423dfc4f755b5dd815dae0a0e0a2ca2
|
7
|
+
data.tar.gz: dbdc5756415b07f2b85dce32975508983a03cfcc1d049d95201ab069233df46cd053194f934ec2d3cd39e7ea01904103eddf62ba4451ebbfbcc4341f8861ae2a
|
checksums.yaml.gz.sig
ADDED
data.tar.gz.sig
ADDED
Binary file
|
@@ -0,0 +1,49 @@
|
|
1
|
+
name: CI
|
2
|
+
|
3
|
+
on: [push, pull_request]
|
4
|
+
|
5
|
+
jobs:
|
6
|
+
test:
|
7
|
+
runs-on: ubuntu-latest
|
8
|
+
|
9
|
+
strategy:
|
10
|
+
fail-fast: false
|
11
|
+
matrix:
|
12
|
+
ruby-version: ["2.6", "2.7", "3.0"]
|
13
|
+
rails-version: ["5.2.0", "6.0.0", "6.1.0"]
|
14
|
+
exclude:
|
15
|
+
# Rails 5.2 does not support Ruby 3.0
|
16
|
+
- {ruby-version: "3.0", rails-version: "5.2.0"}
|
17
|
+
|
18
|
+
services:
|
19
|
+
mysql:
|
20
|
+
image: mysql
|
21
|
+
env:
|
22
|
+
MYSQL_ALLOW_EMPTY_PASSWORD: yes
|
23
|
+
ports:
|
24
|
+
- 3306:3306
|
25
|
+
postgres:
|
26
|
+
image: postgres
|
27
|
+
env:
|
28
|
+
POSTGRES_PASSWORD: password
|
29
|
+
POSTGRES_HOST_AUTH_METHOD: trust
|
30
|
+
ports:
|
31
|
+
- 5432:5432
|
32
|
+
|
33
|
+
env:
|
34
|
+
RAILS_VERSION: ${{ matrix.rails-version }}
|
35
|
+
MYSQL_HOST: 127.0.0.1
|
36
|
+
PGHOST: 127.0.0.1
|
37
|
+
DB_HOST: 127.0.0.1
|
38
|
+
|
39
|
+
steps:
|
40
|
+
- uses: actions/checkout@v2
|
41
|
+
|
42
|
+
- uses: ruby/setup-ruby@v1
|
43
|
+
with:
|
44
|
+
ruby-version: ${{ matrix.ruby-version }}
|
45
|
+
bundler-cache: true
|
46
|
+
|
47
|
+
- name: Run tests
|
48
|
+
run: bundle exec rake db:reset test:all
|
49
|
+
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.6.
|
1
|
+
2.6.8
|
data/Gemfile
CHANGED
@@ -2,29 +2,9 @@ source "https://rubygems.org"
|
|
2
2
|
|
3
3
|
gemspec
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
gem 'mysql2', '~> 0.3.13'
|
5
|
+
rails_version = ENV["RAILS_VERSION"] || "6.1.0"
|
6
|
+
if rails_version == "main"
|
7
|
+
gem "rails", github: "rails/rails"
|
9
8
|
else
|
10
|
-
gem
|
11
|
-
end
|
12
|
-
gem 'pg', '~> 0.15'
|
13
|
-
gem 'sqlite3', '~> 1.3.6'
|
14
|
-
|
15
|
-
rails = case version
|
16
|
-
when "master"
|
17
|
-
{:github => "rails/rails"}
|
18
|
-
else
|
19
|
-
"~> #{version}"
|
20
|
-
end
|
21
|
-
|
22
|
-
gem "rails", rails
|
23
|
-
|
24
|
-
if ENV["TEST_RAILS_API"] == "true"
|
25
|
-
gem "rails-api", "~> 0.2.1"
|
26
|
-
end
|
27
|
-
|
28
|
-
if RUBY_VERSION.start_with?('2.3')
|
29
|
-
gem 'mysql'
|
9
|
+
gem "rails", "~> #{rails_version}"
|
30
10
|
end
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# marginalia [](https://github.com/basecamp/marginalia/actions/workflows/ci.yml)
|
2
2
|
|
3
3
|
Attach comments to your ActiveRecord queries. By default, it adds the application, controller, and action names as a
|
4
4
|
comment at the end of each query.
|
@@ -18,43 +18,26 @@ to automate identification of controllers and actions that are hotspots for slow
|
|
18
18
|
This gem was created at 37signals. You can read more about how we use it [on
|
19
19
|
our blog](http://37signals.com/svn/posts/3130-tech-note-mysql-query-comments-in-rails).
|
20
20
|
|
21
|
-
This has been tested and used in production with
|
22
|
-
tested on Rails 2.
|
21
|
+
This has been tested and used in production with the mysql2 and pg gems, and is
|
22
|
+
tested on Rails 5.2 through 6.1, and Ruby 2.6 through 3.0. It is also tested
|
23
|
+
for sqlite3.
|
24
|
+
|
25
|
+
Rails version support will follow supported versions in the [Ruby on Rails maintenance policy](https://guides.rubyonrails.org/maintenance_policy.html)
|
26
|
+
and Ruby support will follow maintained versions in the [Ruby maintenance policy](https://www.ruby-lang.org/en/downloads/branches/).
|
23
27
|
|
24
28
|
Patches are welcome for other database adapters.
|
25
29
|
|
26
30
|
## Installation
|
27
31
|
|
28
|
-
### For Rails 3.x and 4.x:
|
29
|
-
|
30
32
|
# Gemfile
|
31
33
|
gem 'marginalia'
|
32
34
|
|
33
|
-
### For Rails 2.x:
|
34
|
-
|
35
|
-
If using cached externals, add to your `config/externals.yml` file.
|
36
|
-
|
37
|
-
Or, if your prefer using `config.gem`, you can use:
|
38
|
-
|
39
|
-
config.gem 'marginalia'
|
40
|
-
|
41
|
-
Finally, if bundled, you'll need to manually run the initialization step in an
|
42
|
-
initializer, e.g.:
|
43
|
-
|
44
|
-
# Gemfile
|
45
|
-
gem 'marginalia', :require => false
|
46
|
-
|
47
|
-
#config/initializers/marginalia.rb
|
48
|
-
require 'marginalia'
|
49
|
-
Marginalia::Railtie.insert
|
50
|
-
|
51
35
|
### Customization
|
52
36
|
Optionally, you can set the application name shown in the log like so in an initializer (e.g. `config/initializers/marginalia.rb`):
|
53
37
|
|
54
38
|
Marginalia.application_name = "BCX"
|
55
39
|
|
56
|
-
|
57
|
-
For Rails 2 applications, "rails" is used as the default application name.
|
40
|
+
The name will default to your Rails application name.
|
58
41
|
|
59
42
|
#### Components
|
60
43
|
|
@@ -94,8 +77,6 @@ default. In addition, implementation is provided for:
|
|
94
77
|
* `:job` to include the classname of the ActiveJob being performed.
|
95
78
|
* `:hostname` to include ```Socket.gethostname```.
|
96
79
|
* `:pid` to include current process id.
|
97
|
-
|
98
|
-
With ActiveRecord >= 3.2.19:
|
99
80
|
* `:db_host` to include the configured database hostname.
|
100
81
|
* `:socket` to include the configured database socket.
|
101
82
|
* `:database` to include the configured database name.
|
@@ -133,6 +114,16 @@ will issue this query:
|
|
133
114
|
|
134
115
|
Nesting `with_annotation` blocks will concatenate the comment strings.
|
135
116
|
|
117
|
+
### Caveats
|
118
|
+
|
119
|
+
#### Prepared statements
|
120
|
+
|
121
|
+
Be careful when using Marginalia with prepared statements. If you use a component
|
122
|
+
like `request_id` then every query will be unique and so ActiveRecord will create
|
123
|
+
a new prepared statement for each potentially exhausting system resources.
|
124
|
+
[Disable prepared statements](https://guides.rubyonrails.org/configuring.html#configuring-a-postgresql-database)
|
125
|
+
if you wish to use components with high cardinality values.
|
126
|
+
|
136
127
|
## Contributing
|
137
128
|
|
138
129
|
Start by bundling and creating the test database:
|
data/Rakefile
CHANGED
@@ -7,11 +7,6 @@ namespace :test do
|
|
7
7
|
desc "test all drivers"
|
8
8
|
task :all => [:mysql2, :postgresql, :sqlite]
|
9
9
|
|
10
|
-
desc "test mysql driver"
|
11
|
-
task :mysql do
|
12
|
-
sh "DRIVER=mysql bundle exec ruby -Ilib -Itest test/*_test.rb"
|
13
|
-
end
|
14
|
-
|
15
10
|
desc "test mysql2 driver"
|
16
11
|
task :mysql2 do
|
17
12
|
sh "DRIVER=mysql2 bundle exec ruby -Ilib -Itest test/*_test.rb"
|
data/lib/marginalia.rb
CHANGED
@@ -19,8 +19,8 @@ module Marginalia
|
|
19
19
|
else
|
20
20
|
is_mysql2 = defined?(ActiveRecord::ConnectionAdapters::Mysql2Adapter) &&
|
21
21
|
ActiveRecord::ConnectionAdapters::Mysql2Adapter == instrumented_class
|
22
|
-
# Dont instrument exec_query on mysql2
|
23
|
-
unless is_mysql2
|
22
|
+
# Dont instrument exec_query on mysql2 as it calls execute internally
|
23
|
+
unless is_mysql2
|
24
24
|
if instrumented_class.method_defined?(:exec_query)
|
25
25
|
alias_method :exec_query_without_marginalia, :exec_query
|
26
26
|
alias_method :exec_query, :exec_query_with_marginalia
|
@@ -29,9 +29,9 @@ module Marginalia
|
|
29
29
|
|
30
30
|
is_postgres = defined?(ActiveRecord::ConnectionAdapters::PostgreSQLAdapter) &&
|
31
31
|
ActiveRecord::ConnectionAdapters::PostgreSQLAdapter == instrumented_class
|
32
|
-
# Instrument exec_delete and exec_update
|
33
|
-
#
|
34
|
-
if is_postgres
|
32
|
+
# Instrument exec_delete and exec_update since they don't call
|
33
|
+
# execute internally
|
34
|
+
if is_postgres
|
35
35
|
if instrumented_class.method_defined?(:exec_delete)
|
36
36
|
alias_method :exec_delete_without_marginalia, :exec_delete
|
37
37
|
alias_method :exec_delete, :exec_delete_with_marginalia
|
@@ -72,18 +72,12 @@ module Marginalia
|
|
72
72
|
end
|
73
73
|
ruby2_keywords :execute_with_marginalia if respond_to?(:ruby2_keywords, true)
|
74
74
|
|
75
|
-
def exec_query_with_marginalia(sql, *args)
|
76
|
-
|
75
|
+
def exec_query_with_marginalia(sql, *args, **options)
|
76
|
+
options[:prepare] ||= false
|
77
|
+
exec_query_without_marginalia(annotate_sql(sql), *args, **options)
|
77
78
|
end
|
78
79
|
ruby2_keywords :exec_query_with_marginalia if respond_to?(:ruby2_keywords, true)
|
79
80
|
|
80
|
-
if ActiveRecord::VERSION::MAJOR >= 5
|
81
|
-
def exec_query_with_marginalia(sql, *args, **options)
|
82
|
-
options[:prepare] ||= false
|
83
|
-
exec_query_without_marginalia(annotate_sql(sql), *args, **options)
|
84
|
-
end
|
85
|
-
end
|
86
|
-
|
87
81
|
def exec_delete_with_marginalia(sql, *args)
|
88
82
|
exec_delete_without_marginalia(annotate_sql(sql), *args)
|
89
83
|
end
|
@@ -94,16 +88,10 @@ module Marginalia
|
|
94
88
|
end
|
95
89
|
ruby2_keywords :exec_update_with_marginalia if respond_to?(:ruby2_keywords, true)
|
96
90
|
|
97
|
-
if ActiveRecord::VERSION::MAJOR >= 5
|
98
91
|
def execute_and_clear_with_marginalia(sql, *args, &block)
|
99
92
|
execute_and_clear_without_marginalia(annotate_sql(sql), *args, &block)
|
100
93
|
end
|
101
94
|
ruby2_keywords :execute_and_clear_with_marginalia if respond_to?(:ruby2_keywords, true)
|
102
|
-
else
|
103
|
-
def execute_and_clear_with_marginalia(sql, *args, &block)
|
104
|
-
execute_and_clear_without_marginalia(annotate_sql(sql), *args, &block)
|
105
|
-
end
|
106
|
-
end
|
107
95
|
end
|
108
96
|
|
109
97
|
module ActionControllerInstrumentation
|
data/lib/marginalia/comment.rb
CHANGED
@@ -123,7 +123,7 @@ module Marginalia
|
|
123
123
|
else
|
124
124
|
""
|
125
125
|
end
|
126
|
-
if last_line.
|
126
|
+
if last_line.start_with? root
|
127
127
|
last_line = last_line[root.length..-1]
|
128
128
|
end
|
129
129
|
last_line
|
@@ -144,29 +144,35 @@ module Marginalia
|
|
144
144
|
end
|
145
145
|
end
|
146
146
|
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
self.connection_config[:socket]
|
151
|
-
end
|
147
|
+
def self.socket
|
148
|
+
if self.connection_config.present?
|
149
|
+
self.connection_config[:socket]
|
152
150
|
end
|
151
|
+
end
|
153
152
|
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
end
|
153
|
+
def self.db_host
|
154
|
+
if self.connection_config.present?
|
155
|
+
self.connection_config[:host]
|
158
156
|
end
|
157
|
+
end
|
159
158
|
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
end
|
159
|
+
def self.database
|
160
|
+
if self.connection_config.present?
|
161
|
+
self.connection_config[:database]
|
164
162
|
end
|
163
|
+
end
|
165
164
|
|
165
|
+
if Gem::Version.new(ActiveRecord::VERSION::STRING) < Gem::Version.new('6.1')
|
166
166
|
def self.connection_config
|
167
167
|
return if marginalia_adapter.pool.nil?
|
168
168
|
marginalia_adapter.pool.spec.config
|
169
169
|
end
|
170
|
+
else
|
171
|
+
def self.connection_config
|
172
|
+
# `pool` might be a NullPool which has no db_config
|
173
|
+
return unless marginalia_adapter.pool.respond_to?(:db_config)
|
174
|
+
marginalia_adapter.pool.db_config.configuration_hash
|
175
|
+
end
|
170
176
|
end
|
171
177
|
|
172
178
|
def self.inline_annotations
|
data/lib/marginalia/railtie.rb
CHANGED
@@ -1,27 +1,22 @@
|
|
1
1
|
require 'marginalia'
|
2
|
+
require 'rails/railtie'
|
2
3
|
|
3
4
|
module Marginalia
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
ActiveSupport.on_load :active_record do
|
10
|
-
Marginalia::Railtie.insert_into_active_record
|
11
|
-
end
|
5
|
+
class Railtie < Rails::Railtie
|
6
|
+
initializer 'marginalia.insert' do
|
7
|
+
ActiveSupport.on_load :active_record do
|
8
|
+
Marginalia::Railtie.insert_into_active_record
|
9
|
+
end
|
12
10
|
|
13
|
-
|
14
|
-
|
15
|
-
|
11
|
+
ActiveSupport.on_load :action_controller do
|
12
|
+
Marginalia::Railtie.insert_into_action_controller
|
13
|
+
end
|
16
14
|
|
17
|
-
|
18
|
-
|
19
|
-
end
|
15
|
+
ActiveSupport.on_load :active_job do
|
16
|
+
Marginalia::Railtie.insert_into_active_job
|
20
17
|
end
|
21
18
|
end
|
22
|
-
end
|
23
19
|
|
24
|
-
class Railtie
|
25
20
|
def self.insert
|
26
21
|
insert_into_active_record
|
27
22
|
insert_into_action_controller
|
data/marginalia.gemspec
CHANGED
@@ -8,11 +8,11 @@ Gem::Specification.new do |gem|
|
|
8
8
|
gem.test_files = `git ls-files -- {test}/*`.split("\n")
|
9
9
|
gem.name = "marginalia"
|
10
10
|
gem.require_paths = ["lib"]
|
11
|
-
gem.version = "1.
|
11
|
+
gem.version = "1.11.0"
|
12
12
|
gem.license = "MIT"
|
13
13
|
|
14
|
-
gem.add_runtime_dependency "actionpack", ">= 2
|
15
|
-
gem.add_runtime_dependency "activerecord", ">= 2
|
14
|
+
gem.add_runtime_dependency "actionpack", ">= 5.2"
|
15
|
+
gem.add_runtime_dependency "activerecord", ">= 5.2"
|
16
16
|
gem.add_development_dependency "rake"
|
17
17
|
gem.add_development_dependency "mysql2"
|
18
18
|
gem.add_development_dependency "pg"
|
data/test/query_comments_test.rb
CHANGED
@@ -5,16 +5,8 @@ def using_rails_api?
|
|
5
5
|
ENV["TEST_RAILS_API"] == true
|
6
6
|
end
|
7
7
|
|
8
|
-
def
|
9
|
-
Gem::Version.new(
|
10
|
-
end
|
11
|
-
|
12
|
-
def active_job_available?
|
13
|
-
Gem::Version.new(Rails::VERSION::STRING) >= Gem::Version.new('4.2')
|
14
|
-
end
|
15
|
-
|
16
|
-
def adapter_pool_available?
|
17
|
-
Gem::Version.new(ActiveRecord::VERSION::STRING) >= Gem::Version.new('3.2.19')
|
8
|
+
def pool_db_config?
|
9
|
+
Gem::Version.new(ActiveRecord::VERSION::STRING) >= Gem::Version.new('6.1')
|
18
10
|
end
|
19
11
|
|
20
12
|
require "minitest/autorun"
|
@@ -23,16 +15,11 @@ require 'logger'
|
|
23
15
|
require 'pp'
|
24
16
|
require 'active_record'
|
25
17
|
require 'action_controller'
|
18
|
+
require 'active_job'
|
26
19
|
require 'sidekiq'
|
27
20
|
require 'sidekiq/testing'
|
28
21
|
|
29
|
-
|
30
|
-
require 'action_dispatch/middleware/request_id'
|
31
|
-
end
|
32
|
-
|
33
|
-
if active_job_available?
|
34
|
-
require 'active_job'
|
35
|
-
end
|
22
|
+
require 'action_dispatch/middleware/request_id'
|
36
23
|
|
37
24
|
if using_rails_api?
|
38
25
|
require 'rails-api/action_controller/api'
|
@@ -55,7 +42,7 @@ RAILS_ROOT = File.expand_path(File.dirname(__FILE__))
|
|
55
42
|
|
56
43
|
ActiveRecord::Base.establish_connection({
|
57
44
|
:adapter => ENV["DRIVER"] || "mysql",
|
58
|
-
:host => "localhost",
|
45
|
+
:host => ENV["DB_HOST"] || "localhost",
|
59
46
|
:username => ENV["DB_USERNAME"] || "root",
|
60
47
|
:database => "marginalia_test"
|
61
48
|
})
|
@@ -81,11 +68,9 @@ module API
|
|
81
68
|
end
|
82
69
|
end
|
83
70
|
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
Post.first
|
88
|
-
end
|
71
|
+
class PostsJob < ActiveJob::Base
|
72
|
+
def perform
|
73
|
+
Post.first
|
89
74
|
end
|
90
75
|
end
|
91
76
|
|
@@ -116,6 +101,9 @@ Marginalia::Railtie.insert
|
|
116
101
|
|
117
102
|
class MarginaliaTest < MiniTest::Test
|
118
103
|
def setup
|
104
|
+
# Touch the model to avoid spurious schema queries
|
105
|
+
Post.first
|
106
|
+
|
119
107
|
@queries = []
|
120
108
|
ActiveSupport::Notifications.subscribe "sql.active_record" do |*args|
|
121
109
|
@queries << args.last[:sql]
|
@@ -132,7 +120,6 @@ class MarginaliaTest < MiniTest::Test
|
|
132
120
|
end
|
133
121
|
|
134
122
|
def test_exists
|
135
|
-
skip if Gem::Version.new(ActiveRecord::VERSION::STRING) < Gem::Version.new('3.2')
|
136
123
|
Post.exists?
|
137
124
|
assert_match %r{/\*application:rails\*/$}, @queries.last
|
138
125
|
end
|
@@ -238,19 +225,29 @@ class MarginaliaTest < MiniTest::Test
|
|
238
225
|
assert_match %r{/\*controller_with_namespace:API::V1::PostsController}, @queries.first
|
239
226
|
end
|
240
227
|
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
end
|
228
|
+
def test_db_host
|
229
|
+
Marginalia::Comment.components = [:db_host]
|
230
|
+
API::V1::PostsController.action(:driver_only).call(@env)
|
231
|
+
assert_match %r{/\*db_host:#{ENV["DB_HOST"] || "localhost"}}, @queries.first
|
232
|
+
end
|
247
233
|
|
248
|
-
|
249
|
-
|
234
|
+
def test_database
|
235
|
+
Marginalia::Comment.components = [:database]
|
236
|
+
API::V1::PostsController.action(:driver_only).call(@env)
|
237
|
+
assert_match %r{/\*database:marginalia_test}, @queries.first
|
238
|
+
end
|
239
|
+
|
240
|
+
if pool_db_config?
|
241
|
+
def test_socket
|
242
|
+
# setting socket in configuration would break some connections - mock it instead
|
243
|
+
pool = ActiveRecord::Base.connection_pool
|
244
|
+
pool.db_config.stubs(:configuration_hash).returns({:socket => "marginalia_socket"})
|
245
|
+
Marginalia::Comment.components = [:socket]
|
250
246
|
API::V1::PostsController.action(:driver_only).call(@env)
|
251
|
-
assert_match %r{/\*
|
247
|
+
assert_match %r{/\*socket:marginalia_socket}, @queries.first
|
248
|
+
pool.db_config.unstub(:configuration_hash)
|
252
249
|
end
|
253
|
-
|
250
|
+
else
|
254
251
|
def test_socket
|
255
252
|
# setting socket in configuration would break some connections - mock it instead
|
256
253
|
pool = ActiveRecord::Base.connection_pool
|
@@ -262,46 +259,34 @@ class MarginaliaTest < MiniTest::Test
|
|
262
259
|
end
|
263
260
|
end
|
264
261
|
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
assert_match %r{/\*request_id:some-uuid.*}, @queries.first
|
271
|
-
|
272
|
-
if using_rails_api?
|
273
|
-
PostsApiController.action(:driver_only).call(@env)
|
274
|
-
assert_match %r{/\*request_id:some-uuid.*}, @queries.second
|
275
|
-
end
|
276
|
-
end
|
262
|
+
def test_request_id
|
263
|
+
@env["action_dispatch.request_id"] = "some-uuid"
|
264
|
+
Marginalia::Comment.components = [:request_id]
|
265
|
+
PostsController.action(:driver_only).call(@env)
|
266
|
+
assert_match %r{/\*request_id:some-uuid.*}, @queries.first
|
277
267
|
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
Marginalia::Comment.components = [:request_id]
|
282
|
-
PostsController.action(:driver_only).call(@env)
|
283
|
-
assert_match %r{^select id from posts$}, @queries.first
|
268
|
+
if using_rails_api?
|
269
|
+
PostsApiController.action(:driver_only).call(@env)
|
270
|
+
assert_match %r{/\*request_id:some-uuid.*}, @queries.second
|
284
271
|
end
|
285
272
|
end
|
286
273
|
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
assert_match %{job:PostsJob}, @queries.first
|
274
|
+
def test_active_job
|
275
|
+
Marginalia::Comment.components = [:job]
|
276
|
+
PostsJob.perform_later
|
277
|
+
assert_match %{job:PostsJob}, @queries.first
|
292
278
|
|
293
|
-
|
294
|
-
|
295
|
-
|
279
|
+
Post.first
|
280
|
+
refute_match %{job:PostsJob}, @queries.last
|
281
|
+
end
|
296
282
|
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
283
|
+
def test_active_job_with_sidekiq
|
284
|
+
Marginalia::Comment.components = [:job, :sidekiq_job]
|
285
|
+
PostsJob.perform_later
|
286
|
+
assert_match %{job:PostsJob}, @queries.first
|
301
287
|
|
302
|
-
|
303
|
-
|
304
|
-
end
|
288
|
+
Post.first
|
289
|
+
refute_match %{job:PostsJob}, @queries.last
|
305
290
|
end
|
306
291
|
|
307
292
|
def test_sidekiq_job
|
metadata
CHANGED
@@ -1,16 +1,36 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: marginalia
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.11.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Noah Lorang
|
8
8
|
- Nick Quaranto
|
9
9
|
- Taylor Weibley
|
10
|
-
autorequire:
|
10
|
+
autorequire:
|
11
11
|
bindir: bin
|
12
|
-
cert_chain:
|
13
|
-
|
12
|
+
cert_chain:
|
13
|
+
- |
|
14
|
+
-----BEGIN CERTIFICATE-----
|
15
|
+
MIIDKDCCAhCgAwIBAgIBCDANBgkqhkiG9w0BAQsFADA6MQ0wCwYDVQQDDARzajI2
|
16
|
+
MRQwEgYKCZImiZPyLGQBGRYEc2oyNjETMBEGCgmSJomT8ixkARkWA2NvbTAeFw0y
|
17
|
+
MTA0MjcwMzIxMjZaFw0yMjA0MjcwMzIxMjZaMDoxDTALBgNVBAMMBHNqMjYxFDAS
|
18
|
+
BgoJkiaJk/IsZAEZFgRzajI2MRMwEQYKCZImiZPyLGQBGRYDY29tMIIBIjANBgkq
|
19
|
+
hkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAsr60Eo/ttCk8GMTMFiPr3GoYMIMFvLak
|
20
|
+
xSmTk9YGCB6UiEePB4THSSA5w6IPyeaCF/nWkDp3/BAam0eZMWG1IzYQB23TqIM0
|
21
|
+
1xzcNRvFsn0aQoQ00k+sj+G83j3T5OOV5OZIlu8xAChMkQmiPd1NXc6uFv+Iacz7
|
22
|
+
kj+CMsI9YUFdNoU09QY0b+u+Rb6wDYdpyvN60YC30h0h1MeYbvYZJx/iZK4XY5zu
|
23
|
+
4O/FL2ChjL2CPCpLZW55ShYyrzphWJwLOJe+FJ/ZBl6YXwrzQM9HKnt4titSNvyU
|
24
|
+
KzE3L63A3PZvExzLrN9u09kuWLLJfXB2sGOlw3n9t72rJiuBr3/OQQIDAQABozkw
|
25
|
+
NzAJBgNVHRMEAjAAMAsGA1UdDwQEAwIEsDAdBgNVHQ4EFgQU99dfRjEKFyczTeIz
|
26
|
+
m3ZsDWrNC80wDQYJKoZIhvcNAQELBQADggEBAInkmTwBeGEJ7Xu9jjZIuFaE197m
|
27
|
+
YfvrzVoE6Q1DlWXpgyhhxbPIKg2acvM/Z18A7kQrF7paYl64Ti84dC64seOFIBNx
|
28
|
+
Qj/lxzPHMBoAYqeXYJhnYIXnvGCZ4Fkic5Bhs+VdcDP/uwYp3adqy+4bT/XDFZQg
|
29
|
+
tSjrAOTg3wck5aI+Tz90ONQJ83bnCRr1UPQ0T3PbWMjnNsEa9CAxUB845Sg+9yUz
|
30
|
+
Tvf+pbX8JT9rawFDogxPhL7eRAbjg4MH9amp5l8HTVCAsW8vqv7wM4rtMNAaXmik
|
31
|
+
LJghfDEf70fTtbs4Zv57pPhn1b7wBNf8fh+TZOlYAA6dFtQXoCwfE6bWgQU=
|
32
|
+
-----END CERTIFICATE-----
|
33
|
+
date: 2021-08-14 00:00:00.000000000 Z
|
14
34
|
dependencies:
|
15
35
|
- !ruby/object:Gem::Dependency
|
16
36
|
name: actionpack
|
@@ -18,28 +38,28 @@ dependencies:
|
|
18
38
|
requirements:
|
19
39
|
- - ">="
|
20
40
|
- !ruby/object:Gem::Version
|
21
|
-
version: '2
|
41
|
+
version: '5.2'
|
22
42
|
type: :runtime
|
23
43
|
prerelease: false
|
24
44
|
version_requirements: !ruby/object:Gem::Requirement
|
25
45
|
requirements:
|
26
46
|
- - ">="
|
27
47
|
- !ruby/object:Gem::Version
|
28
|
-
version: '2
|
48
|
+
version: '5.2'
|
29
49
|
- !ruby/object:Gem::Dependency
|
30
50
|
name: activerecord
|
31
51
|
requirement: !ruby/object:Gem::Requirement
|
32
52
|
requirements:
|
33
53
|
- - ">="
|
34
54
|
- !ruby/object:Gem::Version
|
35
|
-
version: '2
|
55
|
+
version: '5.2'
|
36
56
|
type: :runtime
|
37
57
|
prerelease: false
|
38
58
|
version_requirements: !ruby/object:Gem::Requirement
|
39
59
|
requirements:
|
40
60
|
- - ">="
|
41
61
|
- !ruby/object:Gem::Version
|
42
|
-
version: '2
|
62
|
+
version: '5.2'
|
43
63
|
- !ruby/object:Gem::Dependency
|
44
64
|
name: rake
|
45
65
|
requirement: !ruby/object:Gem::Requirement
|
@@ -145,19 +165,13 @@ executables: []
|
|
145
165
|
extensions: []
|
146
166
|
extra_rdoc_files: []
|
147
167
|
files:
|
168
|
+
- ".github/workflows/ci.yml"
|
148
169
|
- ".gitignore"
|
149
170
|
- ".ruby-version"
|
150
|
-
- ".travis.yml"
|
151
171
|
- Gemfile
|
152
172
|
- LICENSE
|
153
173
|
- README.md
|
154
174
|
- Rakefile
|
155
|
-
- gemfiles/4.2.api.gemfile
|
156
|
-
- gemfiles/4.2.gemfile
|
157
|
-
- gemfiles/5.0.gemfile
|
158
|
-
- gemfiles/5.1.gemfile
|
159
|
-
- gemfiles/5.2.gemfile
|
160
|
-
- init.rb
|
161
175
|
- lib/marginalia.rb
|
162
176
|
- lib/marginalia/comment.rb
|
163
177
|
- lib/marginalia/railtie.rb
|
@@ -168,7 +182,7 @@ homepage: https://github.com/basecamp/marginalia
|
|
168
182
|
licenses:
|
169
183
|
- MIT
|
170
184
|
metadata: {}
|
171
|
-
post_install_message:
|
185
|
+
post_install_message:
|
172
186
|
rdoc_options: []
|
173
187
|
require_paths:
|
174
188
|
- lib
|
@@ -183,8 +197,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
183
197
|
- !ruby/object:Gem::Version
|
184
198
|
version: '0'
|
185
199
|
requirements: []
|
186
|
-
rubygems_version: 3.
|
187
|
-
signing_key:
|
200
|
+
rubygems_version: 3.2.25
|
201
|
+
signing_key:
|
188
202
|
specification_version: 4
|
189
203
|
summary: Attach comments to your ActiveRecord queries.
|
190
204
|
test_files: []
|
metadata.gz.sig
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
YJ�11X��/:�Zl�kQ�1S$>�m��6��`?6�É����۬J?f����`�zr�!CHGZ�2���H#�4Nb�^�n2���>���<��n�u��O�o%Uuˣ�s䂛 [�L���l.T��� �]\�3�\����Բ�i}��E�;����L�5�>�V��]5Ұ�W�����Lu"ٖ[�y���̡$TZ���3�~n�
|
data/.travis.yml
DELETED
@@ -1,34 +0,0 @@
|
|
1
|
-
language: ruby
|
2
|
-
sudo: false
|
3
|
-
|
4
|
-
services:
|
5
|
-
- mysql
|
6
|
-
- postgresql
|
7
|
-
|
8
|
-
rvm:
|
9
|
-
- 2.2
|
10
|
-
- 2.3
|
11
|
-
- 2.4
|
12
|
-
- 2.5
|
13
|
-
- 2.6
|
14
|
-
- 2.7
|
15
|
-
|
16
|
-
services:
|
17
|
-
- mysql
|
18
|
-
- postgresql
|
19
|
-
|
20
|
-
script: "bundle exec rake db:reset test:all"
|
21
|
-
|
22
|
-
gemfile:
|
23
|
-
- gemfiles/4.2.gemfile
|
24
|
-
- gemfiles/4.2.api.gemfile
|
25
|
-
- gemfiles/5.0.gemfile
|
26
|
-
- gemfiles/5.1.gemfile
|
27
|
-
- gemfiles/5.2.gemfile
|
28
|
-
|
29
|
-
matrix:
|
30
|
-
exclude:
|
31
|
-
- rvm: 2.7
|
32
|
-
gemfile: gemfiles/4.2.gemfile
|
33
|
-
- rvm: 2.7
|
34
|
-
gemfile: gemfiles/4.2.api.gemfile
|
data/gemfiles/4.2.api.gemfile
DELETED
data/gemfiles/4.2.gemfile
DELETED
data/gemfiles/5.0.gemfile
DELETED
data/gemfiles/5.1.gemfile
DELETED
data/gemfiles/5.2.gemfile
DELETED
data/init.rb
DELETED