Explorar o código

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 %!s(int64=2) %!d(string=hai) anos
pai
achega
80e2c2c955
Modificáronse 1 ficheiros con 1 adicións e 1 borrados
  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) ->
             (topics, Map) ->
                 Map#{topics => maps:get(topics, M1)};
                 Map#{topics => maps:get(topics, M1)};
             (Key, Map) ->
             (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,
         end,
     lists:foldl(Fun, #{}, ?SAMPLER_LIST).
     lists:foldl(Fun, #{}, ?SAMPLER_LIST).