anchor.diff:      OnlyNewConns = new_connections(OldConns, Conns),
       Parsed = lists:map(fun ip_vs_conn:parse/1, maps:to_list(OnlyNewConns)),
       lists:foreach(fun (C) -> check_connections(C, PollDelay) end, Parsed),
  -    ParsedMap = maps:from_list(lists:map(fun vip_addr_map/1, Parsed)),
  +    ParsedMap = lists:foldl(fun vip_addr_map/2, #{}, Parsed),
       {ok, Metrics} = tcp_metrics_monitor:get_metrics(),
  -    lists:foreach(fun (Metric) -> update_p99(ParsedMap, Metric) end, Metrics),
  +    P99s = get_p99s(ParsedMap, Metrics),
  +    lists:foreach(fun apply_p99/1, P99s),
       Conns.
   
  -vip_addr_map(C = #ip_vs_conn{to_ip = VIP}) -> {int_to_ip(VIP), C}.
  +vip_addr_map(C = #ip_vs_conn{dst_ip = IP}, Z) ->
  +    vip_addr_map(C, Z, maps:get(int_to_ip(IP), Z, undefined)).
  +
  +vip_addr_map(C = #ip_vs_conn{dst_ip = IP}, Z, undefined) ->
  +    maps:put(int_to_ip(IP), [C], Z);
  +vip_addr_map(C = #ip_vs_conn{dst_ip = IP}, Z, Ls) ->
  +    maps:put(int_to_ip(IP), [C | Ls], Z).
   
   new_connections(OldConns, AllConns) ->
       maps:filter(fun(K,V) -> has_new_state(OldConns, {K,V}) end, AllConns).
  
positive.code:     New = new_connections(#{Conn => ConnStatus0}, #{Conn => ConnStatus1}),
      [?_assertEqual(#{Conn => ConnStatus1}, New)].
  
  -endif.
  
negative.code:     AggTags = [[hostname], [hostname, backend]],
      telemetry:counter(mm_connect_successes, Tags, AggTags, 1).
  
  get_p99s(Conns, Metrics) ->
      lists:flatmap(fun (M) -> get_p99_updates(Conns, M) end, Metrics).
  
  get_p99_updates(Conns, {netlink,tcp_metrics,_, _, _, {get,_,_,Attrs}}) ->
      match_metrics(Conns, proplists:get_value(d_addr, Attrs), proplists:get_value(vals, Attrs)).
  
  match_metrics(_, undefined, _) -> [];
  match_metrics(_, _, undefined) -> [];
  match_metrics(Conns, Addr, Vals) -> match_conn(maps:get(Addr, Conns, undefined),
                                                 proplists:get_value(rtt_us, Vals), 
                                                 proplists:get_value(rtt_var_us, Vals)).
  match_conn(undefined, _, _) -> [];
  match_conn(_, undefined, _) -> [];
  match_conn(_, _, undefined) -> [];
  match_conn(Conns, RttUs, RttVarUs) -> [{Conns, RttUs, RttVarUs}].
  
  apply_p99({Conns, RttUs, RttVarUs}) ->
      lists:foreach(fun(C) -> apply_p99(C, RttUs, RttVarUs) end, Conns).
  
  apply_p99(#ip_vs_conn{dst_ip = IP, dst_port = Port,
                        to_ip = VIP, to_port = VIPPort},
            RttUs, RttVarUs) ->
      P99 = erlang:round(1000*(RttUs + math:sqrt(RttVarUs)*3)),
      Tags = named_tags(IP, Port, VIP, VIPPort),
      AggTags = [[hostname], [hostname, backend]],
      telemetry:histogram(mm_connect_latency, Tags, AggTags, P99).
  
  
  -spec(named_tags(IIP :: integer(),
                   Port :: inet:port_numbrer(),
  