summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon MacMullen <simon@rabbitmq.com>2010-07-19 16:21:59 +0100
committerSimon MacMullen <simon@rabbitmq.com>2010-07-19 16:21:59 +0100
commite6f5dee609d82930c28cca0446b486a4759706db (patch)
tree84e93c5a171c53604db19f94459174307ece6415
parent26bcbe8230e3c4fe7692768a143b61ea809dd1fb (diff)
downloadrabbitmq-server-e6f5dee609d82930c28cca0446b486a4759706db.tar.gz
Switch to using proplists rather than records for events.
-rw-r--r--include/rabbit.hrl22
-rw-r--r--src/rabbit_amqqueue_process.erl20
-rw-r--r--src/rabbit_channel.erl21
-rw-r--r--src/rabbit_event.erl10
-rw-r--r--src/rabbit_reader.erl42
5 files changed, 49 insertions, 66 deletions
diff --git a/include/rabbit.hrl b/include/rabbit.hrl
index f400495c..ac7e3851 100644
--- a/include/rabbit.hrl
+++ b/include/rabbit.hrl
@@ -70,27 +70,7 @@
-record(delivery, {mandatory, immediate, txn, sender, message}).
-record(amqp_error, {name, explanation, method = none}).
-
--record(event_connection_stats, {connection_pid, state, channels,
- recv_oct, recv_cnt,
- send_oct, send_cnt, send_pend}).
-
--record(event_channel_stats, {channel_pid, per_exchange_statistics,
- per_queue_statistics}).
-
--record(event_queue_stats, {qpid, messages_ready, messages_unacknowledged,
- consumers, memory, exclusive_consumer_pid,
- exclusive_consumer_tag, backing_queue_status}).
-
--record(event_connection_created, {connection_pid, address, port,
- peer_address, peer_port, user, vhost,
- timeout, frame_max, client_properties}).
--record(event_connection_closed, {connection_pid}).
--record(event_channel_created, {channel_pid, connection_pid, channel, user,
- vhost}).
--record(event_channel_closed, {channel_pid}).
-
-
+-record(event, {type, props, timestamp}).
%%----------------------------------------------------------------------------
diff --git a/src/rabbit_amqqueue_process.erl b/src/rabbit_amqqueue_process.erl
index 9af77e78..cec36553 100644
--- a/src/rabbit_amqqueue_process.erl
+++ b/src/rabbit_amqqueue_process.erl
@@ -537,16 +537,16 @@ maybe_emit_stats(State = #q{last_statistics_update = LastUpdate}) ->
Now = os:timestamp(),
case timer:now_diff(Now, LastUpdate) > ?STATISTICS_UPDATE_INTERVAL of
true ->
- rabbit_event:notify(#event_queue_stats{
- qpid = self(),
- messages_ready = i(messages_ready, State),
- messages_unacknowledged = i(messages_unacknowledged, State),
- consumers = i(consumers, State),
- memory = i(memory, State),
- exclusive_consumer_tag = i(exclusive_consumer_tag, State),
- exclusive_consumer_pid = i(exclusive_consumer_pid, State),
- backing_queue_status = i(backing_queue_status, State)
- }),
+ rabbit_event:notify(
+ queue_stats,
+ [{qpid, self()},
+ {messages_ready, i(messages_ready, State)},
+ {messages_unacknowledged, i(messages_unacknowledged, State)},
+ {consumers, i(consumers, State)},
+ {memory, i(memory, State)},
+ {exclusive_consumer_tag, i(exclusive_consumer_tag, State)},
+ {exclusive_consumer_pid, i(exclusive_consumer_pid, State)},
+ {backing_queue_status, i(backing_queue_status, State)}]),
State#q{last_statistics_update = Now};
_ ->
State
diff --git a/src/rabbit_channel.erl b/src/rabbit_channel.erl
index dd7c5d4f..2a6e51e1 100644
--- a/src/rabbit_channel.erl
+++ b/src/rabbit_channel.erl
@@ -158,11 +158,11 @@ init([Channel, ReaderPid, WriterPid, Username, VHost, CollectorPid]) ->
process_flag(trap_exit, true),
link(WriterPid),
ok = pg_local:join(rabbit_channels, self()),
- rabbit_event:notify(#event_channel_created{channel_pid = self(),
- connection_pid = ReaderPid,
- channel = Channel,
- user = Username,
- vhost = VHost}),
+ rabbit_event:notify(channel_created, [{channel_pid, self()},
+ {connection_pid, ReaderPid},
+ {channel, Channel},
+ {user, Username},
+ {vhost, VHost}]),
{ok, #ch{state = starting,
channel = Channel,
reader_pid = ReaderPid,
@@ -1134,7 +1134,7 @@ internal_deliver(WriterPid, Notify, ConsumerTag, DeliveryTag,
terminate(#ch{writer_pid = WriterPid, limiter_pid = LimiterPid}) ->
pg_local:leave(rabbit_channels, self()),
- rabbit_event:notify(#event_channel_closed{channel_pid = self()}),
+ rabbit_event:notify(channel_closed, [{channel_pid, self()}]),
rabbit_writer:shutdown(WriterPid),
rabbit_limiter:shutdown(LimiterPid).
@@ -1189,11 +1189,10 @@ maybe_emit_stats(State = #ch{exchange_statistics = ExchangeStatistics,
case timer:now_diff(Now, LastUpdate) > ?STATISTICS_UPDATE_INTERVAL of
true ->
rabbit_event:notify(
- #event_channel_stats{channel_pid = self(),
- per_exchange_statistics =
- dict:to_list(ExchangeStatistics),
- per_queue_statistics =
- dict:to_list(QueueStatistics)}),
+ channel_stats,
+ [{channel_pid, self()},
+ {per_exchange_statistics, dict:to_list(ExchangeStatistics)},
+ {per_queue_statistics, dict:to_list(QueueStatistics)}]),
State#ch{last_statistics_update = Now};
_ ->
State
diff --git a/src/rabbit_event.erl b/src/rabbit_event.erl
index c74d7220..08c13007 100644
--- a/src/rabbit_event.erl
+++ b/src/rabbit_event.erl
@@ -31,9 +31,13 @@
-module(rabbit_event).
--export([notify/1]).
+-include("rabbit.hrl").
+
+-export([notify/2]).
%%----------------------------------------------------------------------------
-notify(Event) ->
- gen_event:notify(rabbit_event, Event).
+notify(Type, Props) ->
+ gen_event:notify(rabbit_event, #event{type = Type,
+ props = Props,
+ timestamp = os:timestamp()}).
diff --git a/src/rabbit_reader.erl b/src/rabbit_reader.erl
index 2dc6d933..fe7d17e8 100644
--- a/src/rabbit_reader.erl
+++ b/src/rabbit_reader.erl
@@ -275,7 +275,7 @@ start_connection(Parent, Deb, Sock, SockTransform) ->
teardown_profiling(ProfilingValue),
rabbit_queue_collector:shutdown(Collector),
rabbit_misc:unlink_and_capture_exit(Collector),
- rabbit_event:notify(#event_connection_closed{connection_pid = self()})
+ rabbit_event:notify(connection_closed, [{connection_pid, self()}])
end,
done.
@@ -664,18 +664,17 @@ handle_method0(#'connection.open'{virtual_host = VHostPath,
Sock,
#'connection.open_ok'{known_hosts = KnownHosts}),
rabbit_event:notify(
- #event_connection_created{connection_pid = self(),
- address = i(address, State),
- port = i(port, State),
- peer_address = i(peer_address, State),
- peer_port = i(peer_port, State),
- user = User,
- vhost = VHost,
- timeout = i(timeout, State),
- frame_max = i(frame_max, State),
- client_properties =
- i(client_properties, State)
- }),
+ connection_created,
+ [{connection_pid, self()},
+ {address, i(address, State)},
+ {port, i(port, State)},
+ {peer_address, i(peer_address, State)},
+ {peer_port, i(peer_port, State)},
+ {user, User},
+ {vhost, VHost},
+ {timeout, i(timeout, State)},
+ {frame_max, i(frame_max, State)},
+ {client_properties, i(client_properties, State)}]),
State#v1{connection_state = running,
connection = NewConnection};
true ->
@@ -870,14 +869,15 @@ maybe_emit_stats(State = #v1{last_statistics_update = LastUpdate}) ->
case timer:now_diff(Now, LastUpdate) > ?STATISTICS_UPDATE_INTERVAL of
true ->
rabbit_event:notify(
- #event_connection_stats{connection_pid = self(),
- state = i(state, State),
- channels = i(channels, State),
- recv_oct = i(recv_oct, State),
- recv_cnt = i(recv_cnt, State),
- send_oct = i(send_oct, State),
- send_cnt = i(send_cnt, State),
- send_pend = i(send_pend, State)}),
+ connection_stats,
+ [{connection_pid, self()},
+ {state, i(state, State)},
+ {channels, i(channels, State)},
+ {recv_oct, i(recv_oct, State)},
+ {recv_cnt, i(recv_cnt, State)},
+ {send_oct, i(send_oct, State)},
+ {send_cnt, i(send_cnt, State)},
+ {send_pend, i(send_pend, State)}]),
State#v1{last_statistics_update = Now};
_ ->
State