Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Matrix
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Container Registry
Model registry
Operate
Environments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TeDomum
Matrix
Commits
5e16c1dc
Unverified
Commit
5e16c1dc
authored
7 years ago
by
Richard van der Hoff
Committed by
GitHub
7 years ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #2778 from matrix-org/rav/counters_should_be_floats
Make Counter render floats
parents
0fc2362d
19d27408
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
synapse/metrics/metric.py
+10
-3
10 additions, 3 deletions
synapse/metrics/metric.py
with
10 additions
and
3 deletions
synapse/metrics/metric.py
+
10
−
3
View file @
5e16c1dc
...
...
@@ -50,7 +50,14 @@ class BaseMetric(object):
class
CounterMetric
(
BaseMetric
):
"""
The simplest kind of metric; one that stores a monotonically-increasing
integer that counts events.
"""
value that counts events or running totals.
Example use cases for Counters:
- Number of requests processed
- Number of items that were inserted into a queue
- Total amount of data that a system has processed
Counters can only go up (and be reset when the process restarts).
"""
def
__init__
(
self
,
*
args
,
**
kwargs
):
super
(
CounterMetric
,
self
).
__init__
(
*
args
,
**
kwargs
)
...
...
@@ -59,7 +66,7 @@ class CounterMetric(BaseMetric):
# Scalar metrics are never empty
if
self
.
is_scalar
():
self
.
counts
[()]
=
0
self
.
counts
[()]
=
0
.
def
inc_by
(
self
,
incr
,
*
values
):
if
len
(
values
)
!=
self
.
dimension
():
...
...
@@ -78,7 +85,7 @@ class CounterMetric(BaseMetric):
self
.
inc_by
(
1
,
*
values
)
def
render_item
(
self
,
k
):
return
[
"
%s%s %
d
"
%
(
self
.
name
,
self
.
_render_key
(
k
),
self
.
counts
[
k
])]
return
[
"
%s%s %
.12g
"
%
(
self
.
name
,
self
.
_render_key
(
k
),
self
.
counts
[
k
])]
def
render
(
self
):
return
map_concat
(
self
.
render_item
,
sorted
(
self
.
counts
.
keys
()))
...
...
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