fix(backend-ender): use local machine timestamp for comparison

This commit is contained in:
ShiKhu 2021-12-29 16:49:58 +01:00
parent acee296e0a
commit dafabe4672

View file

@ -3,6 +3,7 @@ package builder
import (
"net/url"
"strings"
"time"
"openreplay/backend/pkg/intervals"
. "openreplay/backend/pkg/messages"
@ -42,6 +43,7 @@ func getResourceType(initiator string, URL string) string {
type builder struct {
readyMsgs []Message
timestamp uint64
lastProcessedTimestamp int64
peBuilder *pageEventBuilder
ptaBuilder *performanceTrackAggrBuilder
ieBuilder *inputEventBuilder
@ -112,6 +114,10 @@ func (b *builder) handleMessage(message Message, messageID uint64) {
if b.timestamp <= timestamp { // unnecessary? TODO: test and remove
b.timestamp = timestamp
}
b.lastProcessedTimestamp = time.Now().UnixNano()/1e6
// Might happen before the first timestamp.
switch msg := message.(type) {
case *SessionStart,
@ -293,7 +299,7 @@ func (b *builder) checkTimeouts(ts int64) bool {
b.buildPerformanceTrackAggr()
}
lastTsGap := ts - int64(b.timestamp)
lastTsGap := ts - b.lastProcessedTimestamp
//log.Printf("checking timeouts for sess %v: %v now, %v sesstime; gap %v",b.sid, ts, b.timestamp, lastTsGap)
if lastTsGap > intervals.EVENTS_SESSION_END_TIMEOUT {
if rm := b.ddDetector.Build(); rm != nil {