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
a5cbd200
Commit
a5cbd200
authored
9 years ago
by
Erik Johnston
Browse files
Options
Downloads
Plain Diff
Merge pull request #225 from matrix-org/erikj/reactor_metrics
Fix pending_calls metric to not lie
parents
128ed32e
6e7d36a7
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/__init__.py
+25
-3
25 additions, 3 deletions
synapse/metrics/__init__.py
with
25 additions
and
3 deletions
synapse/metrics/__init__.py
+
25
−
3
View file @
a5cbd200
...
@@ -158,18 +158,40 @@ def runUntilCurrentTimer(func):
...
@@ -158,18 +158,40 @@ def runUntilCurrentTimer(func):
@functools.wraps
(
func
)
@functools.wraps
(
func
)
def
f
(
*
args
,
**
kwargs
):
def
f
(
*
args
,
**
kwargs
):
pending_calls
=
len
(
reactor
.
getDelayedCalls
())
now
=
reactor
.
seconds
()
num_pending
=
0
# _newTimedCalls is one long list of *all* pending calls. Below loop
# is based off of impl of reactor.runUntilCurrent
for
delayed_call
in
reactor
.
_newTimedCalls
:
if
delayed_call
.
time
>
now
:
break
if
delayed_call
.
delayed_time
>
0
:
continue
num_pending
+=
1
num_pending
+=
len
(
reactor
.
threadCallQueue
)
start
=
time
.
time
()
*
1000
start
=
time
.
time
()
*
1000
ret
=
func
(
*
args
,
**
kwargs
)
ret
=
func
(
*
args
,
**
kwargs
)
end
=
time
.
time
()
*
1000
end
=
time
.
time
()
*
1000
tick_time
.
inc_by
(
end
-
start
)
tick_time
.
inc_by
(
end
-
start
)
pending_calls_metric
.
inc_by
(
pending
_calls
)
pending_calls_metric
.
inc_by
(
num_
pending
)
return
ret
return
ret
return
f
return
f
if
hasattr
(
reactor
,
"
runUntilCurrent
"
):
try
:
# Ensure the reactor has all the attributes we expect
reactor
.
runUntilCurrent
reactor
.
_newTimedCalls
reactor
.
threadCallQueue
# runUntilCurrent is called when we have pending calls. It is called once
# runUntilCurrent is called when we have pending calls. It is called once
# per iteratation after fd polling.
# per iteratation after fd polling.
reactor
.
runUntilCurrent
=
runUntilCurrentTimer
(
reactor
.
runUntilCurrent
)
reactor
.
runUntilCurrent
=
runUntilCurrentTimer
(
reactor
.
runUntilCurrent
)
except
AttributeError
:
pass
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