fix: monitor timestamp millsecond

This commit is contained in:
DDDHuang 2021-08-13 14:26:43 +08:00
parent e73df538a7
commit 23a8e28f77
1 changed files with 4 additions and 3 deletions

View File

@ -139,7 +139,8 @@ counter_schema() ->
type => object, type => object,
properties => #{ properties => #{
timestamp => #{ timestamp => #{
type => integer}, type => integer,
description => <<"Millisecond">>},
count => #{ count => #{
type => integer}}}}. type => integer}}}}.
%%%============================================================================================== %%%==============================================================================================
@ -298,7 +299,7 @@ format([#mqtt_collect{timestamp = Ts, collect = {C, R, S, Re, S1, D}} | Collects
[[Ts, S1] | Sent], [[Ts, S1] | Sent],
[[Ts, D] | Dropped]}). [[Ts, D] | Dropped]}).
add_key(Collects) -> add_key(Collects) ->
lists:reverse([#{timestamp => Ts, count => C} || [Ts, C] <- Collects]). lists:reverse([#{timestamp => Ts * 1000, count => C} || [Ts, C] <- Collects]).
format_single(Collects, Counter) -> format_single(Collects, Counter) ->
#{Counter => format_single(Collects, counter_index(Counter), [])}. #{Counter => format_single(Collects, counter_index(Counter), [])}.
@ -306,7 +307,7 @@ format_single([], _Index, Acc) ->
lists:reverse(Acc); lists:reverse(Acc);
format_single([#mqtt_collect{timestamp = Ts, collect = Collect} | Collects], Index, Acc) -> format_single([#mqtt_collect{timestamp = Ts, collect = Collect} | Collects], Index, Acc) ->
format_single(Collects, Index, format_single(Collects, Index,
[#{timestamp => Ts, count => erlang:element(Index, Collect)} | Acc]). [#{timestamp => Ts * 1000, count => erlang:element(Index, Collect)} | Acc]).
counter_index(connection) -> 1; counter_index(connection) -> 1;
counter_index(route) -> 2; counter_index(route) -> 2;