Commit 46cd2d93 authored by Pawel Chojnacki's avatar Pawel Chojnacki

Use feature flag instead of application settigns to control if method calls should be instrumented

parent 0ae2d9e6
......@@ -211,7 +211,6 @@ module ApplicationSettingsHelper
:polling_interval_multiplier,
:project_export_enabled,
:prometheus_metrics_enabled,
:prometheus_metrics_method_instrumentation_enabled,
:recaptcha_enabled,
:recaptcha_private_key,
:recaptcha_site_key,
......
......@@ -361,14 +361,6 @@
%code prometheus_multiproc_dir
does not exist or is not pointing to a valid directory.
= link_to icon('question-circle'), help_page_path('administration/monitoring/prometheus/gitlab_metrics', anchor: 'metrics-shared-directory')
.form-group
.col-sm-offset-2.col-sm-10
.checkbox
= f.label :prometheus_metrics_method_instrumentation_enabled do
= f.check_box :prometheus_metrics_method_instrumentation_enabled
Track method execution time.
.help-block
Provides method execution metrics. Can adversely impact GitLab's responsiveness.
%fieldset
%legend Profiling - Performance Bar
......
class AddPrometheusInstrumentationToApplicationSettings < ActiveRecord::Migration
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
disable_ddl_transaction!
def up
add_column_with_default(:application_settings, :prometheus_metrics_method_instrumentation_enabled, :boolean,
default: false, allow_null: false)
end
def down
remove_column(:application_settings, :prometheus_metrics_method_instrumentation_enabled)
end
end
......@@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20171122211913) do
ActiveRecord::Schema.define(version: 20171121144800) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
......@@ -149,7 +149,6 @@ ActiveRecord::Schema.define(version: 20171122211913) do
t.boolean "throttle_authenticated_web_enabled", default: false, null: false
t.integer "throttle_authenticated_web_requests_per_period", default: 7200, null: false
t.integer "throttle_authenticated_web_period_in_seconds", default: 3600, null: false
t.boolean "prometheus_metrics_method_instrumentation_enabled", default: false, null: false
end
create_table "audit_events", force: :cascade do |t|
......
......@@ -66,9 +66,6 @@ module API
optional :max_pages_size, type: Integer, desc: 'Maximum size of pages in MB'
optional :container_registry_token_expire_delay, type: Integer, desc: 'Authorization token duration (minutes)'
optional :prometheus_metrics_enabled, type: Boolean, desc: 'Enable Prometheus metrics'
given prometheus_metrics_enabled: ->(val) { val } do
requires :prometheus_metrics_method_instrumentation_enabled, type: Boolean, desc: 'Enable method call instrumentation'
end
optional :metrics_enabled, type: Boolean, desc: 'Enable the InfluxDB metrics'
given metrics_enabled: ->(val) { val } do
requires :metrics_host, type: String, desc: 'The InfluxDB host'
......
......@@ -45,7 +45,7 @@ module Gitlab
@cpu_time += cpu_time
@call_count += 1
if prometheus_enabled? && above_threshold?
if call_measurement_enabled? && above_threshold?
self.class.call_duration_histogram.observe(@transaction.labels.merge(labels), real_time / 1000.0)
end
......@@ -71,8 +71,8 @@ module Gitlab
real_time >= Metrics.method_call_threshold
end
def prometheus_enabled?
@prometheus_enabled ||= Gitlab::CurrentSettings.current_application_settings[:prometheus_metrics_method_instrumentation_enabled]
def call_measurement_enabled?
Feature.get(:prometheus_metrics_method_instrumentation).enabled?
end
end
end
......
......@@ -20,8 +20,7 @@ describe Gitlab::Metrics::MethodCall do
context 'prometheus instrumentation is enabled' do
before do
allow(Gitlab::CurrentSettings).to receive(:current_application_settings)
.and_return(prometheus_metrics_method_instrumentation_enabled: true)
Feature.get(:prometheus_metrics_method_instrumentation).enable
end
it 'observes the performance of the supplied block' do
......@@ -35,8 +34,7 @@ describe Gitlab::Metrics::MethodCall do
context 'prometheus instrumentation is disabled' do
before do
allow(Gitlab::CurrentSettings).to receive(:current_application_settings)
.and_return(prometheus_metrics_method_instrumentation_enabled: false)
Feature.get(:prometheus_metrics_method_instrumentation).disable
end
it 'does not observe the performance' do
......@@ -52,8 +50,7 @@ describe Gitlab::Metrics::MethodCall do
before do
allow(method_call).to receive(:above_threshold?).and_return(false)
allow(Gitlab::CurrentSettings).to receive(:current_application_settings)
.and_return(prometheus_metrics_method_instrumentation_enabled: true)
Feature.get(:prometheus_metrics_method_instrumentation).enable
end
it 'does not observe the performance' do
......
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