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

[es] Remove unused indexCache #5408

Merged
merged 1 commit into from
May 2, 2024
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
22 changes: 5 additions & 17 deletions plugin/storage/es/spanstore/writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ type serviceWriter func(string, *dbmodel.Span)

// SpanWriter is a wrapper around elastic.Client
type SpanWriter struct {
client func() es.Client
logger *zap.Logger
writerMetrics spanWriterMetrics // TODO: build functions to wrap around each Do fn
indexCache cache.Cache
client func() es.Client
logger *zap.Logger
writerMetrics spanWriterMetrics // TODO: build functions to wrap around each Do fn
// indexCache cache.Cache
serviceWriter serviceWriter
spanConverter dbmodel.FromDomain
spanServiceIndex spanAndServiceIndexFn
Expand All @@ -69,7 +69,6 @@ type SpanWriterParams struct {
Archive bool
UseReadWriteAliases bool
ServiceCacheTTL time.Duration
IndexCacheTTL time.Duration
}

// NewSpanWriter creates a new SpanWriter for use
Expand All @@ -79,25 +78,14 @@ func NewSpanWriter(p SpanWriterParams) *SpanWriter {
serviceCacheTTL = serviceCacheTTLDefault
}

indexCacheTTL := p.IndexCacheTTL
if p.ServiceCacheTTL == 0 {
indexCacheTTL = indexCacheTTLDefault
}

serviceOperationStorage := NewServiceOperationStorage(p.Client, p.Logger, serviceCacheTTL)
return &SpanWriter{
client: p.Client,
logger: p.Logger,
writerMetrics: spanWriterMetrics{
indexCreate: storageMetrics.NewWriteMetrics(p.MetricsFactory, "index_create"),
},
serviceWriter: serviceOperationStorage.Write,
indexCache: cache.NewLRUWithOptions(
5,
&cache.Options{
TTL: indexCacheTTL,
},
),
serviceWriter: serviceOperationStorage.Write,
spanConverter: dbmodel.NewFromDomain(p.AllTagsAsFields, p.TagKeysAsFields, p.TagDotReplacement),
spanServiceIndex: getSpanAndServiceIndexFn(p.Archive, p.UseReadWriteAliases, p.IndexPrefix, p.SpanIndexDateLayout, p.ServiceIndexDateLayout),
}
Expand Down
4 changes: 0 additions & 4 deletions plugin/storage/es/spanstore/writer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -424,19 +424,16 @@ func TestSpanWriterParamsTTL(t *testing.T) {
logger, _ := testutils.NewLogger()
metricsFactory := metricstest.NewFactory(0)
testCases := []struct {
indexTTL time.Duration
serviceTTL time.Duration
name string
expectedAddCalls int
}{
{
indexTTL: 0,
serviceTTL: 0,
name: "uses defaults",
expectedAddCalls: 1,
},
{
indexTTL: 1 * time.Nanosecond,
serviceTTL: 1 * time.Nanosecond,
name: "uses provided values",
expectedAddCalls: 3,
Expand All @@ -451,7 +448,6 @@ func TestSpanWriterParamsTTL(t *testing.T) {
Logger: logger,
MetricsFactory: metricsFactory,
ServiceCacheTTL: test.serviceTTL,
IndexCacheTTL: test.indexTTL,
}
w := NewSpanWriter(params)

Expand Down
Loading