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
0
Merge Requests
0
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
Léo-Paul Géneau
gitlab-ce
Commits
466beeb3
Commit
466beeb3
authored
May 23, 2017
by
Pawel Chojnacki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use interpolation instead of concatenation
parent
62fe37e3
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
4 deletions
+4
-4
app/controllers/metrics_controller.rb
app/controllers/metrics_controller.rb
+4
-4
No files found.
app/controllers/metrics_controller.rb
View file @
466beeb3
...
...
@@ -14,7 +14,7 @@ class MetricsController < ActionController::Base
def
metrics
metrics_text
=
Prometheus
::
Client
::
Formats
::
Text
.
marshal_multiprocess
(
multiprocess_metrics_path
)
response
=
health_metrics_text
+
"
\n
"
+
metrics_text
response
=
"
#{
health_metrics_text
}
\n
#{
metrics_text
}
"
render
text:
response
,
content_type:
'text/plain; version=0.0.4'
end
...
...
@@ -32,15 +32,15 @@ class MetricsController < ActionController::Base
def
health_metrics_text
results
=
CHECKS
.
flat_map
(
&
:metrics
)
types
=
results
.
map
(
&
:name
)
.
uniq
.
map
{
|
metric_name
|
"# TYPE
#{
metric_name
}
gauge"
}
types
=
results
.
map
(
&
:name
).
uniq
.
map
{
|
metric_name
|
"# TYPE
#{
metric_name
}
gauge"
}
metrics
=
results
.
map
(
&
method
(
:metric_to_prom_line
))
types
.
concat
(
metrics
).
join
(
"
\n
"
)
end
def
metric_to_prom_line
(
metric
)
labels
=
metric
.
labels
&
.
map
{
|
key
,
value
|
"
#{
key
}
=
\"
#{
value
}
\"
"
}
&
.
join
(
','
)
||
''
if
labels
.
empty?
"
#{
metric
.
name
}
#{
metric
.
value
}
"
else
...
...
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