From 9c6ce08db0794ff34b00c7d5a1a0c04371f41a01 Mon Sep 17 00:00:00 2001 From: Jon Chambers Date: Sun, 10 Jan 2021 22:45:01 -0500 Subject: [PATCH] Break down message send attempts by client platform, message ephemerality, and sealed sender status. --- .../controllers/MessageController.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/service/src/main/java/org/whispersystems/textsecuregcm/controllers/MessageController.java b/service/src/main/java/org/whispersystems/textsecuregcm/controllers/MessageController.java index 316122821..3f28bdd97 100644 --- a/service/src/main/java/org/whispersystems/textsecuregcm/controllers/MessageController.java +++ b/service/src/main/java/org/whispersystems/textsecuregcm/controllers/MessageController.java @@ -14,6 +14,7 @@ import com.google.protobuf.ByteString; import io.dropwizard.auth.Auth; import io.dropwizard.util.DataSize; import io.micrometer.core.instrument.Metrics; +import io.micrometer.core.instrument.Tag; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.whispersystems.textsecuregcm.auth.AmbiguousIdentifier; @@ -87,9 +88,13 @@ public class MessageController { private final MessagesManager messagesManager; private final ApnFallbackManager apnFallbackManager; + private static final String SENT_MESSAGE_COUNTER_NAME = name(MessageController.class, "sentMessages"); private static final String CONTENT_SIZE_DISTRIBUTION_NAME = name(MessageController.class, "messageContentSize"); private static final String OUTGOING_MESSAGE_LIST_SIZE_BYTES_DISTRIBUTION_NAME = name(MessageController.class, "outgoingMessageListSizeBytes"); + private static final String EPHEMERAL_TAG_NAME = "ephemeral"; + private static final String SENDER_TYPE_TAG_NAME = "senderType"; + private static final long MAX_MESSAGE_SIZE = DataSize.kibibytes(256).toBytes(); public MessageController(RateLimiters rateLimiters, @@ -134,10 +139,16 @@ public class MessageController { } } + final String senderType; + if (source.isPresent() && !source.get().isFor(destinationName)) { identifiedMeter.mark(); + senderType = "identified"; } else if (source.isEmpty()) { unidentifiedMeter.mark(); + senderType = "unidentified"; + } else { + senderType = "self"; } for (final IncomingMessage message : messages.getMessages()) { @@ -173,10 +184,15 @@ public class MessageController { validateCompleteDeviceList(destination.get(), messages.getMessages(), isSyncMessage); validateRegistrationIds(destination.get(), messages.getMessages()); + final List tags = List.of(UserAgentTagUtil.getPlatformTag(userAgent), + Tag.of(EPHEMERAL_TAG_NAME, String.valueOf(messages.isOnline())), + Tag.of(SENDER_TYPE_TAG_NAME, senderType)); + for (IncomingMessage incomingMessage : messages.getMessages()) { Optional destinationDevice = destination.get().getDevice(incomingMessage.getDestinationDeviceId()); if (destinationDevice.isPresent()) { + Metrics.counter(SENT_MESSAGE_COUNTER_NAME, tags).increment(); sendMessage(source, destination.get(), destinationDevice.get(), messages.getTimestamp(), messages.isOnline(), incomingMessage); } }