2019-12-13 16:07:41 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'marginalia'
|
|
|
|
|
|
|
|
::Marginalia::Comment.extend(::Gitlab::Marginalia::Comment)
|
|
|
|
|
2021-02-12 19:09:10 -05:00
|
|
|
# By default, PostgreSQL only tracks the first 1024 bytes of a SQL
|
|
|
|
# query. Prepending the comment allows us to trace the source of the
|
|
|
|
# query without having to increase the `track_activity_query_size`
|
|
|
|
# parameter.
|
2021-02-25 19:11:20 -05:00
|
|
|
#
|
|
|
|
# We only enable this in production because a number of tests do string
|
|
|
|
# matching against the raw SQL, and prepending the comment prevents color
|
|
|
|
# coding from working in the development log.
|
|
|
|
Marginalia::Comment.prepend_comment = true if Rails.env.production?
|
2021-09-15 08:11:13 -04:00
|
|
|
Marginalia::Comment.components = [:application, :correlation_id, :jid, :endpoint_id, :db_config_name]
|
2020-02-28 22:07:51 -05:00
|
|
|
|
|
|
|
# As mentioned in https://github.com/basecamp/marginalia/pull/93/files,
|
|
|
|
# adding :line has some overhead because a regexp on the backtrace has
|
|
|
|
# to be run on every SQL query. Only enable this in development because
|
|
|
|
# we've seen it slow things down.
|
2021-10-19 08:12:07 -04:00
|
|
|
if Rails.env.development?
|
|
|
|
Marginalia::Comment.components << :line
|
|
|
|
Marginalia::Comment.lines_to_ignore = Regexp.union(Gitlab::BacktraceCleaner::IGNORE_BACKTRACES + %w(lib/ruby/gems/ lib/gem_extensions/ lib/ruby/))
|
|
|
|
end
|
2019-12-13 16:07:41 -05:00
|
|
|
|
|
|
|
Gitlab::Marginalia.set_application_name
|
|
|
|
|
|
|
|
Gitlab::Marginalia.enable_sidekiq_instrumentation
|