mirror of
https://mau.dev/maunium/synapse.git
synced 2024-10-01 01:36:05 -04:00
Ensure that exceptions while rendering individual metrics don't stop others from being rendered anyway - especially useful for CallbackMetric
This commit is contained in:
parent
59c448f074
commit
e02cc249da
@ -13,9 +13,14 @@
|
|||||||
# 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
|
||||||
|
|
||||||
from .metric import CounterMetric, CallbackMetric, CacheCounterMetric
|
from .metric import CounterMetric, CallbackMetric, CacheCounterMetric
|
||||||
|
|
||||||
|
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
# We'll keep all the available metrics in a single toplevel dict, one shared
|
# We'll keep all the available metrics in a single toplevel dict, one shared
|
||||||
# for the entire process. We don't currently support per-HomeServer instances
|
# for the entire process. We don't currently support per-HomeServer instances
|
||||||
# of metrics, because in practice any one python VM will host only one
|
# of metrics, because in practice any one python VM will host only one
|
||||||
@ -82,6 +87,10 @@ def render_all():
|
|||||||
strs = []
|
strs = []
|
||||||
|
|
||||||
for name in sorted(all_metrics.keys()):
|
for name in sorted(all_metrics.keys()):
|
||||||
|
try:
|
||||||
strs += all_metrics[name].render()
|
strs += all_metrics[name].render()
|
||||||
|
except Exception as e:
|
||||||
|
strs += ["# FAILED to render %s" % name]
|
||||||
|
logger.exception("Failed to render %s metric", name)
|
||||||
|
|
||||||
return "\n".join(strs)
|
return "\n".join(strs)
|
||||||
|
Loading…
Reference in New Issue
Block a user