anchor.diff:                           assert_no_duplicates(ReporterList),
                            lists:foldr(
                              fun({Reporter, Opt}, Acc) ->
  +                                   Restart = get_restart(Opt),
                                      {Pid, MRef} = spawn_reporter(Reporter, Opt),
                                      [ #reporter { module = Reporter,
                                                    pid = Pid,
  -                                                 mref = MRef} | Acc]
  +                                                 mref = MRef,
  +                                                 opts = Opt,
  +                                                 restart = Restart} | Acc]
                              end, [], ReporterList);
                        false -> 
                            []
  
positive.code:           t_ref     :: reference()
           }).
  
  -record(reporter, {
            pid       :: pid(),
            mref      :: reference(),
            module    :: module()
           }).
  
  -record(st, {
  
negative.code:     ?warning("Incorrect static subscriber spec ~p. "
               "Use { Reporter, Metric, DataPoint, Interval [, Extra ]}~n", [ Other ]),
      Acc.
  
  add_restart(#restart{spec = Spec,
                       history = H,
                       save_n = N} = R) ->
      T = exometer_util:timestamp(),
      H1 = lists:sublist([T|H], 1, N),
      case match_frequency(H1, Spec) of
          {remove, Action} ->
              {remove, Action};
          restart ->
              {restart, R#restart{history = H1}}
      end.
  
  match_frequency([H|T], Spec) ->
      match_frequency(T, 1, H, Spec).
  
  match_frequency([H|T], R, Since, Spec) ->
      R1 = R+1,
      %% Note that we traverse millisec timestamps backwards in time
      Span = (Since - H) div 1000,
      case find_match(Spec, R1, Span) of
          {true, Action} ->
              {remove, Action};
          false ->
              match_frequency(T, R1, Since, Spec)
      end;
  match_frequency([], _, _, _) ->
      restart.
  
  find_match([{R1,T1}|Tail], R, T) when R1 >= R, T1 =< T ->
      {true, find_action(Tail)};
  find_match([_|Tail], R, T) ->
      find_match(Tail, R, T);
  find_match([], _, _) ->
      false.
  
  find_action([{M,F} = H|_]) when is_atom(M), is_atom(F) -> H;
  find_action([H|_]) when H==kill; H==shutdown -> H;
  find_action([_|T]) ->
      find_action(T);
  find_action([]) ->
      unsubscribe.
  
  default_restart() ->
      [{3, 1}, {10, 30}, kill].
  
  get_restart(Opts) ->
      case lists:keyfind(restart, 1, Opts) of
          {_, R} ->
              restart_rec(valid_restart(R));
          false ->
              restart_rec(default_restart())
      end.
  
  restart_rec(L) ->
      Save = lists:foldl(fun({R,_}, Acc) -> erlang:max(R, Acc);
                            (_, Acc) -> Acc
                         end, 0, L),
      #restart{spec = L,
               save_n = Save}.
  
  valid_restart(L) when is_list(L) ->
      lists:foreach(
        fun({R,T}) when is_integer(R), is_integer(T), R > 0, T > 0 ->
                ok;
           (kill) -> ok;
           (shutdown) -> ok;
           ({M,F}) when is_atom(M), is_atom(F) -> ok;
           (_) ->
                erlang:error({invalid_restart_spec, L})
        end, L),
      L.
                 
  