diff options
| author | Michael Klishin <mklishin@pivotal.io> | 2015-05-02 13:20:07 +0300 |
|---|---|---|
| committer | Michael Klishin <mklishin@pivotal.io> | 2015-05-02 13:20:07 +0300 |
| commit | c29e7c331c05940b7264b1131c1d31d04916aee6 (patch) | |
| tree | eb52e1028113522f1250ab09dcc211ff55e1a23b | |
| parent | abc354dc34f302637098cbe94340911ae4b95ffc (diff) | |
| download | rabbitmq-server-git-c29e7c331c05940b7264b1131c1d31d04916aee6.tar.gz | |
Make it possible to publish credit_flow events to rabbit_event
This is not intended to be used by end users, at least not yet, so
this is an opt-in compilation flag.
To enable:
make CREDIT_FLOW_TRACING=true
| -rw-r--r-- | Makefile | 4 | ||||
| -rw-r--r-- | src/credit_flow.erl | 12 |
2 files changed, 16 insertions, 0 deletions
@@ -65,6 +65,10 @@ else ERLC_OPTS += -DINSTR_MOD=gm endif +ifdef CREDIT_FLOW_TRACING +ERLC_OPTS += -DCREDIT_FLOW_TRACING=true +endif + include version.mk PLUGINS_SRC_DIR?=$(shell [ -d "plugins-src" ] && echo "plugins-src" || echo ) diff --git a/src/credit_flow.erl b/src/credit_flow.erl index 8932062145..c7c20cd15e 100644 --- a/src/credit_flow.erl +++ b/src/credit_flow.erl @@ -68,6 +68,16 @@ put(Key, Expr) end). +-ifdef(CREDIT_FLOW_TRACING). +-define(TRACE_BLOCKED(THIS, FROM), rabbit_event:notify(credit_flow_blocked, + [{process, THIS}, {from, FROM}])). +-define(TRACE_UNBLOCKED(THIS, FROM), rabbit_event:notify(credit_flow_unblocked, + [{process, THIS}, {from, FROM}])). +-else. +-define(TRACE_BLOCKED(THIS, FROM), ok). +-define(TRACE_UNBLOCKED(THIS, FROM), ok). +-endif. + %%---------------------------------------------------------------------------- %% There are two "flows" here; of messages and of credit, going in @@ -143,6 +153,7 @@ grant(To, Quantity) -> end. block(From) -> + ?TRACE_BLOCKED(self(), From), case blocked() of false -> put(credit_blocked_at, erlang:now()); true -> ok @@ -150,6 +161,7 @@ block(From) -> ?UPDATE(credit_blocked, [], Blocks, [From | Blocks]). unblock(From) -> + ?TRACE_UNBLOCKED(self(), From), ?UPDATE(credit_blocked, [], Blocks, Blocks -- [From]), case blocked() of false -> case erase(credit_deferred) of |
