diff options
author | Simon MacMullen <simon@rabbitmq.com> | 2011-05-19 17:36:24 +0100 |
---|---|---|
committer | Simon MacMullen <simon@rabbitmq.com> | 2011-05-19 17:36:24 +0100 |
commit | 358a68480d6eb0b0c388deb166342d49c56382f3 (patch) | |
tree | fa2cf8b2bf28b1bda1ac77106b363dd3b8cad757 | |
parent | c39f7e65ced88329bbde31411690b600bb439f90 (diff) | |
download | rabbitmq-server-358a68480d6eb0b0c388deb166342d49c56382f3.tar.gz |
funs are too expensive here. Ouch.
-rw-r--r-- | src/rabbit_trace.erl | 27 |
1 files changed, 13 insertions, 14 deletions
diff --git a/src/rabbit_trace.erl b/src/rabbit_trace.erl index ed1ac05f..df44ed25 100644 --- a/src/rabbit_trace.erl +++ b/src/rabbit_trace.erl @@ -39,32 +39,31 @@ init(VHost) -> trace_exchange(VHost). tap_trace_in(Msg, TraceX) -> - maybe_trace(Msg, TraceX, - fun () -> - {<<"publish.", (xname(Msg))/binary>>, msg_to_table(Msg)} - end). + maybe_trace(Msg, TraceX, publish, []). tap_trace_out({#resource{name = QName}, _QPid, _QMsgId, Redelivered, Msg}, TraceX) -> - maybe_trace(Msg, TraceX, - fun () -> - H = {<<"redelivered">>, signedint, - case Redelivered of true -> 1; false -> 0 end}, - {<<"deliver.", QName/binary>>, [H | msg_to_table(Msg)]} - end). + RedeliveredNum = case Redelivered of true -> 1; false -> 0 end, + maybe_trace(Msg, TraceX, {deliver, QName}, + [{<<"redelivered">>, signedint, RedeliveredNum}]). xname(#basic_message{exchange_name = #resource{name = XName}}) -> XName. vhost(#basic_message{exchange_name = #resource{virtual_host = VHost}}) -> VHost. -maybe_trace(_Msg, none, _Fun) -> +maybe_trace(_Msg, none, _Mode, _Extra) -> ok; -maybe_trace(Msg0, TraceX, Fun) -> +maybe_trace(Msg0, TraceX, Mode, Extra) -> case xname(Msg0) of TraceX -> ok; _ -> Msg = ensure_content_decoded(Msg0), X = rabbit_misc:r(vhost(Msg), exchange, TraceX), - {RKey, Headers} = Fun(), - P = #'P_basic'{headers = Headers}, + {RKPrefix, RKSuffix} = + case Mode of + publish -> {<<"publish">>, xname(Msg0)}; + {deliver, Q} -> {<<"deliver">>, Q} + end, + RKey = <<RKPrefix/binary, ".", RKSuffix/binary>>, + P = #'P_basic'{headers = msg_to_table(Msg) ++ Extra}, case catch rabbit_basic:publish(X, RKey, P, payload(Msg)) of {'EXIT', R} -> rabbit_log:info( "Trace publish died: ~p~n", [R]); |