anchor.diff:           terminate/2,
            code_change/3]).
   
  --record(state, {port, socket, counters, timers, gauges, sets}).
  +-record(state, {port, socket, counters, timers, gauges, sets, timer}).
   
   -define(DELIMITER_PIPE, <<"|">>).
   -define(DELIMITER_COLON, <<":">>).
  
positive.code: %% @spec terminate(Reason, State) -> void()
  %% @end
  %%--------------------------------------------------------------------
  terminate(_Reason, _State) ->
      ok.
  
  %%--------------------------------------------------------------------
  
negative.code:     lager:debug("handle counter: ~p:~w [sample ~w]", [Metric, Value, Sample]),
  
      Counters0 = State#state.counters,
      Update = fun(X) -> X + (Value * (1 / Sample)) end,
      Counters = maps:update_with(Metric, Update, (Value * (1 / Sample)), Counters0),
  
      {ok, State#state{counters=Counters}};
  
  handle_metric(State, Metric, {ok, Value}, <<"ms">>, {ok, Sample}) ->
      lager:debug("handle timer: ~p:~w [sample ~w]", [Metric, Value, Sample]),
  
      Inc = 1 / Sample,
      Timers0 = State#state.timers,
      Update = fun({Xs, Cnt}) -> {[Value | Xs], Cnt + Inc} end,
      Timers = maps:update_with(Metric, Update, {[Value], Inc}, Timers0),
  
      {ok, State#state{timers=Timers}};
  
  