Enable prometheus metrics by default

This commit is contained in:
Felipe Artur 2018-05-07 08:46:23 +00:00 committed by Douwe Maan
parent 1492cf8f57
commit a9d0deebd2
5 changed files with 29 additions and 6 deletions

View file

@ -0,0 +1,5 @@
---
title: Enable prometheus monitoring by default
merge_request:
author:
type: other

View file

@ -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'

View file

@ -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

View file

@ -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"

View file

@ -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