Commit f460e2dc authored by Douwe Maan's avatar Douwe Maan

Merge branch 'issue_43660' into 'master'

Enable prometheus metrics by default

Closes #43660

See merge request gitlab-org/gitlab-ce!18723
parents 1492cf8f a9d0deeb
---
title: Enable prometheus monitoring by default
merge_request:
author:
type: other
......@@ -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'
......
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 @@
#
# 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"
......
......@@ -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
......
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