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
Package registry
Container Registry
Model registry
Operate
Terraform modules
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
Timo Ley
synapse
Commits
d884047d
Commit
d884047d
authored
9 years ago
by
Erik Johnston
Browse files
Options
Downloads
Plain Diff
Merge pull request #224 from matrix-org/erikj/reactor_metrics
Add some metrics about the reactor
parents
7eb4d626
3d1cdda7
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
synapse/metrics/__init__.py
+29
-0
29 additions, 0 deletions
synapse/metrics/__init__.py
with
29 additions
and
0 deletions
synapse/metrics/__init__.py
+
29
−
0
View file @
d884047d
...
...
@@ -18,8 +18,12 @@ from __future__ import absolute_import
import
logging
from
resource
import
getrusage
,
getpagesize
,
RUSAGE_SELF
import
functools
import
os
import
stat
import
time
from
twisted.internet
import
reactor
from
.metric
import
(
CounterMetric
,
CallbackMetric
,
DistributionMetric
,
CacheMetric
...
...
@@ -144,3 +148,28 @@ def _process_fds():
return
counts
get_metrics_for
(
"
process
"
).
register_callback
(
"
fds
"
,
_process_fds
,
labels
=
[
"
type
"
])
reactor_metrics
=
get_metrics_for
(
"
reactor
"
)
tick_time
=
reactor_metrics
.
register_distribution
(
"
tick_time
"
)
pending_calls_metric
=
reactor_metrics
.
register_distribution
(
"
pending_calls
"
)
def
runUntilCurrentTimer
(
func
):
@functools.wraps
(
func
)
def
f
(
*
args
,
**
kwargs
):
pending_calls
=
len
(
reactor
.
getDelayedCalls
())
start
=
time
.
time
()
*
1000
ret
=
func
(
*
args
,
**
kwargs
)
end
=
time
.
time
()
*
1000
tick_time
.
inc_by
(
end
-
start
)
pending_calls_metric
.
inc_by
(
pending_calls
)
return
ret
return
f
if
hasattr
(
reactor
,
"
runUntilCurrent
"
):
# runUntilCurrent is called when we have pending calls. It is called once
# per iteratation after fd polling.
reactor
.
runUntilCurrent
=
runUntilCurrentTimer
(
reactor
.
runUntilCurrent
)
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