diff options
| author | Jean-Sébastien Pédron <jean-sebastien.pedron@dumbbell.fr> | 2015-05-07 11:49:45 +0200 |
|---|---|---|
| committer | Jean-Sébastien Pédron <jean-sebastien.pedron@dumbbell.fr> | 2015-05-07 11:49:45 +0200 |
| commit | 441177b7760c9a70f72d342d18d2c9e6911f38b9 (patch) | |
| tree | 78ea9657025578815c407c3d276a278b0ef9e9f0 | |
| parent | 5ad46366823620d5d5ece8820f690905ca184768 (diff) | |
| parent | a26434986308283ef505fca4525a3d2a85a2b254 (diff) | |
| download | rabbitmq-server-git-441177b7760c9a70f72d342d18d2c9e6911f38b9.tar.gz | |
Merge pull request #139 from rabbitmq/rabbitmq-server-137
Introduce conditional tracing of credit_flow events
| -rw-r--r-- | Makefile | 4 | ||||
| -rw-r--r-- | src/credit_flow.erl | 18 |
2 files changed, 22 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 f8e991ede8..7cc8094d91 100644 --- a/src/credit_flow.erl +++ b/src/credit_flow.erl @@ -81,6 +81,22 @@ put(Key, Expr) end). +-ifdef(CREDIT_FLOW_TRACING). +-define(TRACE_BLOCKED(SELF, FROM), rabbit_event:notify(credit_flow_blocked, + [{process, SELF}, + {process_info, erlang:process_info(SELF)}, + {from, FROM}, + {from_info, erlang:process_info(FROM)}, + {timestamp, os:timestamp()}])). +-define(TRACE_UNBLOCKED(SELF, FROM), rabbit_event:notify(credit_flow_unblocked, + [{process, SELF}, + {from, FROM}, + {timestamp, os:timestamp()}])). +-else. +-define(TRACE_BLOCKED(SELF, FROM), ok). +-define(TRACE_UNBLOCKED(SELF, FROM), ok). +-endif. + %%---------------------------------------------------------------------------- %% There are two "flows" here; of messages and of credit, going in @@ -156,6 +172,7 @@ grant(To, Quantity) -> end. block(From) -> + ?TRACE_BLOCKED(self(), From), case blocked() of false -> put(credit_blocked_at, os:timestamp()); true -> ok @@ -163,6 +180,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 |
