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
fb2806b1
Commit
fb2806b1
authored
6 years ago
by
Erik Johnston
Browse files
Options
Downloads
Patches
Plain Diff
Move in_flight_requests_count to be a callback metric
parent
dfa70adc
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/http/request_metrics.py
+21
-10
21 additions, 10 deletions
synapse/http/request_metrics.py
with
21 additions
and
10 deletions
synapse/http/request_metrics.py
+
21
−
10
View file @
fb2806b1
...
...
@@ -124,12 +124,8 @@ in_flight_requests_db_sched_duration = metrics.register_counter(
"
in_flight_requests_db_sched_duration_seconds
"
,
labels
=
[
"
method
"
,
"
servlet
"
]
)
_in_flight_requests_count
=
metrics
.
register_gauge
(
"
in_flight_requests_count
"
,
labels
=
[
"
method
"
,
"
servlet
"
]
)
# The set of all in flight requests
.
# The set of all in flight requests
, set[RequestMetrics]
_in_flight_requests
=
set
()
...
...
@@ -138,20 +134,35 @@ def _collect_in_flight():
the in flight request metrics
"""
for
rm
in
_in_flight_requests
:
rm
.
update_metrics
()
metrics
.
register_collector
(
_collect_in_flight
)
def
_get_in_flight_counts
():
"""
Returns a count of all in flight requests by (method, server_name)
Returns:
dict[tuple[str, str], int]
"""
# Map from (method, name) -> int, the number of in flight requests of that
# type
counts
=
{}
for
rm
in
_in_flight_requests
:
rm
.
update_metrics
()
key
=
(
rm
.
method
,
rm
.
name
,)
counts
[
key
]
=
counts
.
get
(
key
,
0
)
+
1
for
(
method
,
name
),
count
in
counts
.
iteritems
():
_in_flight_requests_count
.
set
(
count
,
method
,
name
)
return
counts
metrics
.
register_collector
(
_collect_in_flight
)
metrics
.
register_callback
(
"
in_flight_requests_count
"
,
_get_in_flight_counts
,
labels
=
[
"
method
"
,
"
servlet
"
]
)
class
RequestMetrics
(
object
):
...
...
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