From 4859c512258bef4315db1cf6f06265924a3cf7cb Mon Sep 17 00:00:00 2001 From: Fredrik Ekre Date: Tue, 21 Nov 2023 15:54:25 +0100 Subject: [PATCH] Use begin-end block with at-lock macro to help coverage --- src/Prometheus.jl | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Prometheus.jl b/src/Prometheus.jl index 3fa0dc7..9ed1115 100644 --- a/src/Prometheus.jl +++ b/src/Prometheus.jl @@ -1042,8 +1042,10 @@ end function expose_io(io::IO, reg::CollectorRegistry) # Collect all metrics metrics = Metric[] - @lock reg.lock for collector in reg.collectors - collect!(metrics, collector) + @lock reg.lock begin + for collector in reg.collectors + collect!(metrics, collector) + end end sort!(metrics; by = metric -> metric.metric_name) # Write to IO