@@ -1654,17 +1654,28 @@ private boolean meetPolicyCheckRequirements(RoutingContext rc) {
16541654 respectOptOut = OptoutCheckPolicy .fromValue (requestJsonObject .getInteger (POLICY_PARAM )) == OptoutCheckPolicy .respectOptOut ();
16551655 }
16561656
1657- final ClientKey clientKey = (ClientKey ) AuthMiddleware .getAuthClient (rc );
1658- final ClientKey oldestClientKey = this .clientKeyProvider .getOldestClientKey (clientKey .getSiteId ());
1659- boolean newClient = oldestClientKey .getCreated () >= OPT_OUT_CHECK_CUTOFF_DATE ;
1660-
1661- if (newClient && !respectOptOut ) {
1662- // log policy violation
1663- LOGGER .warn (String .format ("Failed to respect opt-out policy: siteId=%d, clientKeyName=%s, clientKeyCreated=%d" ,
1664- oldestClientKey .getSiteId (), oldestClientKey .getName (), oldestClientKey .getCreated ()));
1665- return false ;
1657+ if (respectOptOut ) {
1658+ return true ;
1659+ } else {
1660+ final ClientKey clientKey = (ClientKey ) AuthMiddleware .getAuthClient (rc );
1661+ final ClientKey oldestClientKey = this .clientKeyProvider .getOldestClientKey (clientKey .getSiteId ());
1662+ boolean newClient = oldestClientKey .getCreated () >= OPT_OUT_CHECK_CUTOFF_DATE ;
1663+
1664+ if (!newClient ) {
1665+ Counter .builder ("uid2_opt_out_no_respect_total" )
1666+ .description ("Counter for the number of successful requests that have optout set to zero (legacy clients)" )
1667+ .tag ("client_name" , clientKey .getName ())
1668+ .tag ("client_contact" , clientKey .getContact ())
1669+ .register (Metrics .globalRegistry )
1670+ .increment ();
1671+ return true ;
1672+ } else {
1673+ // log policy violation
1674+ LOGGER .warn (String .format ("Failed to respect opt-out policy: siteId=%d, clientKeyName=%s, clientKeyCreated=%d" ,
1675+ oldestClientKey .getSiteId (), oldestClientKey .getName (), oldestClientKey .getCreated ()));
1676+ return false ;
1677+ }
16661678 }
1667- return true ;
16681679 }
16691680
16701681 private Tuple .Tuple2 <OptoutCheckPolicy , String > readOptoutCheckPolicy (JsonObject req ) {
0 commit comments