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
a10c8dae
Commit
a10c8dae
authored
5 years ago
by
Amber H. Brown
Browse files
Options
Downloads
Patches
Plain Diff
fix prometheus rendering error
parent
b59a4eba
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
synapse/metrics/__init__.py
+1
-1
1 addition, 1 deletion
synapse/metrics/__init__.py
tests/storage/test_event_metrics.py
+23
-38
23 additions, 38 deletions
tests/storage/test_event_metrics.py
with
24 additions
and
39 deletions
synapse/metrics/__init__.py
+
1
−
1
View file @
a10c8dae
...
...
@@ -227,7 +227,7 @@ class BucketCollector(object):
break
for
i
in
self
.
buckets
:
res
.
append
([
i
,
buckets
.
get
(
i
,
0
)])
res
.
append
([
str
(
i
)
,
buckets
.
get
(
i
,
0
)])
res
.
append
([
"
+Inf
"
,
sum
(
data
.
values
())])
...
...
This diff is collapsed.
Click to expand it.
tests/storage/test_event_metrics.py
+
23
−
38
View file @
a10c8dae
...
...
@@ -13,6 +13,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from
prometheus_client.exposition
import
generate_latest
from
synapse.metrics
import
REGISTRY
from
synapse.types
import
Requester
,
UserID
...
...
@@ -52,46 +54,29 @@ class ExtremStatisticsTestCase(HomeserverTestCase):
self
.
reactor
.
advance
(
60
*
60
*
1000
)
self
.
pump
(
1
)
items
=
li
st
(
items
=
s
e
t
(
filter
(
lambda
x
:
x
.
name
==
"
synapse_forward_extremities
"
,
list
(
REGISTRY
.
collect
()
),
lambda
x
:
b
"
synapse_forward_extremities
_
"
in
x
,
generate_latest
(
REGISTRY
).
split
(
b
"
\n
"
),
)
)
# Check the values are what we want
buckets
=
{}
_count
=
0
_sum
=
0
for
i
in
items
[
0
].
samples
:
if
i
[
0
].
endswith
(
"
_bucket
"
):
buckets
[
i
[
1
][
'
le
'
]]
=
i
[
2
]
elif
i
[
0
].
endswith
(
"
_count
"
):
_count
=
i
[
2
]
elif
i
[
0
].
endswith
(
"
_sum
"
):
_sum
=
i
[
2
]
expected
=
set
([
b
'
synapse_forward_extremities_bucket{le=
"
1.0
"
} 0.0
'
,
b
'
synapse_forward_extremities_bucket{le=
"
2.0
"
} 2.0
'
,
b
'
synapse_forward_extremities_bucket{le=
"
3.0
"
} 0.0
'
,
b
'
synapse_forward_extremities_bucket{le=
"
5.0
"
} 0.0
'
,
b
'
synapse_forward_extremities_bucket{le=
"
7.0
"
} 1.0
'
,
b
'
synapse_forward_extremities_bucket{le=
"
10.0
"
} 0.0
'
,
b
'
synapse_forward_extremities_bucket{le=
"
15.0
"
} 0.0
'
,
b
'
synapse_forward_extremities_bucket{le=
"
20.0
"
} 0.0
'
,
b
'
synapse_forward_extremities_bucket{le=
"
50.0
"
} 0.0
'
,
b
'
synapse_forward_extremities_bucket{le=
"
100.0
"
} 0.0
'
,
b
'
synapse_forward_extremities_bucket{le=
"
200.0
"
} 0.0
'
,
b
'
synapse_forward_extremities_bucket{le=
"
500.0
"
} 0.0
'
,
b
'
synapse_forward_extremities_bucket{le=
"
+Inf
"
} 3.0
'
,
b
'
synapse_forward_extremities_count 3.0
'
,
b
'
synapse_forward_extremities_sum 10.0
'
,
])
# 3 buckets, 2 with 2 extrems, 1 with 6 extrems (bucketed as 7), and
# +Inf which is all
self
.
assertEqual
(
buckets
,
{
1.0
:
0
,
2.0
:
2
,
3.0
:
0
,
5.0
:
0
,
7.0
:
1
,
10.0
:
0
,
15.0
:
0
,
20.0
:
0
,
50.0
:
0
,
100.0
:
0
,
200.0
:
0
,
500.0
:
0
,
"
+Inf
"
:
3
,
},
)
# 3 rooms, with 10 total events
self
.
assertEqual
(
_count
,
3
)
self
.
assertEqual
(
_sum
,
10
)
self
.
assertEqual
(
items
,
expected
)
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