diff --git a/changelogs/unreleased/issue_43660.yml b/changelogs/unreleased/issue_43660.yml new file mode 100644 index 00000000000..d83c0ebcbb5 --- /dev/null +++ b/changelogs/unreleased/issue_43660.yml @@ -0,0 +1,5 @@ +--- +title: Enable prometheus monitoring by default +merge_request: +author: +type: other diff --git a/config/initializers/8_metrics.rb b/config/initializers/8_metrics.rb index 7cdf49159b4..8a851b89c56 100644 --- a/config/initializers/8_metrics.rb +++ b/config/initializers/8_metrics.rb @@ -119,7 +119,14 @@ def instrument_classes(instrumentation) end # rubocop:enable Metrics/AbcSize -if Gitlab::Metrics.enabled? +# With prometheus enabled by default this breaks all specs +# that stubs methods using `any_instance_of` for the models reloaded here. +# +# We should deprecate the usage of `any_instance_of` in the future +# check: https://github.com/rspec/rspec-mocks#settings-mocks-or-stubs-on-any-instance-of-a-class +# +# Related issue: https://gitlab.com/gitlab-org/gitlab-ce/issues/33587 +if Gitlab::Metrics.enabled? && !Rails.env.test? require 'pathname' require 'influxdb' require 'connection_pool' diff --git a/db/migrate/20180503200320_enable_prometheus_metrics_by_default.rb b/db/migrate/20180503200320_enable_prometheus_metrics_by_default.rb new file mode 100644 index 00000000000..2c8f86ff0f4 --- /dev/null +++ b/db/migrate/20180503200320_enable_prometheus_metrics_by_default.rb @@ -0,0 +1,11 @@ +class EnablePrometheusMetricsByDefault < ActiveRecord::Migration + DOWNTIME = false + + def up + change_column_default :application_settings, :prometheus_metrics_enabled, true + end + + def down + change_column_default :application_settings, :prometheus_metrics_enabled, false + end +end diff --git a/db/schema.rb b/db/schema.rb index 27c70c03612..1f592c019fa 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: 20180503175054) do +ActiveRecord::Schema.define(version: 20180503200320) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -134,7 +134,7 @@ ActiveRecord::Schema.define(version: 20180503175054) do t.integer "cached_markdown_version" t.boolean "clientside_sentry_enabled", default: false, null: false t.string "clientside_sentry_dsn" - t.boolean "prometheus_metrics_enabled", default: false, null: false + t.boolean "prometheus_metrics_enabled", default: true, null: false t.boolean "help_page_hide_commercial_content", default: false t.string "help_page_support_url" t.integer "performance_bar_allowed_group_id" diff --git a/spec/db/production/settings_spec.rb b/spec/db/production/settings_spec.rb index c8d016070f5..db19e98b851 100644 --- a/spec/db/production/settings_spec.rb +++ b/spec/db/production/settings_spec.rb @@ -48,15 +48,15 @@ describe 'seed production settings' do end end - context 'GITLAB_PROMETHEUS_METRICS_ENABLED is false' do + context 'GITLAB_PROMETHEUS_METRICS_ENABLED is default' do before do stub_env('GITLAB_PROMETHEUS_METRICS_ENABLED', '') end - it 'prometheus_metrics_enabled is set to false' do + it 'prometheus_metrics_enabled is set to true' do load(settings_file) - expect(settings.prometheus_metrics_enabled).to eq(false) + expect(settings.prometheus_metrics_enabled).to eq(true) end end end