2019-12-13 16:07:41 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Gitlab
|
|
|
|
module Marginalia
|
2020-01-23 10:08:46 -05:00
|
|
|
cattr_accessor :enabled, default: false
|
|
|
|
|
2019-12-13 16:07:41 -05:00
|
|
|
MARGINALIA_FEATURE_FLAG = :marginalia
|
|
|
|
|
|
|
|
def self.set_application_name
|
|
|
|
::Marginalia.application_name = Gitlab.process_name
|
|
|
|
end
|
|
|
|
|
|
|
|
def self.enable_sidekiq_instrumentation
|
|
|
|
if Sidekiq.server?
|
|
|
|
::Marginalia::SidekiqInstrumentation.enable!
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def self.cached_feature_enabled?
|
2020-01-23 10:08:46 -05:00
|
|
|
enabled
|
2019-12-13 16:07:41 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def self.set_feature_cache
|
|
|
|
# During db:create and db:bootstrap skip feature query as DB is not available yet.
|
2020-02-17 19:09:20 -05:00
|
|
|
return false unless Gitlab::Database.cached_table_exists?('features')
|
2019-12-13 16:07:41 -05:00
|
|
|
|
2020-01-23 10:08:46 -05:00
|
|
|
self.enabled = Feature.enabled?(MARGINALIA_FEATURE_FLAG)
|
2019-12-13 16:07:41 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|