anchor.diff:  -define(TABLE, ?PROMETHEUS_SUMMARY_TABLE).
   -define(SUM_POS, 3).
   -define(COUNTER_POS, 2).
  +-define(WIDTH, 16).
   
   %%====================================================================
   %% Metric API
  
positive.code: %% @end
  observe(Registry, Name, LabelValues, Value) when is_integer(Value) ->
    try
      ets:update_counter(?TABLE, {Registry, Name, LabelValues},
                         [{?COUNTER_POS, 1}, {?SUM_POS, Value}])
    catch error:badarg ->
        insert_metric(Registry, Name, LabelValues, Value, fun observe/4)
  
negative.code: sum(Metric) ->
    element(?SUM_POS, Metric).
  
  key(Registry, Name, LabelValues) ->
    X = erlang:system_info(scheduler_id),
    Rnd = X band (?WIDTH-1),
    {Registry, Name, LabelValues, Rnd}.
  
  collect_unique_labels(MFValues) ->
    lists:usort([L || [L, _, _] <- MFValues]).
  
  reduce_label_values(Labels, MFValues) ->
    {lists:sum([C || [L, C, _] <- MFValues, L == Labels]),
     lists:sum([S || [L, _, S] <- MFValues, L == Labels])}.
  
  reduce_values(Values) ->
    {lists:sum([C || [C, _] <- Values]),
     lists:sum([S || [_, S] <- Values])}.
  
  create_summary(Name, Help, Data) ->
    prometheus_model_helpers:create_mf(Name, Help, summary, ?MODULE, Data).
  