@@ -71,7 +71,8 @@ public class UIDOperatorVerticle extends AbstractVerticle{
7171 private final Clock clock ;
7272 private IUIDOperatorService idService ;
7373 private final Map <String , DistributionSummary > _identityMapMetricSummaries = new HashMap <>();
74- private final Map <String , DistributionSummary > _refreshDurationMetricSummaries = new HashMap <>();
74+ private final Map <Tuple .Tuple2 <String , Boolean >, DistributionSummary > _refreshDurationMetricSummaries = new HashMap <>();
75+ private final Map <Tuple .Tuple3 <String , Boolean , Boolean >, Counter > _advertisingTokenExpiryStatus = new HashMap <>();
7576 private final Map <Tuple .Tuple2 <String , TokenGeneratePolicy >, Counter > _tokenGeneratePolicyCounters = new HashMap <>();
7677 private final Map <Tuple .Tuple2 <String , IdentityMapPolicy >, Counter > _identityMapPolicyCounters = new HashMap <>();
7778 private final Map <String , Tuple .Tuple2 <Counter , Counter >> _identityMapUnmappedIdentifiers = new HashMap <>();
@@ -372,7 +373,7 @@ private void handleTokenRefreshV1(RoutingContext rc) {
372373 }
373374 } else {
374375 ResponseUtil .Success (rc , toJsonV1 (r .getTokens ()));
375- this .recordRefreshDurationStats (siteId , getApiContact (rc ), r .getDurationSinceLastRefresh ());
376+ this .recordRefreshDurationStats (siteId , getApiContact (rc ), r .getDurationSinceLastRefresh (), rc . request (). headers (). contains ( "Origin" ) );
376377 }
377378
378379 TokenResponseStatsCollector .record (siteId , TokenResponseStatsCollector .Endpoint .RefreshV1 , r );
@@ -402,7 +403,7 @@ private void handleTokenRefreshV2(RoutingContext rc) {
402403 }
403404 } else {
404405 ResponseUtil .SuccessV2 (rc , toJsonV1 (r .getTokens ()));
405- this .recordRefreshDurationStats (siteId , getApiContact (rc ), r .getDurationSinceLastRefresh ());
406+ this .recordRefreshDurationStats (siteId , getApiContact (rc ), r .getDurationSinceLastRefresh (), rc . request (). headers (). contains ( "Origin" ) );
406407 }
407408 TokenResponseStatsCollector .record (siteId , TokenResponseStatsCollector .Endpoint .RefreshV2 , r );
408409 } catch (Exception e ) {
@@ -589,7 +590,7 @@ private void handleTokenRefresh(RoutingContext rc) {
589590
590591 Integer siteId = rc .get (Const .RoutingContextData .SiteId );
591592 if (r .isRefreshed ()) {
592- this .recordRefreshDurationStats (siteId , getApiContact (rc ), r .getDurationSinceLastRefresh ());
593+ this .recordRefreshDurationStats (siteId , getApiContact (rc ), r .getDurationSinceLastRefresh (), rc . request (). headers (). contains ( "Origin" ) );
593594 }
594595 TokenResponseStatsCollector .record (siteId , TokenResponseStatsCollector .Endpoint .RefreshV0 , r );
595596 } catch (Exception e ) {
@@ -1254,16 +1255,29 @@ private RefreshResponse refreshIdentity(RoutingContext rc, String tokenStr) {
12541255 return this .idService .refreshIdentity (refreshToken );
12551256 }
12561257
1257- private void recordRefreshDurationStats (Integer siteId , String apiContact , Duration durationSinceLastRefresh ) {
1258- DistributionSummary ds = _refreshDurationMetricSummaries .computeIfAbsent (apiContact , k ->
1258+ private void recordRefreshDurationStats (Integer siteId , String apiContact , Duration durationSinceLastRefresh , boolean hasOriginHeader ) {
1259+ DistributionSummary ds = _refreshDurationMetricSummaries .computeIfAbsent (new Tuple . Tuple2 <>( apiContact , hasOriginHeader ) , k ->
12591260 DistributionSummary
12601261 .builder ("uid2.token_refresh_duration_seconds" )
12611262 .description ("duration between token refreshes" )
12621263 .tag ("site_id" , String .valueOf (siteId ))
12631264 .tag ("api_contact" , apiContact )
1265+ .tag ("has_origin_header" , hasOriginHeader ? "true" : "false" )
12641266 .register (Metrics .globalRegistry )
12651267 );
12661268 ds .record (durationSinceLastRefresh .getSeconds ());
1269+
1270+ boolean isExpired = durationSinceLastRefresh .compareTo (this .idService .getIdentityExpiryDuration ()) > 0 ;
1271+ Counter c = _advertisingTokenExpiryStatus .computeIfAbsent (new Tuple .Tuple3 <>(String .valueOf (siteId ), hasOriginHeader , isExpired ), k ->
1272+ Counter
1273+ .builder ("uid2.advertising_token_expired_on_refresh" )
1274+ .description ("status of advertiser token expiry" )
1275+ .tag ("site_id" , String .valueOf (siteId ))
1276+ .tag ("has_origin_header" , hasOriginHeader ? "true" : "false" )
1277+ .tag ("is_expired" , isExpired ? "true" : "false" )
1278+ .register (Metrics .globalRegistry )
1279+ );
1280+ c .increment ();
12671281 }
12681282
12691283 private InputUtil .InputVal [] createInputList (JsonArray a , boolean inputAsHash ) {
@@ -1458,6 +1472,4 @@ public static enum UserConsentStatus {
14581472 INSUFFICIENT ,
14591473 INVALID ,
14601474 }
1461-
1462-
14631475}
0 commit comments