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
f008d7e7
Commit
f008d7e7
authored
Dec 21, 2021
by
Matthias Käppler
Committed by
Rémy Coutable
Dec 21, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix Prometheus client state not being reset
parent
d0306a75
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
7 deletions
+8
-7
spec/metrics_server/metrics_server_spec.rb
spec/metrics_server/metrics_server_spec.rb
+8
-7
No files found.
spec/metrics_server/metrics_server_spec.rb
View file @
f008d7e7
...
...
@@ -8,14 +8,22 @@ require_relative '../support/helpers/next_instance_of'
RSpec
.
describe
MetricsServer
do
# rubocop:disable RSpec/FilePath
include
NextInstanceOf
let
(
:prometheus_config
)
{
::
Prometheus
::
Client
.
configuration
}
let
(
:metrics_dir
)
{
Dir
.
mktmpdir
}
# Prometheus::Client is a singleton, i.e. shared global state, so
# we need to reset it after testing.
let!
(
:old_multiprocess_files_dir
)
{
prometheus_config
.
multiprocess_files_dir
}
before
do
# We do not want this to have knock-on effects on the test process.
allow
(
Gitlab
::
ProcessManagement
).
to
receive
(
:modify_signals
)
end
after
do
Gitlab
::
Metrics
.
reset_registry!
prometheus_config
.
multiprocess_files_dir
=
old_multiprocess_files_dir
FileUtils
.
rm_rf
(
metrics_dir
,
secure:
true
)
end
...
...
@@ -55,9 +63,7 @@ RSpec.describe MetricsServer do # rubocop:disable RSpec/FilePath
describe
'#start'
do
let
(
:exporter_class
)
{
Class
.
new
(
Gitlab
::
Metrics
::
Exporter
::
BaseExporter
)
}
let
(
:exporter_double
)
{
double
(
'fake_exporter'
,
start:
true
)
}
let
(
:prometheus_config
)
{
::
Prometheus
::
Client
.
configuration
}
let
(
:settings
)
{
{
"fake_exporter"
=>
{
"enabled"
=>
true
}
}
}
let!
(
:old_metrics_dir
)
{
prometheus_config
.
multiprocess_files_dir
}
let
(
:ruby_sampler_double
)
{
double
(
Gitlab
::
Metrics
::
Samplers
::
RubySampler
)
}
subject
(
:metrics_server
)
{
described_class
.
new
(
'fake'
,
metrics_dir
,
true
)}
...
...
@@ -71,11 +77,6 @@ RSpec.describe MetricsServer do # rubocop:disable RSpec/FilePath
allow
(
ruby_sampler_double
).
to
receive
(
:start
)
end
after
do
Gitlab
::
Metrics
.
reset_registry!
prometheus_config
.
multiprocess_files_dir
=
old_metrics_dir
end
it
'configures ::Prometheus::Client'
do
metrics_server
.
start
...
...
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