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
1748605c
Commit
1748605c
authored
10 years ago
by
Paul "LeoNerd" Evans
Browse files
Options
Downloads
Patches
Plain Diff
Count incoming HTTP requests per servlet that responds
parent
4d661ec0
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/federation/transport/server.py
+4
-0
4 additions, 0 deletions
synapse/federation/transport/server.py
synapse/http/server.py
+11
-7
11 additions, 7 deletions
synapse/http/server.py
with
15 additions
and
7 deletions
synapse/federation/transport/server.py
+
4
−
0
View file @
1748605c
...
...
@@ -148,6 +148,10 @@ class BaseFederationServlet(object):
logger
.
exception
(
"
authenticate_request failed
"
)
raise
defer
.
returnValue
(
response
)
# Extra logic that functools.wraps() doesn't finish
new_code
.
__self__
=
code
.
__self__
return
new_code
def
register
(
self
,
server
):
...
...
This diff is collapsed.
Click to expand it.
synapse/http/server.py
+
11
−
7
View file @
1748605c
...
...
@@ -38,7 +38,7 @@ logger = logging.getLogger(__name__)
metrics
=
synapse
.
metrics
.
get_metrics_for
(
__name__
)
incoming_requests_counter
=
metrics
.
register_counter
(
"
requests
"
,
labels
=
[
"
method
"
],
labels
=
[
"
method
"
,
"
servlet
"
],
)
outgoing_responses_counter
=
metrics
.
register_counter
(
"
responses
"
,
labels
=
[
"
method
"
,
"
code
"
],
...
...
@@ -122,8 +122,6 @@ class JsonResource(HttpServer, resource.Resource):
This checks if anyone has registered a callback for that method and
path.
"""
incoming_requests_counter
.
inc
(
request
.
method
)
code
=
None
start
=
self
.
clock
.
time_msec
()
try
:
...
...
@@ -143,6 +141,15 @@ class JsonResource(HttpServer, resource.Resource):
# returned response. We pass both the request and any
# matched groups from the regex to the callback.
callback
=
path_entry
.
callback
servlet_instance
=
getattr
(
callback
,
"
__self__
"
,
None
)
if
servlet_instance
is
not
None
:
servlet_classname
=
servlet_instance
.
__class__
.
__name__
else
:
servlet_classname
=
"
%r
"
%
callback
incoming_requests_counter
.
inc
(
request
.
method
,
servlet_classname
)
args
=
[
urllib
.
unquote
(
u
).
decode
(
"
UTF-8
"
)
for
u
in
m
.
groups
()
]
...
...
@@ -152,10 +159,7 @@ class JsonResource(HttpServer, resource.Resource):
request
.
method
,
request
.
path
)
code
,
response
=
yield
path_entry
.
callback
(
request
,
*
args
)
code
,
response
=
yield
callback
(
request
,
*
args
)
self
.
_send_response
(
request
,
code
,
response
)
return
...
...
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