mirror of
https://github.com/signalapp/Signal-Server
synced 2026-04-21 09:28:11 +01:00
Add identity type/"stale" dimensions to the "pre-key unavailable" counter
This commit is contained in:
committed by
Jon Chambers
parent
fef57dce0d
commit
4dce0f1b9d
@@ -15,6 +15,8 @@ import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import io.swagger.v3.oas.annotations.parameters.RequestBody;
|
||||
import io.swagger.v3.oas.annotations.responses.ApiResponse;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
@@ -239,8 +241,10 @@ public class KeysController {
|
||||
|
||||
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"))
|
||||
"isPrimary", String.valueOf(device.isPrimary()),
|
||||
"platform", getDevicePlatform(device).map(Enum::name).orElse("unknown"),
|
||||
"identityType", targetIdentifier.identityType().name(),
|
||||
"isStale", String.valueOf(isDeviceStale(device)))
|
||||
.increment();
|
||||
}
|
||||
|
||||
@@ -279,6 +283,11 @@ public class KeysController {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
private static boolean isDeviceStale(final Device device) {
|
||||
return Duration.between(Instant.ofEpochMilli(device.getLastSeen()), Instant.now())
|
||||
.compareTo(Duration.ofDays(30)) >= 0;
|
||||
}
|
||||
|
||||
@PUT
|
||||
@Path("/signed")
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
|
||||
Reference in New Issue
Block a user