From 083dff310f8027b668b74781ab25ca7dbf05c996 Mon Sep 17 00:00:00 2001 From: Droxenator <125274321+Droxenator@users.noreply.github.com> Date: Mon, 13 Feb 2023 18:07:53 +0300 Subject: [PATCH] fixed opentsdbListenAddr timestamp conversion (#3810) Co-authored-by: Andrei Ivanov --- lib/protoparser/opentsdb/streamparser.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/protoparser/opentsdb/streamparser.go b/lib/protoparser/opentsdb/streamparser.go index 94e7fc5b8..5fa6df76b 100644 --- a/lib/protoparser/opentsdb/streamparser.go +++ b/lib/protoparser/opentsdb/streamparser.go @@ -168,9 +168,13 @@ func (uw *unmarshalWork) Unmarshal() { } } - // Convert timestamps from seconds to milliseconds + // Convert timestamps in seconds to milliseconds if needed. + // See http://opentsdb.net/docs/javadoc/net/opentsdb/core/Const.html#SECOND_MASK for i := range rows { - rows[i].Timestamp *= 1e3 + r := &rows[i] + if r.Timestamp&secondMask == 0 { + r.Timestamp *= 1e3 + } } // Trim timestamps if required. @@ -185,6 +189,8 @@ func (uw *unmarshalWork) Unmarshal() { putUnmarshalWork(uw) } +const secondMask int64 = 0x7FFFFFFF00000000 + func getUnmarshalWork() *unmarshalWork { v := unmarshalWorkPool.Get() if v == nil {