mirror of
https://github.com/signalapp/Signal-Server
synced 2026-04-21 01:18:20 +01:00
Add diagnostic dimensions to the "get keys" counter
This commit is contained in:
committed by
Jon Chambers
parent
3e12a8780d
commit
cd64390141
@@ -894,7 +894,7 @@ public class WhisperServerService extends Application<WhisperServerConfiguration
|
||||
new DirectoryV2Controller(directoryV2CredentialsGenerator),
|
||||
new DonationController(clock, zkReceiptOperations, redeemedReceiptsManager, accountsManager, config.getBadges(),
|
||||
ReceiptCredentialPresentation::new),
|
||||
new KeysController(rateLimiters, keysManager, accountsManager),
|
||||
new KeysController(rateLimiters, keysManager, accountsManager, clientReleaseManager),
|
||||
new MessageController(rateLimiters, messageByteLimitCardinalityEstimator, messageSender, receiptSender,
|
||||
accountsManager, messagesManager, pushNotificationManager, reportMessageManager,
|
||||
multiRecipientMessageExecutor, messageDeliveryScheduler, reportSpamTokenProvider, clientReleaseManager,
|
||||
|
||||
@@ -58,6 +58,7 @@ import org.whispersystems.textsecuregcm.metrics.MetricsUtil;
|
||||
import org.whispersystems.textsecuregcm.metrics.UserAgentTagUtil;
|
||||
import org.whispersystems.textsecuregcm.storage.Account;
|
||||
import org.whispersystems.textsecuregcm.storage.AccountsManager;
|
||||
import org.whispersystems.textsecuregcm.storage.ClientReleaseManager;
|
||||
import org.whispersystems.textsecuregcm.storage.Device;
|
||||
import org.whispersystems.textsecuregcm.storage.KeysManager;
|
||||
import org.whispersystems.textsecuregcm.util.HeaderUtils;
|
||||
@@ -72,6 +73,7 @@ public class KeysController {
|
||||
private final RateLimiters rateLimiters;
|
||||
private final KeysManager keysManager;
|
||||
private final AccountsManager accounts;
|
||||
private final ClientReleaseManager clientReleaseManager;
|
||||
|
||||
private static final String KEY_COUNT_DISTRIBUTION_NAME = MetricsUtil.name(KeysController.class, "getKeyCount");
|
||||
private static final String GET_KEYS_COUNTER_NAME = MetricsUtil.name(KeysController.class, "getKeys");
|
||||
@@ -82,10 +84,11 @@ public class KeysController {
|
||||
|
||||
private static final CompletableFuture<?>[] EMPTY_FUTURE_ARRAY = new CompletableFuture[0];
|
||||
|
||||
public KeysController(RateLimiters rateLimiters, KeysManager keysManager, AccountsManager accounts) {
|
||||
public KeysController(RateLimiters rateLimiters, KeysManager keysManager, AccountsManager accounts, ClientReleaseManager clientReleaseManager) {
|
||||
this.rateLimiters = rateLimiters;
|
||||
this.keysManager = keysManager;
|
||||
this.accounts = accounts;
|
||||
this.clientReleaseManager = clientReleaseManager;
|
||||
}
|
||||
|
||||
@GET
|
||||
@@ -282,14 +285,26 @@ public class KeysController {
|
||||
final ECPreKey unsignedEcPreKey = unsignedEcPreKeyFuture.join().orElse(null);
|
||||
final ECSignedPreKey signedEcPreKey = signedEcPreKeyFuture.join().orElse(null);
|
||||
|
||||
Metrics.counter(GET_KEYS_COUNTER_NAME, Tags.of(
|
||||
Tag.of(PRIMARY_DEVICE_TAG_NAME, String.valueOf(device.isPrimary())),
|
||||
UserAgentTagUtil.getPlatformTag(userAgent),
|
||||
Tag.of("targetPlatform", getDevicePlatform(device).map(Enum::name).orElse("unknown")),
|
||||
Tag.of(IDENTITY_TYPE_TAG_NAME, targetIdentifier.identityType().name()),
|
||||
Tag.of("isStale", String.valueOf(isDeviceStale(device))),
|
||||
Tag.of("oneTimeEcKeyAvailable", String.valueOf(unsignedEcPreKey != null))))
|
||||
.increment();
|
||||
Tags tags = Tags.of(
|
||||
Tag.of(PRIMARY_DEVICE_TAG_NAME, String.valueOf(device.isPrimary())),
|
||||
UserAgentTagUtil.getPlatformTag(userAgent),
|
||||
Tag.of("targetPlatform", getDevicePlatform(device).map(Enum::name).orElse("unknown")),
|
||||
Tag.of(IDENTITY_TYPE_TAG_NAME, targetIdentifier.identityType().name()),
|
||||
Tag.of("isStale", String.valueOf(isDeviceStale(device))),
|
||||
Tag.of("oneTimeEcKeyAvailable", String.valueOf(unsignedEcPreKey != null)),
|
||||
Tag.of("authenticationType", auth.isPresent() ? "authenticated" : "anonymous"));
|
||||
|
||||
if (auth.isPresent()) {
|
||||
tags = tags.and(Tag.of("targetIsSelf", String.valueOf(auth.get().getAccount().getUuid().equals(target.getUuid()))));
|
||||
}
|
||||
|
||||
final Optional<Tag> maybeClientVersionTag = UserAgentTagUtil.getClientVersionTag(userAgent, clientReleaseManager);
|
||||
|
||||
if (maybeClientVersionTag.isPresent()) {
|
||||
tags = tags.and(maybeClientVersionTag.get());
|
||||
}
|
||||
|
||||
Metrics.counter(GET_KEYS_COUNTER_NAME, tags).increment();
|
||||
|
||||
if (signedEcPreKey != null || unsignedEcPreKey != null || pqPreKey != null) {
|
||||
final int registrationId = switch (targetIdentifier.identityType()) {
|
||||
|
||||
Reference in New Issue
Block a user