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
e3bc4617
Unverified
Commit
e3bc4617
authored
3 years ago
by
Erik Johnston
Committed by
GitHub
3 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Time external cache response time (#9904)
parent
b85821ac
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
changelog.d/9904.misc
+1
-0
1 addition, 0 deletions
changelog.d/9904.misc
synapse/replication/tcp/external_cache.py
+26
-10
26 additions, 10 deletions
synapse/replication/tcp/external_cache.py
with
27 additions
and
10 deletions
changelog.d/9904.misc
0 → 100644
+
1
−
0
View file @
e3bc4617
Time response time for external cache requests.
This diff is collapsed.
Click to expand it.
synapse/replication/tcp/external_cache.py
+
26
−
10
View file @
e3bc4617
...
...
@@ -15,7 +15,7 @@
import
logging
from
typing
import
TYPE_CHECKING
,
Any
,
Optional
from
prometheus_client
import
Counter
from
prometheus_client
import
Counter
,
Histogram
from
synapse.logging.context
import
make_deferred_yieldable
from
synapse.util
import
json_decoder
,
json_encoder
...
...
@@ -35,6 +35,20 @@ get_counter = Counter(
labelnames
=
[
"
cache_name
"
,
"
hit
"
],
)
response_timer
=
Histogram
(
"
synapse_external_cache_response_time_seconds
"
,
"
Time taken to get a response from Redis for a cache get/set request
"
,
labelnames
=
[
"
method
"
],
buckets
=
(
0.001
,
0.002
,
0.005
,
0.01
,
0.02
,
0.05
,
),
)
logger
=
logging
.
getLogger
(
__name__
)
...
...
@@ -72,13 +86,14 @@ class ExternalCache:
logger
.
debug
(
"
Caching %s %s: %r
"
,
cache_name
,
key
,
encoded_value
)
return
await
make_deferred_yieldable
(
self
.
_redis_connection
.
set
(
self
.
_get_redis_key
(
cache_name
,
key
),
encoded_value
,
pexpire
=
expiry_ms
,
with
response_timer
.
labels
(
"
set
"
).
time
():
return
await
make_deferred_yieldable
(
self
.
_redis_connection
.
set
(
self
.
_get_redis_key
(
cache_name
,
key
),
encoded_value
,
pexpire
=
expiry_ms
,
)
)
)
async
def
get
(
self
,
cache_name
:
str
,
key
:
str
)
->
Optional
[
Any
]:
"""
Look up a key/value in the named cache.
"""
...
...
@@ -86,9 +101,10 @@ class ExternalCache:
if
self
.
_redis_connection
is
None
:
return
None
result
=
await
make_deferred_yieldable
(
self
.
_redis_connection
.
get
(
self
.
_get_redis_key
(
cache_name
,
key
))
)
with
response_timer
.
labels
(
"
get
"
).
time
():
result
=
await
make_deferred_yieldable
(
self
.
_redis_connection
.
get
(
self
.
_get_redis_key
(
cache_name
,
key
))
)
logger
.
debug
(
"
Got cache result %s %s: %r
"
,
cache_name
,
key
,
result
)
...
...
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