fix(http): avoid crash if the old sample data dont contain `live_connections`

In version 5.1.0, a new metric called "live_connections" was added. However, we try to merge
some data from the Mria disk table, which may include old data formats.

Therefore, maps:get/3 is needed to avoid crashes.
This commit is contained in:
JianBo He 2023-06-14 15:14:20 +08:00
parent ebf307d704
commit 80e2c2c955
1 changed files with 1 additions and 1 deletions

View File

@ -249,7 +249,7 @@ merge_cluster_sampler_map(M1, M2) ->
(topics, Map) ->
Map#{topics => maps:get(topics, M1)};
(Key, Map) ->
Map#{Key => maps:get(Key, M1) + maps:get(Key, M2)}
Map#{Key => maps:get(Key, M1, 0) + maps:get(Key, M2, 0)}
end,
lists:foldl(Fun, #{}, ?SAMPLER_LIST).