mirror of
https://github.com/signalapp/Signal-Server
synced 2026-04-22 12:07:59 +01:00
Allow optional size parameter when requesting message backup upload forms
This commit is contained in:
committed by
ravi-signal
parent
ae2d98750c
commit
3f62677176
@@ -8,17 +8,21 @@ package org.whispersystems.textsecuregcm.metrics;
|
||||
import static org.whispersystems.textsecuregcm.metrics.MetricsUtil.name;
|
||||
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
import io.micrometer.core.instrument.DistributionSummary;
|
||||
import io.micrometer.core.instrument.MeterRegistry;
|
||||
import io.micrometer.core.instrument.Metrics;
|
||||
import io.micrometer.core.instrument.Tag;
|
||||
import io.micrometer.core.instrument.Tags;
|
||||
import org.signal.libsignal.zkgroup.backups.BackupCredentialType;
|
||||
import org.whispersystems.textsecuregcm.auth.AuthenticatedBackupUser;
|
||||
import org.whispersystems.textsecuregcm.backup.CopyResult;
|
||||
import java.util.Optional;
|
||||
|
||||
public class BackupMetrics {
|
||||
|
||||
private final static String COPY_MEDIA_COUNTER_NAME = name(BackupMetrics.class, "copyMedia");
|
||||
private final static String GET_BACKUP_CREDENTIALS_NAME = name(BackupMetrics.class, "getBackupCredentials");
|
||||
private final static String MESSAGE_BACKUP_SIZE_NAME = name(BackupMetrics.class, "messageBackupSize");
|
||||
|
||||
|
||||
private MeterRegistry registry;
|
||||
@@ -48,4 +52,19 @@ public class BackupMetrics {
|
||||
.increment();
|
||||
}
|
||||
|
||||
public void updateMessageBackupSizeDistribution(
|
||||
AuthenticatedBackupUser authenticatedBackupUser,
|
||||
final boolean oversize,
|
||||
final Optional<Long> backupLength) {
|
||||
DistributionSummary.builder(MESSAGE_BACKUP_SIZE_NAME)
|
||||
.publishPercentileHistogram(true)
|
||||
.tags(Tags.of(
|
||||
UserAgentTagUtil.getPlatformTag(authenticatedBackupUser.userAgent()),
|
||||
Tag.of("tier", authenticatedBackupUser.backupLevel().name().toLowerCase()),
|
||||
Tag.of("oversize", Boolean.toString(oversize)),
|
||||
Tag.of("hasBackupLength", Boolean.toString(backupLength.isPresent()))))
|
||||
.register(Metrics.globalRegistry)
|
||||
.record(backupLength.orElse(0L));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user