Browse files

Add tracing routines.

  • Loading branch information...
1 parent b7b26c8 commit 282bcba7842f0d14e69975f73c4b15151b13b74f @jlouis committed Dec 25, 2012
Showing with 8 additions and 0 deletions.
  1. +6 −0 src/sv.erl
  2. +2 −0 src/sv_codel.erl
View
6 src/sv.erl
@@ -2,6 +2,8 @@
-export([timestamp/0]).
-export([run/2]).
+%% Internal API
+-export([report/2]).
%% @doc Enqueue a job on a queue
%% <p>Try to run `Fun' on queue `Name'. The `Fun' is run at time `TP'.
@@ -30,6 +32,10 @@ run(Name, Fun) ->
{error, Reason}
end.
+%% @private
+report(_T, _Event) ->
+ hopefully_traced.
+
%% @doc Construct a timestamp in a canonical way for Safetyvalve.
-spec timestamp() -> term().
timestamp() ->
View
2 src/sv_codel.erl
@@ -132,10 +132,12 @@ control_law(T, I, C) ->
dodequeue(Now, #state { queue = Q } = State) ->
case ?Q:out(Now, Q) of
{empty, [], NQ} ->
+ sv:report(Now, {dodequeue, 0, 0}),
{nodrop, empty, State#state { first_above_time = 0, queue = NQ }};
{{Pkt, InT}, [], NQ} ->
Sojourn = Now - InT,
+ sv:report(Now, {dodequeue, ?Q:len(NQ), Sojourn / 1000}),
dodequeue_(Now, Pkt, Sojourn, State#state { queue = NQ })
end.

0 comments on commit 282bcba

Please sign in to comment.