Skip to content

Commit

Permalink
feat: Use prefixed WAL storage path in Object Storage
Browse files Browse the repository at this point in the history
  • Loading branch information
benclive committed Jul 2, 2024
1 parent 64306a0 commit 1584e49
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion pkg/storage/chunk/client/object_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@ import (
"context"
"encoding/base64"
"io"
"math/rand"
"strings"
"time"

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

"github.com/grafana/loki/v3/pkg/storage/chunk"
Expand Down Expand Up @@ -85,6 +87,7 @@ type client struct {
keyEncoder KeyEncoder
getChunkMaxParallel int
schema config.SchemaConfig
entropy io.Reader
}

// NewClient wraps the provided ObjectClient with a chunk.Client implementation
Expand All @@ -98,6 +101,7 @@ func NewClientWithMaxParallel(store ObjectClient, encoder KeyEncoder, maxParalle
keyEncoder: encoder,
getChunkMaxParallel: maxParallel,
schema: schema,
entropy: rand.New(rand.NewSource(time.Now().UnixNano())),
}
}

Expand All @@ -112,7 +116,8 @@ func (o *client) PutWal(ctx context.Context, segment *wal.SegmentWriter) error {
if err != nil {
return err
}
return o.store.PutObject(ctx, "wal-segment-"+time.Now().UTC().Format(time.RFC3339Nano), bytes.NewReader(buffer.Bytes()))
newUlid := ulid.MustNew(ulid.Timestamp(time.Now()), o.entropy)
return o.store.PutObject(ctx, "loki-v2/wal/anon/"+newUlid.String(), bytes.NewReader(buffer.Bytes()))
}

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

0 comments on commit 1584e49

Please sign in to comment.