diff options
author | Pawel Chojnacki <pawel@chojnacki.ws> | 2017-11-23 23:30:57 +0100 |
---|---|---|
committer | Pawel Chojnacki <pawel@chojnacki.ws> | 2017-11-23 23:39:10 +0100 |
commit | 46cd2d93bb23807b76bf20bb06e6ef93f1985ad9 (patch) | |
tree | 171d9dae2c548785e7f8c1088ade52c51f2e54a3 | |
parent | 0ae2d9e68df24f5aeda56e8fb934aa980a3b76c2 (diff) | |
download | gitlab-ce-pawel/update_prometheus_gem_to_well_tested_version.tar.gz |
Use feature flag instead of application settigns to control if method calls should be instrumentedpawel/update_prometheus_gem_to_well_tested_version
-rw-r--r-- | app/helpers/application_settings_helper.rb | 1 | ||||
-rw-r--r-- | app/views/admin/application_settings/_form.html.haml | 8 | ||||
-rw-r--r-- | db/migrate/20171122211913_add_prometheus_instrumentation_to_application_settings.rb | 15 | ||||
-rw-r--r-- | db/schema.rb | 3 | ||||
-rw-r--r-- | lib/api/settings.rb | 3 | ||||
-rw-r--r-- | lib/gitlab/metrics/method_call.rb | 6 | ||||
-rw-r--r-- | spec/lib/gitlab/metrics/method_call_spec.rb | 9 |
7 files changed, 7 insertions, 38 deletions
diff --git a/app/helpers/application_settings_helper.rb b/app/helpers/application_settings_helper.rb index f776cd31438..e5d2693b01e 100644 --- a/app/helpers/application_settings_helper.rb +++ b/app/helpers/application_settings_helper.rb @@ -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, diff --git a/app/views/admin/application_settings/_form.html.haml b/app/views/admin/application_settings/_form.html.haml index 0037d547855..12658dddc06 100644 --- a/app/views/admin/application_settings/_form.html.haml +++ b/app/views/admin/application_settings/_form.html.haml @@ -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 diff --git a/db/migrate/20171122211913_add_prometheus_instrumentation_to_application_settings.rb b/db/migrate/20171122211913_add_prometheus_instrumentation_to_application_settings.rb deleted file mode 100644 index c25646ead9d..00000000000 --- a/db/migrate/20171122211913_add_prometheus_instrumentation_to_application_settings.rb +++ /dev/null @@ -1,15 +0,0 @@ -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 diff --git a/db/schema.rb b/db/schema.rb index 48afc475209..a82270390f1 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -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| diff --git a/lib/api/settings.rb b/lib/api/settings.rb index a43f8d0497c..851b226e9e5 100644 --- a/lib/api/settings.rb +++ b/lib/api/settings.rb @@ -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' diff --git a/lib/gitlab/metrics/method_call.rb b/lib/gitlab/metrics/method_call.rb index 518aefa19ee..65d55576ac2 100644 --- a/lib/gitlab/metrics/method_call.rb +++ b/lib/gitlab/metrics/method_call.rb @@ -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 diff --git a/spec/lib/gitlab/metrics/method_call_spec.rb b/spec/lib/gitlab/metrics/method_call_spec.rb index b20c9e227d6..5341addf911 100644 --- a/spec/lib/gitlab/metrics/method_call_spec.rb +++ b/spec/lib/gitlab/metrics/method_call_spec.rb @@ -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 |