Skip to content

Commit dfcdd37

Browse files
logged count for previous key and previous salt
1 parent 715f418 commit dfcdd37

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

src/main/java/com/uid2/admin/salt/SaltRotation.java

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -250,19 +250,22 @@ private void logSaltAges(String saltCountType, TargetDate targetDate, Collection
250250

251251
/** Logging to monitor migration of buckets from salts (old format - v2/v3) to encryption keys (new format - v4) **/
252252
private void logBucketFormatCount(TargetDate targetDate, SaltEntry[] preRotationBuckets, SaltEntry[] postRotationBuckets) {
253-
int migratedKeyBucketCounter = 0, totalKeyBucketCounter = 0, totalSaltBucketCounter = 0;
253+
int migratedKeyBuckets = 0, totalKeys = 0, totalSalts = 0, totalPreviousKeys = 0, totalPreviousSalts = 0;
254254

255255
for (int i = 0; i < preRotationBuckets.length && i < postRotationBuckets.length; i++) {
256256
var oldBucket = preRotationBuckets[i];
257257
var updatedBucket = postRotationBuckets[i];
258258

259-
if (updatedBucket.currentKey() != null) totalKeyBucketCounter++;
260-
if (updatedBucket.currentSalt() != null) totalSaltBucketCounter++;
261-
if (updatedBucket.currentKey() != null && oldBucket.currentSalt() != null) migratedKeyBucketCounter++;
259+
if (updatedBucket.currentKey() != null) totalKeys++;
260+
if (updatedBucket.currentSalt() != null) totalSalts++;
261+
if (updatedBucket.previousKey() != null) totalPreviousKeys++;
262+
if (updatedBucket.previousSalt() != null) totalPreviousSalts++;
263+
if (updatedBucket.currentKey() != null && oldBucket.currentSalt() != null) migratedKeyBuckets++;
262264
}
263265

264-
LOGGER.info("Rotation bucket format: target_date={} migrated_key_bucket_count={} total_key_bucket_count={} total_salt_bucket_count={}",
265-
targetDate, migratedKeyBucketCounter, totalKeyBucketCounter, totalSaltBucketCounter);
266+
LOGGER.info("UID bucket format: target_date={} migrated_key_bucket_count={} total_key_bucket_count={} total_salt_bucket_count={} " +
267+
"total_previous_key_count={} total_previous_salt_count={}",
268+
targetDate, migratedKeyBuckets, totalKeys, totalSalts, totalPreviousKeys, totalPreviousSalts);
266269
}
267270

268271
@Getter

src/test/java/com/uid2/admin/salt/SaltRotationTest.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -752,10 +752,11 @@ void testKeyRotationLogBucketFormat(boolean v4Enabled, int expectedNewKeyBuckets
752752
saltRotation.rotateSalts(lastSnapshot, minAges, 1, targetDate());
753753

754754
var expected = Set.of(
755-
String.format("[INFO] Rotation bucket format: target_date=2025-01-01 migrated_key_bucket_count=%d total_key_bucket_count=%d total_salt_bucket_count=%d",
756-
expectedNewKeyBuckets, expectedTotalKeyBuckets, expectedTotalSaltBuckets)
755+
String.format("[INFO] UID bucket format: target_date=2025-01-01 migrated_key_bucket_count=%d total_key_bucket_count=%d total_salt_bucket_count=%d " +
756+
"total_previous_key_count=%d total_previous_salt_count=%d",
757+
expectedNewKeyBuckets, expectedTotalKeyBuckets, expectedTotalSaltBuckets, 1, 1)
757758
);
758-
var actual = appender.list.stream().map(Object::toString).filter(s -> s.contains("Rotation bucket format")).collect(Collectors.toSet());
759+
var actual = appender.list.stream().map(Object::toString).filter(s -> s.contains("UID bucket format")).collect(Collectors.toSet());
759760
assertThat(actual).isEqualTo(expected);
760761
}
761762
}

0 commit comments

Comments
 (0)