Add latest changes from gitlab-org/gitlab@master

This commit is contained in:
GitLab Bot 2019-12-24 03:07:52 +00:00
parent 3888bc4261
commit f12dba53d9
4 changed files with 58 additions and 2 deletions

View file

@ -204,7 +204,11 @@ class Environment < ApplicationRecord
end
def has_metrics?
available? && prometheus_adapter&.configured?
available? && (prometheus_adapter&.configured? || has_sample_metrics?)
end
def has_sample_metrics?
!!ENV['USE_SAMPLE_METRICS']
end
def metrics

View file

@ -0,0 +1,5 @@
---
title: Show sample metrics for an environment without prometheus configured
merge_request: 22133
author:
type: added

View file

@ -25,7 +25,7 @@ are very appreciative of the work done by translators and proofreaders!
- Victor Wu - [GitLab](https://gitlab.com/victorwuky), [Crowdin](https://crowdin.com/profile/victorwu)
- Ivan Ip - [GitLab](https://gitlab.com/lifehome), [Crowdin](https://crowdin.com/profile/lifehome)
- Czech
- Proofreaders needed.
- Jan Urbanec - [GitLab](https://gitlab.com/TatranskyMedved), [Crowdin](https://crowdin.com/profile/Tatranskymedved)
- Danish
- Saederup92 - [GitLab](https://gitlab.com/Saederup92), [Crowdin](https://crowdin.com/profile/Saederup92)
- Dutch

View file

@ -6,6 +6,7 @@ describe Environment, :use_clean_rails_memory_store_caching do
include ReactiveCachingHelpers
using RSpec::Parameterized::TableSyntax
include RepoHelpers
include StubENV
let(:project) { create(:project, :repository) }
@ -851,6 +852,52 @@ describe Environment, :use_clean_rails_memory_store_caching do
context 'without a monitoring service' do
it { is_expected.to be_falsy }
end
context 'when sample metrics are enabled' do
before do
stub_env('USE_SAMPLE_METRICS', 'true')
end
context 'with no prometheus adapter configured' do
before do
allow(environment.prometheus_adapter).to receive(:configured?).and_return(false)
end
it { is_expected.to be_truthy }
end
end
end
describe '#has_sample_metrics?' do
subject { environment.has_metrics? }
let(:project) { create(:project) }
context 'when sample metrics are enabled' do
before do
stub_env('USE_SAMPLE_METRICS', 'true')
end
context 'with no prometheus adapter configured' do
before do
allow(environment.prometheus_adapter).to receive(:configured?).and_return(false)
end
it { is_expected.to be_truthy }
end
context 'with the environment stopped' do
before do
environment.stop
end
it { is_expected.to be_falsy }
end
end
context 'when sample metrics are not enabled' do
it { is_expected.to be_falsy }
end
end
context 'when the environment is unavailable' do