Commit 8ba1caeb authored by Albert Salim's avatar Albert Salim

Merge branch 'improve_transactions_stack_logging' into 'master'

Improve preciseness of transaction stack logging

See merge request gitlab-org/gitlab!80447
parents fc1044a2 6e575dea
......@@ -7,6 +7,11 @@ module CrossDatabaseModification
DEBUG_STACK = Rails.env.test? && ENV['DEBUG_GITLAB_TRANSACTION_STACK']
LOG_FILENAME = Rails.root.join("log", "gitlab_transaction_stack.log")
EXCLUDE_DEBUG_TRACE = %w[
lib/gitlab/database/query_analyzer
app/models/concerns/cross_database_modification.rb
].freeze
def self.logger
@logger ||= Logger.new(LOG_FILENAME, formatter: ->(_, _, _, msg) { Gitlab::Json.dump(msg) + "\n" })
end
......@@ -18,7 +23,7 @@ module CrossDatabaseModification
message += " in example #{example}" if example
cleaned_backtrace = Gitlab::BacktraceCleaner.clean_backtrace(caller)
.reject { |line| line.include?('lib/gitlab/database/query_analyzer') }
.reject { |line| EXCLUDE_DEBUG_TRACE.any? { |exclusion| line.include?(exclusion) } }
.first(5)
logger.warn({
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment