Include message timestamp in local send timings.

This commit is contained in:
Greyson Parrelli
2024-05-13 16:00:45 -04:00
committed by Nicholas Tinsley
parent c3c743fbb8
commit b4a8f01980
6 changed files with 32 additions and 7 deletions

View File

@@ -56,7 +56,7 @@ object LocalMetrics {
eventId = id,
eventName = name,
splits = mutableListOf(),
timeunit = timeunit
timeUnit = timeunit
)
lastSplitTimeById[id] = time
}
@@ -76,12 +76,21 @@ object LocalMetrics {
val splitDoesNotExist: Boolean = eventsById[id]?.splits?.none { it.name == split } ?: true
if (lastTime != null && splitDoesNotExist) {
val event = eventsById[id]
event?.splits?.add(LocalMetricsSplit(split, time - lastTime, event.timeunit))
event?.splits?.add(LocalMetricsSplit(split, time - lastTime, event.timeUnit))
lastSplitTimeById[id] = time
}
}
}
fun setLabel(id: String, label: String) {
executor.execute {
val event = eventsById[id]
if (event != null) {
eventsById[id] = event.copy(extraLabel = label)
}
}
}
/**
* Marks a split for an event. Updates the last time, so future splits will have duration relative to this event.
*

View File

@@ -154,8 +154,13 @@ public final class SignalLocalMetrics {
split(messageId, SPLIT_JOB_ENQUEUE);
}
public static void onDeliveryStarted(long messageId) {
public static void onDeliveryStarted(long messageId, long sentTimestamp) {
split(messageId, SPLIT_JOB_PRE_NETWORK);
String splitId = ID_MAP.get(messageId);
if (splitId != null) {
LocalMetrics.getInstance().setLabel(splitId, String.valueOf(sentTimestamp));
}
}
public static void onMessageEncrypted(long messageId) {
@@ -337,6 +342,13 @@ public final class SignalLocalMetrics {
split(messageId, SPLIT_JOB_ENQUEUE);
}
public static void setSentTimestamp(long messageId, long sentTimestamp) {
String splitId = ID_MAP.get(messageId);
if (splitId != null) {
LocalMetrics.getInstance().setLabel(splitId, String.valueOf(sentTimestamp));
}
}
public static void onSenderKeyStarted(long messageId) {
split(messageId, SPLIT_JOB_PRE_NETWORK);
}