perf: expose and reduce message publish latency
This commit is contained in:
@@ -66,6 +66,23 @@ func TestDeliveryRecorderCapturesOrderingViolationDetails(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestDeliveryRecorderSeparatesLocalAndCrossMachineLatency(t *testing.T) {
|
||||
recorder := newDeliveryRecorder("run1", "a", 1)
|
||||
local := AcceptedMessage{RunID: "run1", ClientMid: "run1-p-a-0001-01", Topic: "p2p-one", Seq: 1}
|
||||
cross := AcceptedMessage{RunID: "run1", ClientMid: "run1-p-b-0001-01", Topic: "p2p-one", Seq: 2}
|
||||
recorder.onData(AccountRecord{Index: 1}, testData(local, time.Now().Add(-10*time.Millisecond)))
|
||||
recorder.onData(AccountRecord{Index: 1}, testData(cross, time.Now().Add(time.Second)))
|
||||
|
||||
summary := recorder.summarize(AgentSummary{}, nil)
|
||||
if summary.DeliveryLatencyLocal.Count != 1 || summary.DeliveryLatencyCross.Count != 0 {
|
||||
t.Fatalf("unexpected split latency counts: local=%d cross=%d",
|
||||
summary.DeliveryLatencyLocal.Count, summary.DeliveryLatencyCross.Count)
|
||||
}
|
||||
if summary.CrossClockSkewSamples != 1 {
|
||||
t.Fatalf("cross clock skew samples=%d", summary.CrossClockSkewSamples)
|
||||
}
|
||||
}
|
||||
|
||||
func testData(message AcceptedMessage, sentAt time.Time) dataPacket {
|
||||
content, _ := json.Marshal(map[string]any{"run_id": message.RunID, "sent_at_unix_nano": sentAt.UnixNano()})
|
||||
return dataPacket{Topic: message.Topic, Seq: message.Seq,
|
||||
|
||||
Reference in New Issue
Block a user