summary refs log tree commit diff
path: root/synapse
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2021-03-29 18:34:21 +0100
committerErik Johnston <erik@matrix.org>2021-03-29 18:34:21 +0100
commitacd2778d612225e36019df04c465e063a99a844f (patch)
tree07dd424d46cba91fc1effe53bab936296b38d84a /synapse
parentFix (diff)
downloadsynapse-acd2778d612225e36019df04c465e063a99a844f.tar.xz
Fixup
Diffstat (limited to 'synapse')
-rw-r--r--synapse/metrics/__init__.py29
1 files changed, 14 insertions, 15 deletions
diff --git a/synapse/metrics/__init__.py b/synapse/metrics/__init__.py
index b30688327f..a15a5bba18 100644
--- a/synapse/metrics/__init__.py
+++ b/synapse/metrics/__init__.py
@@ -626,7 +626,11 @@ try:
         allocated = ctypes.c_size_t(0)
         allocated_len = ctypes.c_size_t(ctypes.sizeof(allocated))
         jemalloc.mallctl(
-            name, ctypes.byref(allocated), ctypes.byref(allocated_len), None, None
+            name.encode("ascii"),
+            ctypes.byref(allocated),
+            ctypes.byref(allocated_len),
+            None,
+            None,
         )
         return allocated.value
 
@@ -640,21 +644,16 @@ try:
         def collect(self):
             refresh_stats()
 
-            yield GaugeMetricFamily(
-                "jemalloc_stats_allocated", "", value=get_val(b"stats.allocated")
-            )
-            yield GaugeMetricFamily(
-                "jemalloc_stats_active", "", value=get_val(b"stats.active")
-            )
-            yield GaugeMetricFamily(
-                "jemalloc_stats_resident", "", value=get_val(b"stats.resident")
-            )
-            yield GaugeMetricFamily(
-                "jemalloc_stats_mapped", "", value=get_val(b"stats.mapped")
-            )
-            yield GaugeMetricFamily(
-                "jemalloc_stats_retained", "", value=get_val(b"stats.retained")
+            g = GaugeMetricFamily(
+                "jemalloc_stats_app_memory",
+                "",
+                labels=["type"],
+                value=get_val(b"stats.allocated"),
             )
+            for t in ("allocated", "active", "resident", "mapped", "retained"):
+                g.add_metric([t], value=get_val(f"stats.{t}"))
+
+            yield g
 
     REGISTRY.register(JemallocCollector())