Merge pull request #5482 from DDDHuang/monitor_millseconds

fix: monitor timestamp millsecond
This commit is contained in:
DDDHuang 2021-08-13 15:27:48 +08:00 committed by GitHub
commit 3f1d3b9cf4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 3 deletions

View File

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