Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
synapse
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Monitor
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Maunium
synapse
Commits
aeb9b217
Unverified
Commit
aeb9b217
authored
5 years ago
by
Amber Brown
Committed by
GitHub
5 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Add a build info metric to Prometheus (#6005)
parent
ea6956c5
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
changelog.d/6005.feature
+1
-0
1 addition, 0 deletions
changelog.d/6005.feature
synapse/metrics/__init__.py
+12
-0
12 additions, 0 deletions
synapse/metrics/__init__.py
tests/test_metrics.py
+20
-2
20 additions, 2 deletions
tests/test_metrics.py
with
33 additions
and
2 deletions
changelog.d/6005.feature
0 → 100644
+
1
−
0
View file @
aeb9b217
The
new
Prometheus
metric
`synapse_build_info`
exposes
the
Python
version,
OS
version,
and
Synapse
version
of
the
running
server.
This diff is collapsed.
Click to expand it.
synapse/metrics/__init__.py
+
12
−
0
View file @
aeb9b217
...
@@ -29,11 +29,13 @@ from prometheus_client.core import REGISTRY, GaugeMetricFamily, HistogramMetricF
...
@@ -29,11 +29,13 @@ from prometheus_client.core import REGISTRY, GaugeMetricFamily, HistogramMetricF
from
twisted.internet
import
reactor
from
twisted.internet
import
reactor
import
synapse
from
synapse.metrics._exposition
import
(
from
synapse.metrics._exposition
import
(
MetricsResource
,
MetricsResource
,
generate_latest
,
generate_latest
,
start_http_server
,
start_http_server
,
)
)
from
synapse.util.versionstring
import
get_version_string
logger
=
logging
.
getLogger
(
__name__
)
logger
=
logging
.
getLogger
(
__name__
)
...
@@ -385,6 +387,16 @@ event_processing_last_ts = Gauge("synapse_event_processing_last_ts", "", ["name"
...
@@ -385,6 +387,16 @@ event_processing_last_ts = Gauge("synapse_event_processing_last_ts", "", ["name"
# finished being processed.
# finished being processed.
event_processing_lag
=
Gauge
(
"
synapse_event_processing_lag
"
,
""
,
[
"
name
"
])
event_processing_lag
=
Gauge
(
"
synapse_event_processing_lag
"
,
""
,
[
"
name
"
])
# Build info of the running server.
build_info
=
Gauge
(
"
synapse_build_info
"
,
"
Build information
"
,
[
"
pythonversion
"
,
"
version
"
,
"
osversion
"
]
)
build_info
.
labels
(
"
"
.
join
([
platform
.
python_implementation
(),
platform
.
python_version
()]),
get_version_string
(
synapse
),
"
"
.
join
([
platform
.
system
(),
platform
.
release
()]),
).
set
(
1
)
last_ticked
=
time
.
time
()
last_ticked
=
time
.
time
()
...
...
This diff is collapsed.
Click to expand it.
tests/test_metrics.py
+
20
−
2
View file @
aeb9b217
# -*- coding: utf-8 -*-
# -*- coding: utf-8 -*-
# Copyright 2018 New Vector Ltd
# Copyright 2018 New Vector Ltd
# Copyright 2019 Matrix.org Foundation C.I.C.
#
#
# Licensed under the Apache License, Version 2.0 (the "License");
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# you may not use this file except in compliance with the License.
...
@@ -13,8 +14,7 @@
...
@@ -13,8 +14,7 @@
# See the License for the specific language governing permissions and
# See the License for the specific language governing permissions and
# limitations under the License.
# limitations under the License.
from
synapse.metrics
import
REGISTRY
,
InFlightGauge
,
generate_latest
from
synapse.metrics
import
InFlightGauge
from
tests
import
unittest
from
tests
import
unittest
...
@@ -111,3 +111,21 @@ class TestMauLimit(unittest.TestCase):
...
@@ -111,3 +111,21 @@ class TestMauLimit(unittest.TestCase):
}
}
return
results
return
results
class
BuildInfoTests
(
unittest
.
TestCase
):
def
test_get_build
(
self
):
"""
The synapse_build_info metric reports the OS version, Python version,
and Synapse version.
"""
items
=
list
(
filter
(
lambda
x
:
b
"
synapse_build_info{
"
in
x
,
generate_latest
(
REGISTRY
).
split
(
b
"
\n
"
),
)
)
self
.
assertEqual
(
len
(
items
),
1
)
self
.
assertTrue
(
b
"
osversion=
"
in
items
[
0
])
self
.
assertTrue
(
b
"
pythonversion=
"
in
items
[
0
])
self
.
assertTrue
(
b
"
version=
"
in
items
[
0
])
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment