Commit a9d0deeb authored by Felipe Artur's avatar Felipe Artur Committed by Douwe Maan

Enable prometheus metrics by default

parent 1492cf8f
---
title: Enable prometheus monitoring by default
merge_request:
author:
type: other
...@@ -119,7 +119,14 @@ def instrument_classes(instrumentation) ...@@ -119,7 +119,14 @@ def instrument_classes(instrumentation)
end end
# rubocop:enable Metrics/AbcSize # 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 'pathname'
require 'influxdb' require 'influxdb'
require 'connection_pool' require 'connection_pool'
......
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
...@@ -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: 20180503175054) do ActiveRecord::Schema.define(version: 20180503200320) 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"
...@@ -134,7 +134,7 @@ ActiveRecord::Schema.define(version: 20180503175054) do ...@@ -134,7 +134,7 @@ ActiveRecord::Schema.define(version: 20180503175054) do
t.integer "cached_markdown_version" t.integer "cached_markdown_version"
t.boolean "clientside_sentry_enabled", default: false, null: false t.boolean "clientside_sentry_enabled", default: false, null: false
t.string "clientside_sentry_dsn" 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.boolean "help_page_hide_commercial_content", default: false
t.string "help_page_support_url" t.string "help_page_support_url"
t.integer "performance_bar_allowed_group_id" t.integer "performance_bar_allowed_group_id"
......
...@@ -48,15 +48,15 @@ describe 'seed production settings' do ...@@ -48,15 +48,15 @@ describe 'seed production settings' do
end end
end end
context 'GITLAB_PROMETHEUS_METRICS_ENABLED is false' do context 'GITLAB_PROMETHEUS_METRICS_ENABLED is default' do
before do before do
stub_env('GITLAB_PROMETHEUS_METRICS_ENABLED', '') stub_env('GITLAB_PROMETHEUS_METRICS_ENABLED', '')
end end
it 'prometheus_metrics_enabled is set to false' do it 'prometheus_metrics_enabled is set to true' do
load(settings_file) load(settings_file)
expect(settings.prometheus_metrics_enabled).to eq(false) expect(settings.prometheus_metrics_enabled).to eq(true)
end end
end end
end end
......
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