Skip to content

Commit

Permalink
Utilize UUID v7 for log lines/files, as well as snapshot IDs (#576)
Browse files Browse the repository at this point in the history
The server side already overwrites assigned log line/file IDs with ULIDs,
so this does not make any practical difference for them.

Collector provided snapshot IDs are currently mainly intended for
debugging purposes (the server-side assigns its own ID), but it seems
reasonable to use a more index-friendly ID here as well.
  • Loading branch information
lfittl authored Jul 19, 2024
1 parent dbcdd55 commit db03b27
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion logs/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -620,7 +620,7 @@ func ParseAndAnalyzeBuffer(logStream LineReader, linesNewerThan time.Time, serve
logLine.ByteEnd = byteStart + int64(len(line))

// Generate unique ID that can be used to reference this line
logLine.UUID, err = uuid.NewRandom()
logLine.UUID, err = uuid.NewV7()
if err != nil {
fmt.Printf("Failed to generate log line UUID: %s", err)
continue
Expand Down
2 changes: 1 addition & 1 deletion output/compact.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func uploadAndSubmitCompactSnapshot(ctx context.Context, s pganalyze_collector.C
var err error
var data []byte

snapshotUUID, err := uuid.NewRandom()
snapshotUUID, err := uuid.NewV7()
if err != nil {
logger.PrintError("Error generating snapshot UUID: %s", err)
return err
Expand Down
2 changes: 1 addition & 1 deletion output/full.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func submitFull(ctx context.Context, s snapshot.FullSnapshot, server *state.Serv
var err error
var data []byte

snapshotUUID, err := uuid.NewRandom()
snapshotUUID, err := uuid.NewV7()
if err != nil {
logger.PrintError("Error generating snapshot UUID: %s", err)
return err
Expand Down
2 changes: 1 addition & 1 deletion runner/logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ func setupLogStreamer(ctx context.Context, wg *sync.WaitGroup, globalCollectionO
}

in.LogLine.CollectedAt = time.Now()
in.LogLine.UUID, err = uuid.NewRandom()
in.LogLine.UUID, err = uuid.NewV7()
if err != nil {
logger.PrintError("Could not generate log line UUID: %s", err)
continue
Expand Down
2 changes: 1 addition & 1 deletion state/logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ func NewLogFile(tmpFile *os.File, originalName string) (LogFile, error) {
return LogFile{}, fmt.Errorf("error allocating tempfile for logs: %s", err)
}
}
uuid, err := uuid.NewRandom()
uuid, err := uuid.NewV7()
if err != nil {
return LogFile{}, fmt.Errorf("error generating log file UUID: %s", err)
}
Expand Down

0 comments on commit db03b27

Please sign in to comment.