mirror of
https://mau.dev/maunium/synapse.git
synced 2024-12-15 06:43:50 +01:00
Log which cache is throwing exceptions
This commit is contained in:
parent
8ac9fa7375
commit
7ee94fc1ba
1 changed files with 17 additions and 10 deletions
|
@ -13,6 +13,7 @@
|
||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
|
import logging
|
||||||
import os
|
import os
|
||||||
|
|
||||||
import six
|
import six
|
||||||
|
@ -20,6 +21,8 @@ from six.moves import intern
|
||||||
|
|
||||||
from prometheus_client.core import REGISTRY, Gauge, GaugeMetricFamily
|
from prometheus_client.core import REGISTRY, Gauge, GaugeMetricFamily
|
||||||
|
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
CACHE_SIZE_FACTOR = float(os.environ.get("SYNAPSE_CACHE_FACTOR", 0.5))
|
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 []
|
return []
|
||||||
|
|
||||||
def collect(self):
|
def collect(self):
|
||||||
if cache_type == "response_cache":
|
try:
|
||||||
response_cache_size.labels(cache_name).set(len(cache))
|
if cache_type == "response_cache":
|
||||||
response_cache_hits.labels(cache_name).set(self.hits)
|
response_cache_size.labels(cache_name).set(len(cache))
|
||||||
response_cache_evicted.labels(cache_name).set(self.evicted_size)
|
response_cache_hits.labels(cache_name).set(self.hits)
|
||||||
response_cache_total.labels(cache_name).set(self.hits + self.misses)
|
response_cache_evicted.labels(cache_name).set(self.evicted_size)
|
||||||
else:
|
response_cache_total.labels(cache_name).set(self.hits + self.misses)
|
||||||
cache_size.labels(cache_name).set(len(cache))
|
else:
|
||||||
cache_hits.labels(cache_name).set(self.hits)
|
cache_size.labels(cache_name).set(len(cache))
|
||||||
cache_evicted.labels(cache_name).set(self.evicted_size)
|
cache_hits.labels(cache_name).set(self.hits)
|
||||||
cache_total.labels(cache_name).set(self.hits + self.misses)
|
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", "")
|
yield GaugeMetricFamily("__unused", "")
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue