feat(resman): also move out metrics collection for debugging
Now `emqx_resource:list_instances_verbose/0` will populate the metrics for each instance, for the sake of simplicity.
This commit is contained in:
parent
d5ae5ebfd8
commit
9c9f39d0f7
|
@ -43,8 +43,7 @@
|
||||||
config := resource_config(),
|
config := resource_config(),
|
||||||
error := term(),
|
error := term(),
|
||||||
state := resource_state(),
|
state := resource_state(),
|
||||||
status := resource_status(),
|
status := resource_status()
|
||||||
metrics => emqx_metrics_worker:metrics()
|
|
||||||
}.
|
}.
|
||||||
-type resource_group() :: binary().
|
-type resource_group() :: binary().
|
||||||
-type creation_opts() :: #{
|
-type creation_opts() :: #{
|
||||||
|
|
|
@ -327,9 +327,12 @@ fetch_creation_opts(Opts) ->
|
||||||
list_instances() ->
|
list_instances() ->
|
||||||
[Id || #{id := Id} <- list_instances_verbose()].
|
[Id || #{id := Id} <- list_instances_verbose()].
|
||||||
|
|
||||||
-spec list_instances_verbose() -> [resource_data()].
|
-spec list_instances_verbose() -> [_ResourceDataWithMetrics :: map()].
|
||||||
list_instances_verbose() ->
|
list_instances_verbose() ->
|
||||||
emqx_resource_manager:list_all().
|
[
|
||||||
|
Res#{metrics => get_metrics(ResId)}
|
||||||
|
|| #{id := ResId} = Res <- emqx_resource_manager:list_all()
|
||||||
|
].
|
||||||
|
|
||||||
-spec list_instances_by_type(module()) -> [resource_id()].
|
-spec list_instances_by_type(module()) -> [resource_id()].
|
||||||
list_instances_by_type(ResourceType) ->
|
list_instances_by_type(ResourceType) ->
|
||||||
|
|
|
@ -258,7 +258,7 @@ reset_metrics(ResId) ->
|
||||||
list_all() ->
|
list_all() ->
|
||||||
try
|
try
|
||||||
[
|
[
|
||||||
data_record_to_external_map_with_metrics(Data)
|
data_record_to_external_map(Data)
|
||||||
|| {_Id, _Group, Data} <- ets:tab2list(?ETS_TABLE)
|
|| {_Id, _Group, Data} <- ets:tab2list(?ETS_TABLE)
|
||||||
]
|
]
|
||||||
catch
|
catch
|
||||||
|
@ -669,11 +669,6 @@ data_record_to_external_map(Data) ->
|
||||||
state => Data#data.state
|
state => Data#data.state
|
||||||
}.
|
}.
|
||||||
|
|
||||||
-spec data_record_to_external_map_with_metrics(data()) -> resource_data().
|
|
||||||
data_record_to_external_map_with_metrics(Data) ->
|
|
||||||
DataMap = data_record_to_external_map(Data),
|
|
||||||
DataMap#{metrics => get_metrics(Data#data.id)}.
|
|
||||||
|
|
||||||
-spec wait_for_ready(resource_id(), integer()) -> ok | timeout | {error, term()}.
|
-spec wait_for_ready(resource_id(), integer()) -> ok | timeout | {error, term()}.
|
||||||
wait_for_ready(ResId, WaitTime) ->
|
wait_for_ready(ResId, WaitTime) ->
|
||||||
do_wait_for_ready(ResId, WaitTime div ?WAIT_FOR_RESOURCE_DELAY).
|
do_wait_for_ready(ResId, WaitTime div ?WAIT_FOR_RESOURCE_DELAY).
|
||||||
|
|
Loading…
Reference in New Issue