Skip to content

Commit

Permalink
feat: Use prefixed WAL storage path in Object Storage (#13377)
Browse files Browse the repository at this point in the history
  • Loading branch information
benclive committed Jul 3, 2024
1 parent 33bd390 commit 973aa2d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ require (
github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f
github.com/ncw/swift v1.0.53
github.com/oklog/run v1.1.0
github.com/oklog/ulid v1.3.1 // indirect
github.com/oklog/ulid v1.3.1
github.com/opentracing-contrib/go-grpc v0.0.0-20210225150812-73cb765af46e
github.com/opentracing-contrib/go-stdlib v1.0.0
github.com/opentracing/opentracing-go v1.2.0
Expand Down
6 changes: 5 additions & 1 deletion pkg/storage/chunk/client/object_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ package client
import (
"bytes"
"context"
"crypto/rand"
"encoding/base64"
"io"
"strings"
"time"

"github.com/oklog/ulid"
"github.com/pkg/errors"

"github.com/grafana/loki/v3/pkg/storage/chunk"
Expand Down Expand Up @@ -114,7 +116,9 @@ func (o *client) PutWal(ctx context.Context, segment *wal.SegmentWriter) error {
defer func(reader io.ReadSeekCloser) {
_ = reader.Close()
}(reader)
return o.store.PutObject(ctx, "wal-segment-"+time.Now().UTC().Format(time.RFC3339Nano), reader)

newUlid := ulid.MustNew(ulid.Timestamp(time.Now()), rand.Reader)
return o.store.PutObject(ctx, "loki-v2/wal/anon/"+newUlid.String(), reader)
}

// PutChunks stores the provided chunks in the configured backend. If multiple errors are
Expand Down

0 comments on commit 973aa2d

Please sign in to comment.