From f41e1716c68d6954b0f01431adf0ac31e186fae0 Mon Sep 17 00:00:00 2001 From: Jon Chambers Date: Fri, 16 Feb 2024 11:25:41 -0500 Subject: [PATCH] Combine/expand existing "get keys" counter --- .../controllers/KeysController.java | 23 +++++++------------ 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/service/src/main/java/org/whispersystems/textsecuregcm/controllers/KeysController.java b/service/src/main/java/org/whispersystems/textsecuregcm/controllers/KeysController.java index 144e62b50..65412f657 100644 --- a/service/src/main/java/org/whispersystems/textsecuregcm/controllers/KeysController.java +++ b/service/src/main/java/org/whispersystems/textsecuregcm/controllers/KeysController.java @@ -73,8 +73,6 @@ public class KeysController { private final AccountsManager accounts; private static final String GET_KEYS_COUNTER_NAME = MetricsUtil.name(KeysController.class, "getKeys"); - private static final String ONE_TIME_EC_PRE_KEY_UNAVAILABLE_COUNTER_NAME = - MetricsUtil.name(KeysController.class, "oneTimeEcPreKeyUnavailable"); private static final CompletableFuture[] EMPTY_FUTURE_ARRAY = new CompletableFuture[0]; @@ -215,11 +213,6 @@ public class KeysController { + "." + deviceId); } - Metrics.counter(GET_KEYS_COUNTER_NAME, Tags.of( - UserAgentTagUtil.getPlatformTag(userAgent), - io.micrometer.core.instrument.Tag.of("wildcardDeviceId", String.valueOf("*".equals(deviceId))))) - .increment(); - final List devices = parseDeviceId(deviceId, target); final List responseItems = new ArrayList<>(devices.size()); @@ -239,14 +232,14 @@ public class KeysController { final ECPreKey unsignedEcPreKey = unsignedEcPreKeyFuture.join().orElse(null); final ECSignedPreKey signedEcPreKey = signedEcPreKeyFuture.join().orElse(null); - if (unsignedEcPreKey == null) { - Metrics.counter(ONE_TIME_EC_PRE_KEY_UNAVAILABLE_COUNTER_NAME, - "isPrimary", String.valueOf(device.isPrimary()), - "platform", getDevicePlatform(device).map(Enum::name).orElse("unknown"), - "identityType", targetIdentifier.identityType().name(), - "isStale", String.valueOf(isDeviceStale(device))) - .increment(); - } + Metrics.counter(GET_KEYS_COUNTER_NAME, Tags.of( + io.micrometer.core.instrument.Tag.of("isPrimary", String.valueOf(device.isPrimary())), + UserAgentTagUtil.getPlatformTag(userAgent), + io.micrometer.core.instrument.Tag.of("targetPlatform", getDevicePlatform(device).map(Enum::name).orElse("unknown")), + io.micrometer.core.instrument.Tag.of("identityType", targetIdentifier.identityType().name()), + io.micrometer.core.instrument.Tag.of("isStale", String.valueOf(isDeviceStale(device))), + io.micrometer.core.instrument.Tag.of("oneTimeEcKeyAvailable", String.valueOf(unsignedEcPreKey == null)))) + .increment(); if (signedEcPreKey != null || unsignedEcPreKey != null || pqPreKey != null) { final int registrationId = switch (targetIdentifier.identityType()) {