Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(deps): update module github.com/hashicorp/golang-lru to v2 #14979

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions clients/pkg/logentry/stages/timestamp.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (

"github.com/go-kit/log"
"github.com/go-kit/log/level"
lru "github.com/hashicorp/golang-lru"
lru "github.com/hashicorp/golang-lru/v2"
"github.com/mitchellh/mapstructure"
"github.com/prometheus/common/model"

Expand Down Expand Up @@ -114,9 +114,9 @@ func newTimestampStage(logger log.Logger, config interface{}) (Stage, error) {
return nil, err
}

var lastKnownTimestamps *lru.Cache
var lastKnownTimestamps *lru.Cache[string, time.Time]
if *cfg.ActionOnFailure == TimestampActionOnFailureFudge {
lastKnownTimestamps, err = lru.New(maxLastKnownTimestampsCacheSize)
lastKnownTimestamps, err = lru.New[string, time.Time](maxLastKnownTimestampsCacheSize)
if err != nil {
return nil, err
}
Expand All @@ -138,7 +138,7 @@ type timestampStage struct {

// Stores the last known timestamp for a given "stream id" (guessed, since at this stage
// there's no reliable way to know it).
lastKnownTimestamps *lru.Cache
lastKnownTimestamps *lru.Cache[string, time.Time]
}

// Name implements Stage
Expand Down Expand Up @@ -222,7 +222,7 @@ func (ts *timestampStage) processActionOnFailureFudge(labels model.LabelSet, t *
}

// Fudge the timestamp
*t = lastTimestamp.(time.Time).Add(1 * time.Nanosecond)
*t = lastTimestamp.Add(1 * time.Nanosecond)

// Store the fudged timestamp, so that a subsequent fudged timestamp will be 1ns after it
ts.lastKnownTimestamps.Add(labelsStr, *t)
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ require (
github.com/grpc-ecosystem/go-grpc-middleware v1.4.0
github.com/grpc-ecosystem/grpc-opentracing v0.0.0-20180507213350-8e809c8a8645
github.com/hashicorp/consul/api v1.30.0
github.com/hashicorp/golang-lru v0.6.0
github.com/hashicorp/golang-lru/v2 v2.0.7
github.com/imdario/mergo v0.3.16
github.com/influxdata/telegraf v1.16.3
github.com/jmespath/go-jmespath v0.4.0
Expand Down Expand Up @@ -126,7 +126,6 @@ require (
github.com/gogo/googleapis v1.4.1
github.com/grafana/jsonparser v0.0.0-20241004153430-023329977675
github.com/grafana/loki/pkg/push v0.0.0-20240924133635-758364c7775f
github.com/hashicorp/golang-lru/v2 v2.0.7
github.com/heroku/x v0.4.0
github.com/influxdata/tdigest v0.0.2-0.20210216194612-fc98d27c9e8b
github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db
Expand Down Expand Up @@ -173,6 +172,7 @@ require (
github.com/go-ole/go-ole v1.2.6 // indirect
github.com/goccy/go-json v0.10.3 // indirect
github.com/gorilla/handlers v1.5.2 // indirect
github.com/hashicorp/golang-lru v0.6.0 // indirect
github.com/lufia/plan9stats v0.0.0-20220913051719-115f729f3c8c // indirect
github.com/moby/docker-image-spec v1.3.1 // indirect
github.com/moby/sys/userns v0.1.0 // indirect
Expand Down
9 changes: 4 additions & 5 deletions pkg/distributor/distributor.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import (
"github.com/grafana/dskit/services"
"github.com/grafana/dskit/tenant"
"github.com/grafana/dskit/user"
lru "github.com/hashicorp/golang-lru"
lru "github.com/hashicorp/golang-lru/v2"
"github.com/opentracing/opentracing-go"
"github.com/pkg/errors"
"github.com/prometheus/client_golang/prometheus"
Expand Down Expand Up @@ -148,7 +148,7 @@ type Distributor struct {
subservicesWatcher *services.FailureWatcher
// Per-user rate limiter.
ingestionRateLimiter *limiter.RateLimiter
labelCache *lru.Cache
labelCache *lru.Cache[string, labelData]

// Push failures rate limiter.
writeFailuresManager *writefailures.Manager
Expand Down Expand Up @@ -217,7 +217,7 @@ func New(
var servs []services.Service

rateLimitStrat := validation.LocalIngestionRateStrategy
labelCache, err := lru.New(maxLabelCacheSize)
labelCache, err := lru.New[string, labelData](maxLabelCacheSize)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -1086,8 +1086,7 @@ type labelData struct {

func (d *Distributor) parseStreamLabels(vContext validationContext, key string, stream logproto.Stream) (labels.Labels, string, uint64, error) {
if val, ok := d.labelCache.Get(key); ok {
labelVal := val.(labelData)
return labelVal.ls, labelVal.ls.String(), labelVal.hash, nil
return val.ls, val.ls.String(), val.hash, nil
}

ls, err := syntax.ParseLabels(key)
Expand Down
8 changes: 4 additions & 4 deletions pkg/kafka/encoding.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (

"github.com/twmb/franz-go/pkg/kgo"

lru "github.com/hashicorp/golang-lru"
lru "github.com/hashicorp/golang-lru/v2"
"github.com/prometheus/prometheus/model/labels"

"github.com/grafana/loki/v3/pkg/logproto"
Expand Down Expand Up @@ -126,11 +126,11 @@ func marshalWriteRequestToRecord(partitionID int32, tenantID string, stream logp
// It caches parsed labels for efficiency.
type Decoder struct {
stream *logproto.Stream
cache *lru.Cache
cache *lru.Cache[string, labels.Labels]
}

func NewDecoder() (*Decoder, error) {
cache, err := lru.New(5000) // Set LRU size to 5000, adjust as needed
cache, err := lru.New[string, labels.Labels](5000)
if err != nil {
return nil, fmt.Errorf("failed to create LRU cache: %w", err)
}
Expand All @@ -154,7 +154,7 @@ func (d *Decoder) Decode(data []byte) (logproto.Stream, labels.Labels, error) {

var ls labels.Labels
if cachedLabels, ok := d.cache.Get(d.stream.Labels); ok {
ls = cachedLabels.(labels.Labels)
ls = cachedLabels
} else {
var err error
ls, err = syntax.ParseLabels(d.stream.Labels)
Expand Down
30 changes: 0 additions & 30 deletions vendor/github.com/hashicorp/golang-lru/.golangci.yml

This file was deleted.

25 changes: 0 additions & 25 deletions vendor/github.com/hashicorp/golang-lru/README.md

This file was deleted.

Loading
Loading