summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouwe Maan <douwe@gitlab.com>2018-05-07 08:46:23 +0000
committerDouwe Maan <douwe@gitlab.com>2018-05-07 08:46:23 +0000
commitf460e2dc0fd38090621fe71b20d2e87d16e6d85b (patch)
treec598e36f6d9228665afc2838ffbce7c1abd840f8
parent1492cf8f5792b436d6366e6cad20a708a19ea662 (diff)
parenta9d0deebd2813c2bd070e6bfedc71fa9fadb2ad0 (diff)
downloadgitlab-ce-f460e2dc0fd38090621fe71b20d2e87d16e6d85b.tar.gz
Merge branch 'issue_43660' into 'master'
Enable prometheus metrics by default Closes #43660 See merge request gitlab-org/gitlab-ce!18723
-rw-r--r--changelogs/unreleased/issue_43660.yml5
-rw-r--r--config/initializers/8_metrics.rb9
-rw-r--r--db/migrate/20180503200320_enable_prometheus_metrics_by_default.rb11
-rw-r--r--db/schema.rb4
-rw-r--r--spec/db/production/settings_spec.rb6
5 files changed, 29 insertions, 6 deletions
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