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 ...@@ -211,7 +211,6 @@ module ApplicationSettingsHelper
:polling_interval_multiplier, :polling_interval_multiplier,
:project_export_enabled, :project_export_enabled,
:prometheus_metrics_enabled, :prometheus_metrics_enabled,
:prometheus_metrics_method_instrumentation_enabled,
:recaptcha_enabled, :recaptcha_enabled,
:recaptcha_private_key, :recaptcha_private_key,
:recaptcha_site_key, :recaptcha_site_key,
......
...@@ -361,14 +361,6 @@ ...@@ -361,14 +361,6 @@
%code prometheus_multiproc_dir %code prometheus_multiproc_dir
does not exist or is not pointing to a valid directory. 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') = 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 %fieldset
%legend Profiling - Performance Bar %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 @@ ...@@ -11,7 +11,7 @@
# #
# It's strongly recommended that you check this file into your version control system. # 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 # These are extensions that must be enabled in order to support this database
enable_extension "plpgsql" enable_extension "plpgsql"
...@@ -149,7 +149,6 @@ ActiveRecord::Schema.define(version: 20171122211913) do ...@@ -149,7 +149,6 @@ ActiveRecord::Schema.define(version: 20171122211913) do
t.boolean "throttle_authenticated_web_enabled", default: false, null: false 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_requests_per_period", default: 7200, null: false
t.integer "throttle_authenticated_web_period_in_seconds", default: 3600, 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 end
create_table "audit_events", force: :cascade do |t| create_table "audit_events", force: :cascade do |t|
......
...@@ -66,9 +66,6 @@ module API ...@@ -66,9 +66,6 @@ module API
optional :max_pages_size, type: Integer, desc: 'Maximum size of pages in MB' 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 :container_registry_token_expire_delay, type: Integer, desc: 'Authorization token duration (minutes)'
optional :prometheus_metrics_enabled, type: Boolean, desc: 'Enable Prometheus metrics' 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' optional :metrics_enabled, type: Boolean, desc: 'Enable the InfluxDB metrics'
given metrics_enabled: ->(val) { val } do given metrics_enabled: ->(val) { val } do
requires :metrics_host, type: String, desc: 'The InfluxDB host' requires :metrics_host, type: String, desc: 'The InfluxDB host'
......
...@@ -45,7 +45,7 @@ module Gitlab ...@@ -45,7 +45,7 @@ module Gitlab
@cpu_time += cpu_time @cpu_time += cpu_time
@call_count += 1 @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) self.class.call_duration_histogram.observe(@transaction.labels.merge(labels), real_time / 1000.0)
end end
...@@ -71,8 +71,8 @@ module Gitlab ...@@ -71,8 +71,8 @@ module Gitlab
real_time >= Metrics.method_call_threshold real_time >= Metrics.method_call_threshold
end end
def prometheus_enabled? def call_measurement_enabled?
@prometheus_enabled ||= Gitlab::CurrentSettings.current_application_settings[:prometheus_metrics_method_instrumentation_enabled] Feature.get(:prometheus_metrics_method_instrumentation).enabled?
end end
end end
end end
......
...@@ -20,8 +20,7 @@ describe Gitlab::Metrics::MethodCall do ...@@ -20,8 +20,7 @@ describe Gitlab::Metrics::MethodCall do
context 'prometheus instrumentation is enabled' do context 'prometheus instrumentation is enabled' do
before do before do
allow(Gitlab::CurrentSettings).to receive(:current_application_settings) Feature.get(:prometheus_metrics_method_instrumentation).enable
.and_return(prometheus_metrics_method_instrumentation_enabled: true)
end end
it 'observes the performance of the supplied block' do it 'observes the performance of the supplied block' do
...@@ -35,8 +34,7 @@ describe Gitlab::Metrics::MethodCall do ...@@ -35,8 +34,7 @@ describe Gitlab::Metrics::MethodCall do
context 'prometheus instrumentation is disabled' do context 'prometheus instrumentation is disabled' do
before do before do
allow(Gitlab::CurrentSettings).to receive(:current_application_settings) Feature.get(:prometheus_metrics_method_instrumentation).disable
.and_return(prometheus_metrics_method_instrumentation_enabled: false)
end end
it 'does not observe the performance' do it 'does not observe the performance' do
...@@ -52,8 +50,7 @@ describe Gitlab::Metrics::MethodCall do ...@@ -52,8 +50,7 @@ describe Gitlab::Metrics::MethodCall do
before do before do
allow(method_call).to receive(:above_threshold?).and_return(false) allow(method_call).to receive(:above_threshold?).and_return(false)
allow(Gitlab::CurrentSettings).to receive(:current_application_settings) Feature.get(:prometheus_metrics_method_instrumentation).enable
.and_return(prometheus_metrics_method_instrumentation_enabled: true)
end end
it 'does not observe the performance' do 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