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

fix(prom_di): api crash in `connecting`

- https://emqx.atlassian.net/browse/EMQX-11801
JimMoen 2 лет назад
Родитель
Сommit
61dd362db0

+ 1 - 0
apps/emqx_prometheus/rebar.config

@@ -4,6 +4,7 @@
     {emqx, {path, "../emqx"}},
     {emqx_utils, {path, "../emqx_utils"}},
     {emqx_auth, {path, "../emqx_auth"}},
+    {emqx_resource, {path, "../emqx_resource"}},
     {prometheus, {git, "https://github.com/emqx/prometheus.erl", {tag, "v4.10.0.2"}}}
 ]}.
 

+ 1 - 1
apps/emqx_prometheus/src/emqx_prometheus.app.src

@@ -5,7 +5,7 @@
     {vsn, "5.0.19"},
     {modules, []},
     {registered, [emqx_prometheus_sup]},
-    {applications, [kernel, stdlib, prometheus, emqx, emqx_auth, emqx_management]},
+    {applications, [kernel, stdlib, prometheus, emqx, emqx_auth, emqx_resource, emqx_management]},
     {mod, {emqx_prometheus_app, []}},
     {env, []},
     {licenses, ["Apache-2.0"]},

+ 6 - 5
apps/emqx_prometheus/src/emqx_prometheus_cluster.erl

@@ -16,6 +16,7 @@
 -module(emqx_prometheus_cluster).
 
 -include("emqx_prometheus.hrl").
+-include_lib("emqx_resource/include/emqx_resource.hrl").
 
 -export([
     raw_data/2,
@@ -194,11 +195,11 @@ logic_sum(_, _) ->
 boolean_to_number(true) -> 1;
 boolean_to_number(false) -> 0.
 
-status_to_number(connected) -> 1;
-%% for auth
-status_to_number(stopped) -> 0;
-%% for data_integration
-status_to_number(disconnected) -> 0.
+status_to_number(?status_connected) -> 1;
+status_to_number(?status_connecting) -> 0;
+status_to_number(?status_disconnected) -> 0;
+status_to_number(?rm_status_stopped) -> 0;
+status_to_number(_) -> 0.
 
 metric_names(MetricWithType) when is_list(MetricWithType) ->
     [Name || {Name, _Type} <- MetricWithType].