Last active
April 26, 2021 14:35
-
-
Save LimeBlast/ae36fb67c0892a1bb120e5ee1bbdd83e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
NoMethodError: undefined method `trace_id' for Marginalia::Comment:Module | |
/app/vendor/bundle/ruby/2.5.0/gems/marginalia-1.10.1/lib/marginalia/comment.rb:25:in `block in construct_comment' | |
/app/vendor/bundle/ruby/2.5.0/gems/marginalia-1.10.1/lib/marginalia/comment.rb:24:in `each' | |
/app/vendor/bundle/ruby/2.5.0/gems/marginalia-1.10.1/lib/marginalia/comment.rb:24:in `construct_comment' | |
/app/vendor/bundle/ruby/2.5.0/gems/marginalia-1.10.1/lib/marginalia.rb:50:in `annotate_sql' | |
/app/vendor/bundle/ruby/2.5.0/gems/marginalia-1.10.1/lib/marginalia.rb:71:in `execute_with_marginalia' | |
/app/vendor/bundle/ruby/2.5.0/gems/activerecord-4.2.11.19/lib/active_record/connection_adapters/postgresql/schema_statements.rb:286:in `client_min_messages=' | |
/app/vendor/bundle/ruby/2.5.0/gems/activerecord-4.2.11.19/lib/active_record/connection_adapters/postgresql_adapter.rb:673:in `configure_connection' | |
/app/vendor/bundle/ruby/2.5.0/gems/activerecord-4.2.11.19/lib/active_record/connection_adapters/postgresql_adapter.rb:658:in `connect' | |
/app/vendor/bundle/ruby/2.5.0/gems/activerecord-4.2.11.19/lib/active_record/connection_adapters/postgresql_adapter.rb:242:in `initialize' | |
/app/vendor/bundle/ruby/2.5.0/gems/activerecord-4.2.11.19/lib/active_record/connection_adapters/postgresql_adapter.rb:44:in `new' | |
/app/vendor/bundle/ruby/2.5.0/gems/activerecord-4.2.11.19/lib/active_record/connection_adapters/postgresql_adapter.rb:44:in `postgresql_connection' | |
/app/vendor/bundle/ruby/2.5.0/gems/activerecord-4.2.11.19/lib/active_record/connection_adapters/abstract/connection_pool.rb:438:in `new_connection' | |
/app/vendor/bundle/ruby/2.5.0/gems/activerecord-4.2.11.19/lib/active_record/connection_adapters/abstract/connection_pool.rb:448:in `checkout_new_connection' | |
/app/vendor/bundle/ruby/2.5.0/gems/activerecord-4.2.11.19/lib/active_record/connection_adapters/abstract/connection_pool.rb:422:in `acquire_connection' | |
/app/vendor/bundle/ruby/2.5.0/gems/activerecord-4.2.11.19/lib/active_record/connection_adapters/abstract/connection_pool.rb:349:in `block in checkout' | |
/app/vendor/bundle/ruby/2.5.0/gems/activerecord-4.2.11.19/lib/active_record/connection_adapters/abstract/connection_pool.rb:348:in `checkout' | |
/app/vendor/bundle/ruby/2.5.0/gems/activerecord-4.2.11.19/lib/active_record/connection_adapters/abstract/connection_pool.rb:263:in `block in connection' | |
/app/vendor/bundle/ruby/2.5.0/gems/activerecord-4.2.11.19/lib/active_record/connection_adapters/abstract/connection_pool.rb:262:in `connection' | |
/app/vendor/bundle/ruby/2.5.0/gems/activerecord-4.2.11.19/lib/active_record/connection_adapters/abstract/connection_pool.rb:571:in `retrieve_connection' | |
/app/vendor/bundle/ruby/2.5.0/gems/activerecord-4.2.11.19/lib/active_record/connection_handling.rb:113:in `retrieve_connection' | |
/app/vendor/bundle/ruby/2.5.0/gems/activerecord-4.2.11.19/lib/active_record/connection_handling.rb:87:in `connection' | |
/app/vendor/bundle/ruby/2.5.0/gems/activerecord-4.2.11.19/lib/active_record/migration.rb:648:in `connection' | |
/app/vendor/bundle/ruby/2.5.0/gems/activerecord-4.2.11.19/lib/active_record/migration.rb:664:in `block in method_missing' | |
/app/vendor/bundle/ruby/2.5.0/gems/activerecord-4.2.11.19/lib/active_record/migration.rb:634:in `block in say_with_time' | |
/app/vendor/bundle/ruby/2.5.0/gems/activerecord-4.2.11.19/lib/active_record/migration.rb:634:in `say_with_time' | |
/app/vendor/bundle/ruby/2.5.0/gems/activerecord-4.2.11.19/lib/active_record/migration.rb:654:in `method_missing' | |
/app/db/schema.rb:17:in `block in <top (required)>' | |
/app/vendor/bundle/ruby/2.5.0/gems/activerecord-4.2.11.19/lib/active_record/schema.rb:41:in `instance_eval' | |
/app/vendor/bundle/ruby/2.5.0/gems/activerecord-4.2.11.19/lib/active_record/schema.rb:41:in `define' | |
/app/vendor/bundle/ruby/2.5.0/gems/activerecord-4.2.11.19/lib/active_record/schema.rb:61:in `define' | |
/app/db/schema.rb:14:in `<top (required)>' | |
/app/vendor/bundle/ruby/2.5.0/gems/activesupport-4.2.11.19/lib/active_support/dependencies.rb:268:in `load' | |
/app/vendor/bundle/ruby/2.5.0/gems/activesupport-4.2.11.19/lib/active_support/dependencies.rb:268:in `block in load' | |
/app/vendor/bundle/ruby/2.5.0/gems/activesupport-4.2.11.19/lib/active_support/dependencies.rb:240:in `load_dependency' | |
/app/vendor/bundle/ruby/2.5.0/gems/activesupport-4.2.11.19/lib/active_support/dependencies.rb:268:in `load' | |
/app/vendor/bundle/ruby/2.5.0/gems/activerecord-4.2.11.19/lib/active_record/tasks/database_tasks.rb:221:in `load_schema_for' | |
/app/vendor/bundle/ruby/2.5.0/gems/activerecord-4.2.11.19/lib/active_record/tasks/database_tasks.rb:238:in `block in load_schema_current' | |
/app/vendor/bundle/ruby/2.5.0/gems/activerecord-4.2.11.19/lib/active_record/tasks/database_tasks.rb:278:in `block in each_current_configuration' | |
/app/vendor/bundle/ruby/2.5.0/gems/activerecord-4.2.11.19/lib/active_record/tasks/database_tasks.rb:277:in `each' | |
/app/vendor/bundle/ruby/2.5.0/gems/activerecord-4.2.11.19/lib/active_record/tasks/database_tasks.rb:277:in `each_current_configuration' | |
/app/vendor/bundle/ruby/2.5.0/gems/activerecord-4.2.11.19/lib/active_record/tasks/database_tasks.rb:237:in `load_schema_current' | |
/app/vendor/bundle/ruby/2.5.0/gems/activerecord-4.2.11.19/lib/active_record/railties/databases.rake:237:in `block (3 levels) in <top (required)>' | |
/app/vendor/bundle/ruby/2.5.0/gems/activerecord-4.2.11.19/lib/active_record/railties/databases.rake:241:in `block (3 levels) in <top (required)>' | |
Tasks: TOP => db:schema:load | |
(See full trace by running task with --trace) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# frozen_string_literal: true | |
# Based on https://gist.github.com/lfittl/4d2d53b9a4d8b095acd9a175da1106c6 | |
# with references to sidekiq and sentry removed (as we don't use them). | |
module Marginalia | |
module Comment | |
# Having unique values like the request ID in BEGIN/COMMIT/ROLLBACK will bloat | |
# pg_stat_statements with unnecessary data, per the pg_stat_statements.c source: | |
# "For utility statements, we just hash the query string to get an ID." | |
# (which includes the comment string) | |
# | |
# Unfortunately we don't have easy access to the SQL statement text in this | |
# part of Marginalia, so we improvise with known call stacks that produce | |
# utility statements. | |
UTILITY_STATEMENT_CALLSTACK_FILTERS = [ | |
%r{/active_record/connection_adapters/postgresql/database_statements.rb:\d+:in `begin_db_transaction}, # BEGIN | |
%r{/active_record/connection_adapters/postgresql/database_statements.rb:\d+:in `commit_db_transaction}, # COMMIT | |
%r{/active_record/connection_adapters/postgresql/database_statements.rb:\d+:in `exec_rollback_db_transaction} # ROLLBACK | |
].freeze | |
def self.utility_statement? | |
callstack = caller | |
UTILITY_STATEMENT_CALLSTACK_FILTERS.any? do |filter| | |
callstack.any? { |s| s[filter] } | |
end | |
end | |
def self.request_id | |
return unless marginalia_controller.respond_to?(:request) && marginalia_controller.request.respond_to?(:uuid) | |
return if utility_statement? | |
marginalia_controller.request.uuid | |
end | |
def self.release | |
return unless ENV.key?('HEROKU_SLUG_COMMIT') | |
return if utility_statement? | |
ENV.fetch('HEROKU_SLUG_COMMIT') | |
end | |
end | |
end | |
Marginalia::Comment.lines_to_ignore = %r{\.rvm|gem|vendor/|marginalia|sentry|rbenv|/usr/local/lib/ruby} | |
Marginalia::Comment.components = %i[application controller action line job request_id release trace_id] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment