Skip to content

Commit c672b75

Browse files
committed
Remove old broken routes from stats
1 parent e05a6a9 commit c672b75

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/metrics/hpr_metrics.erl

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,20 @@ record_routes() ->
279279
),
280280
_ = prometheus_gauge:set(?METRICS_ROUTES_GAUGE, [], RoutesCount),
281281
_ = prometheus_gauge:set(?METRICS_SKFS_GAUGE, [], SKFsCount),
282+
283+
OldBrokenRoutes = lists:foldl(
284+
fun({[{"oui", OUI} | _], Length}, Acc) ->
285+
maps:put(OUI, Length, Acc)
286+
end,
287+
#{},
288+
prometheus_gauge:values(default, ?METRICS_BROKEN_ROUTES_GAUGE)
289+
),
290+
maps:foreach(
291+
fun(OUI, _Count) ->
292+
_ = prometheus_gauge:remove(?METRICS_BROKEN_ROUTES_GAUGE, [OUI])
293+
end,
294+
maps:without(maps:keys(BrokenMap), OldBrokenRoutes)
295+
),
282296
maps:foreach(
283297
fun(OUI, Count) ->
284298
_ = prometheus_gauge:set(?METRICS_BROKEN_ROUTES_GAUGE, [OUI], Count)

0 commit comments

Comments
 (0)