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
7ee94fc1
Commit
7ee94fc1
authored
6 years ago
by
Richard van der Hoff
Browse files
Options
Downloads
Patches
Plain Diff
Log which cache is throwing exceptions
parent
8ac9fa73
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/util/caches/__init__.py
+17
-10
17 additions, 10 deletions
synapse/util/caches/__init__.py
with
17 additions
and
10 deletions
synapse/util/caches/__init__.py
+
17
−
10
View file @
7ee94fc1
...
...
@@ -13,6 +13,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import
logging
import
os
import
six
...
...
@@ -20,6 +21,8 @@ from six.moves import intern
from
prometheus_client.core
import
REGISTRY
,
Gauge
,
GaugeMetricFamily
logger
=
logging
.
getLogger
(
__name__
)
CACHE_SIZE_FACTOR
=
float
(
os
.
environ
.
get
(
"
SYNAPSE_CACHE_FACTOR
"
,
0.5
))
...
...
@@ -76,16 +79,20 @@ def register_cache(cache_type, cache_name, cache):
return
[]
def
collect
(
self
):
if
cache_type
==
"
response_cache
"
:
response_cache_size
.
labels
(
cache_name
).
set
(
len
(
cache
))
response_cache_hits
.
labels
(
cache_name
).
set
(
self
.
hits
)
response_cache_evicted
.
labels
(
cache_name
).
set
(
self
.
evicted_size
)
response_cache_total
.
labels
(
cache_name
).
set
(
self
.
hits
+
self
.
misses
)
else
:
cache_size
.
labels
(
cache_name
).
set
(
len
(
cache
))
cache_hits
.
labels
(
cache_name
).
set
(
self
.
hits
)
cache_evicted
.
labels
(
cache_name
).
set
(
self
.
evicted_size
)
cache_total
.
labels
(
cache_name
).
set
(
self
.
hits
+
self
.
misses
)
try
:
if
cache_type
==
"
response_cache
"
:
response_cache_size
.
labels
(
cache_name
).
set
(
len
(
cache
))
response_cache_hits
.
labels
(
cache_name
).
set
(
self
.
hits
)
response_cache_evicted
.
labels
(
cache_name
).
set
(
self
.
evicted_size
)
response_cache_total
.
labels
(
cache_name
).
set
(
self
.
hits
+
self
.
misses
)
else
:
cache_size
.
labels
(
cache_name
).
set
(
len
(
cache
))
cache_hits
.
labels
(
cache_name
).
set
(
self
.
hits
)
cache_evicted
.
labels
(
cache_name
).
set
(
self
.
evicted_size
)
cache_total
.
labels
(
cache_name
).
set
(
self
.
hits
+
self
.
misses
)
except
Exception
as
e
:
logger
.
warn
(
"
Error calculating metrics for %s: %s
"
,
cache_name
,
e
)
raise
yield
GaugeMetricFamily
(
"
__unused
"
,
""
)
...
...
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