From ab6941c84e2b5bfe97369761c3eeb2046a9dea65 Mon Sep 17 00:00:00 2001 From: Yuri Shkuro Date: Thu, 2 May 2024 10:55:04 -0400 Subject: [PATCH] [es] Remove unused indexCache Signed-off-by: Yuri Shkuro --- plugin/storage/es/spanstore/writer.go | 22 +++++----------------- plugin/storage/es/spanstore/writer_test.go | 4 ---- 2 files changed, 5 insertions(+), 21 deletions(-) diff --git a/plugin/storage/es/spanstore/writer.go b/plugin/storage/es/spanstore/writer.go index 06470b0ad19..d7d8c211841 100644 --- a/plugin/storage/es/spanstore/writer.go +++ b/plugin/storage/es/spanstore/writer.go @@ -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 @@ -69,7 +69,6 @@ type SpanWriterParams struct { Archive bool UseReadWriteAliases bool ServiceCacheTTL time.Duration - IndexCacheTTL time.Duration } // NewSpanWriter creates a new SpanWriter for use @@ -79,11 +78,6 @@ 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, @@ -91,13 +85,7 @@ func NewSpanWriter(p SpanWriterParams) *SpanWriter { 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), } diff --git a/plugin/storage/es/spanstore/writer_test.go b/plugin/storage/es/spanstore/writer_test.go index b598115aaa9..2d6ad2f812e 100644 --- a/plugin/storage/es/spanstore/writer_test.go +++ b/plugin/storage/es/spanstore/writer_test.go @@ -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, @@ -451,7 +448,6 @@ func TestSpanWriterParamsTTL(t *testing.T) { Logger: logger, MetricsFactory: metricsFactory, ServiceCacheTTL: test.serviceTTL, - IndexCacheTTL: test.indexTTL, } w := NewSpanWriter(params)