Просмотр исходного кода

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.
JianBo He 2 лет назад
Родитель
Сommit
80e2c2c955
1 измененных файлов с 1 добавлено и 1 удалено
  1. 1 1
      apps/emqx_dashboard/src/emqx_dashboard_monitor.erl

+ 1 - 1
apps/emqx_dashboard/src/emqx_dashboard_monitor.erl

@@ -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).