From 9b4148d379b9cd134a072f684093d590554ccd86 Mon Sep 17 00:00:00 2001 From: Tory Wheelwright Date: Thu, 4 Apr 2024 10:45:48 -0400 Subject: [PATCH] Add epoch-seconds timestamp to debug logs of oplog entries (#63) When we get an oplog entry, we log it out at debug level. This adds an extra metadata field that prints the server time in seconds since the epoch so that it's easy to see visually how delayed oplog entries are. --- default.nix | 2 +- lib/oplog/tail.go | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/default.nix b/default.nix index dad7ed0c..e5e2f96a 100644 --- a/default.nix +++ b/default.nix @@ -2,7 +2,7 @@ buildGoModule { pname = "oplogtoredis"; - version = "3.3.0"; + version = "3.4.0"; src = builtins.path { path = ./.; }; postInstall = '' diff --git a/lib/oplog/tail.go b/lib/oplog/tail.go index 791abec6..0f62b032 100644 --- a/lib/oplog/tail.go +++ b/lib/oplog/tail.go @@ -340,8 +340,7 @@ func (tailer *Tailer) unmarshalEntry(rawData bson.Raw) (timestamp *primitive.Tim timestamp = &result.Timestamp entries := tailer.parseRawOplogEntry(result, nil) - log.Log.Debugw("Received oplog entry", - "entry", result) + log.Log.Debugw("Received oplog entry", "entry", result, "processTime", time.Now().UnixMilli()) status := "ignored" database := "(no database)"