diff options
| author | Jean-Sébastien Pédron <jean-sebastien@rabbitmq.com> | 2015-07-31 18:46:08 +0200 |
|---|---|---|
| committer | Jean-Sébastien Pédron <jean-sebastien@rabbitmq.com> | 2015-08-05 16:16:38 +0200 |
| commit | 869d2bbe7b9b2f3d8cf4fb39843cd93d6450fff8 (patch) | |
| tree | 4bc6b6f7d761d5381769b5653deb80e94f2708b7 /src | |
| parent | 52a12c0cd87fee85c50ed0affa5362764bd9775e (diff) | |
| download | rabbitmq-server-git-869d2bbe7b9b2f3d8cf4fb39843cd93d6450fff8.tar.gz | |
Replace os:timestamp() with os:system_time(milli_seconds)
It will require all consumers of eg. events to be updated. But this is a
good occasion anyway to change the exposed timestamp format to something
pushed by the new Time API.
Comparisons and calculations are much simpler because the new format is
a simple integer.
The resolution is a millisecond, not a microsecond, because current
consumers of these timestamps do calculations in milliseconds.
References #233.
Diffstat (limited to 'src')
| -rw-r--r-- | src/credit_flow.erl | 8 | ||||
| -rw-r--r-- | src/rabbit_amqqueue_process.erl | 7 | ||||
| -rw-r--r-- | src/rabbit_channel.erl | 5 | ||||
| -rw-r--r-- | src/rabbit_event.erl | 5 |
4 files changed, 17 insertions, 8 deletions
diff --git a/src/credit_flow.erl b/src/credit_flow.erl index afd97ce96c..d679696dcb 100644 --- a/src/credit_flow.erl +++ b/src/credit_flow.erl @@ -92,11 +92,15 @@ {process_info, erlang:process_info(SELF)}, {from, FROM}, {from_info, erlang:process_info(FROM)}, - {timestamp, os:timestamp()}])). + {timestamp, + time_compat:os_system_time( + milliseconds)}])). -define(TRACE_UNBLOCKED(SELF, FROM), rabbit_event:notify(credit_flow_unblocked, [{process, SELF}, {from, FROM}, - {timestamp, os:timestamp()}])). + {timestamp, + time_compat:os_system_time( + milliseconds)}])). -else. -define(TRACE_BLOCKED(SELF, FROM), ok). -define(TRACE_UNBLOCKED(SELF, FROM), ok). diff --git a/src/rabbit_amqqueue_process.erl b/src/rabbit_amqqueue_process.erl index e4c6897936..c1e6e5286e 100644 --- a/src/rabbit_amqqueue_process.erl +++ b/src/rabbit_amqqueue_process.erl @@ -1305,8 +1305,11 @@ handle_pre_hibernate(State = #q{backing_queue = BQ, BQS3 = BQ:handle_pre_hibernate(BQS2), rabbit_event:if_enabled( State, #q.stats_timer, - fun () -> emit_stats(State, [{idle_since, os:timestamp()}, - {consumer_utilisation, ''}]) end), + fun () -> emit_stats(State, + [{idle_since, + time_compat:os_system_time(milli_seconds)}, + {consumer_utilisation, ''}]) + end), State1 = rabbit_event:stop_stats_timer(State#q{backing_queue_state = BQS3}, #q.stats_timer), {hibernate, stop_rate_timer(State1)}. diff --git a/src/rabbit_channel.erl b/src/rabbit_channel.erl index d51a8f04c4..db16817845 100644 --- a/src/rabbit_channel.erl +++ b/src/rabbit_channel.erl @@ -578,7 +578,10 @@ handle_pre_hibernate(State) -> ok = clear_permission_cache(), rabbit_event:if_enabled( State, #ch.stats_timer, - fun () -> emit_stats(State, [{idle_since, os:timestamp()}]) end), + fun () -> emit_stats(State, + [{idle_since, + time_compat:os_system_time(milli_seconds)}]) + end), {hibernate, rabbit_event:stop_stats_timer(State, #ch.stats_timer)}. terminate(Reason, State) -> diff --git a/src/rabbit_event.erl b/src/rabbit_event.erl index 13bf6bc6f8..4d62dd079b 100644 --- a/src/rabbit_event.erl +++ b/src/rabbit_event.erl @@ -37,8 +37,7 @@ -type(event_type() :: atom()). -type(event_props() :: term()). --type(event_timestamp() :: - {non_neg_integer(), non_neg_integer(), non_neg_integer()}). +-type(event_timestamp() :: non_neg_integer()). -type(event() :: #event { type :: event_type(), props :: event_props(), @@ -160,5 +159,5 @@ event_cons(Type, Props, Ref) -> #event{type = Type, props = Props, reference = Ref, - timestamp = os:timestamp()}. + timestamp = time_compat:os_system_time(milli_seconds)}. |
