Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
5c9237e7
Commit
5c9237e7
authored
Dec 24, 2019
by
Kirstie Cook
Committed by
Heinrich Lee Yu
Dec 24, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Show sample metrics for an environment without prometheus
parent
9eaa9aa3
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
57 additions
and
1 deletion
+57
-1
app/models/environment.rb
app/models/environment.rb
+5
-1
changelogs/unreleased/sample-metrics-without-prometheus.yml
changelogs/unreleased/sample-metrics-without-prometheus.yml
+5
-0
spec/models/environment_spec.rb
spec/models/environment_spec.rb
+47
-0
No files found.
app/models/environment.rb
View file @
5c9237e7
...
...
@@ -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
...
...
changelogs/unreleased/sample-metrics-without-prometheus.yml
0 → 100644
View file @
5c9237e7
---
title
:
Show sample metrics for an environment without prometheus configured
merge_request
:
22133
author
:
type
:
added
spec/models/environment_spec.rb
View file @
5c9237e7
...
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment