Brijesh's Git Server — argus_client @ 5455d113f7a8066c37167b49aa9e86d2c917006e

fix: set log timestamp as soon as they are received instead of when the batch is sent
Brijesh Wawdhane ops@brijesh.dev
Sat, 28 Dec 2024 16:39:36 +0530
commit

5455d113f7a8066c37167b49aa9e86d2c917006e

parent

7b93aa77b6802acd952901f91a3cb618ab2a67cd

1 files changed, 7 insertions(+), 5 deletions(-)

jump to
M client.goclient.go

@@ -44,8 +44,9 @@ LevelFatal LogLevel = LogLevel(logs.LogLevel_FATAL)

) type LogEntry struct { - Level LogLevel - Message string + Level LogLevel + Message string + Timestamp string } func (c *Client) SendLogs(entries []LogEntry) error {

@@ -62,7 +63,7 @@

for i, entry := range entries { pbLogs[i] = &logs.LogEntry{ LogId: uuid.New().String(), - Timestamp: time.Now().Format(time.RFC3339), + Timestamp: entry.Timestamp, Level: logs.LogLevel(entry.Level), Message: entry.Message, }

@@ -136,8 +137,9 @@ slog.LevelError: LevelError,

}[record.Level] entry := LogEntry{ - Level: level, - Message: record.Message, + Level: level, + Message: record.Message, + Timestamp: time.Now().Format(time.RFC3339), } h.bufferMutex.Lock()