From 42dc476033de10f28192471635bead3c7ae49d50 Mon Sep 17 00:00:00 2001 From: Joachim Bauch Date: Wed, 3 Nov 2021 14:56:25 +0100 Subject: [PATCH] Only log RTT of connections to proxy if larger than 500ms. --- mcu_proxy.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/mcu_proxy.go b/mcu_proxy.go index b496e96..95dd074 100644 --- a/mcu_proxy.go +++ b/mcu_proxy.go @@ -66,6 +66,8 @@ const ( maxWaitDelay = 8 * time.Second defaultProxyTimeoutSeconds = 2 + + rttLogDuration = 500 * time.Millisecond ) type mcuProxyPubSubCommon struct { @@ -385,8 +387,10 @@ func (c *mcuProxyConnection) readPump() { } if ts, err := strconv.ParseInt(msg, 10, 64); err == nil { rtt := now.Sub(time.Unix(0, ts)) - rtt_ms := rtt.Nanoseconds() / time.Millisecond.Nanoseconds() - log.Printf("Proxy at %s has RTT of %d ms (%s)", c.url, rtt_ms, rtt) + if rtt >= rttLogDuration { + rtt_ms := rtt.Nanoseconds() / time.Millisecond.Nanoseconds() + log.Printf("Proxy at %s has RTT of %d ms (%s)", c.url, rtt_ms, rtt) + } } return nil })