From c678a64c9ddaf2f59166a4ba5d93eb954244ebdf Mon Sep 17 00:00:00 2001 From: Mahad Zaryab <43658574+mahadzaryab1@users.noreply.github.com> Date: Mon, 13 Jan 2025 21:35:17 -0500 Subject: [PATCH] [storage] Remove dependency on archive flag in ES reader (#6490) --- plugin/storage/es/factory.go | 30 ++++-- plugin/storage/es/factory_test.go | 41 +++++--- plugin/storage/es/spanstore/index_utils.go | 5 - plugin/storage/es/spanstore/reader.go | 64 +++++------- plugin/storage/es/spanstore/reader_test.go | 115 +++++++++------------ plugin/storage/es/spanstore/writer.go | 28 ++--- plugin/storage/es/spanstore/writer_test.go | 23 +++-- 7 files changed, 151 insertions(+), 155 deletions(-) diff --git a/plugin/storage/es/factory.go b/plugin/storage/es/factory.go index 63ada037544..e1c7ae807a4 100644 --- a/plugin/storage/es/factory.go +++ b/plugin/storage/es/factory.go @@ -182,7 +182,7 @@ func (f *Factory) getArchiveClient() es.Client { // CreateSpanReader implements storage.Factory func (f *Factory) CreateSpanReader() (spanstore.Reader, error) { - sr, err := createSpanReader(f.getPrimaryClient, f.primaryConfig, false, f.logger, f.tracer) + sr, err := createSpanReader(f.getPrimaryClient, f.primaryConfig, f.logger, f.tracer, "", f.primaryConfig.UseReadWriteAliases) if err != nil { return nil, err } @@ -191,7 +191,7 @@ func (f *Factory) CreateSpanReader() (spanstore.Reader, error) { // CreateSpanWriter implements storage.Factory func (f *Factory) CreateSpanWriter() (spanstore.Writer, error) { - return createSpanWriter(f.getPrimaryClient, f.primaryConfig, false, f.metricsFactory, f.logger) + return createSpanWriter(f.getPrimaryClient, f.primaryConfig, f.metricsFactory, f.logger, "", f.primaryConfig.UseReadWriteAliases) } // CreateDependencyReader implements storage.Factory @@ -204,7 +204,11 @@ func (f *Factory) CreateArchiveSpanReader() (spanstore.Reader, error) { if !f.archiveConfig.Enabled { return nil, nil } - sr, err := createSpanReader(f.getArchiveClient, f.archiveConfig, true, f.logger, f.tracer) + readAliasSuffix := "archive" + if f.archiveConfig.UseReadWriteAliases { + readAliasSuffix += "-read" + } + sr, err := createSpanReader(f.getArchiveClient, f.archiveConfig, f.logger, f.tracer, readAliasSuffix, true) if err != nil { return nil, err } @@ -223,6 +227,10 @@ func (f *Factory) CreateArchiveSpanWriter() (spanstore.Writer, error) { if !f.archiveConfig.Enabled { return nil, nil } + writeAliasSuffix := "archive" + if f.archiveConfig.UseReadWriteAliases { + writeAliasSuffix += "-write" + } archiveMetricsFactory := f.metricsFactory.Namespace( metrics.NSOptions{ Tags: map[string]string{ @@ -230,15 +238,16 @@ func (f *Factory) CreateArchiveSpanWriter() (spanstore.Writer, error) { }, }, ) - return createSpanWriter(f.getArchiveClient, f.archiveConfig, true, archiveMetricsFactory, f.logger) + return createSpanWriter(f.getArchiveClient, f.archiveConfig, archiveMetricsFactory, f.logger, writeAliasSuffix, true) } func createSpanReader( clientFn func() es.Client, cfg *config.Configuration, - archive bool, logger *zap.Logger, tp trace.TracerProvider, + readAliasSuffix string, + useReadWriteAliases bool, ) (spanstore.Reader, error) { if cfg.UseILM && !cfg.UseReadWriteAliases { return nil, errors.New("--es.use-ilm must always be used in conjunction with --es.use-aliases to ensure ES writers and readers refer to the single index mapping") @@ -251,8 +260,8 @@ func createSpanReader( SpanIndex: cfg.Indices.Spans, ServiceIndex: cfg.Indices.Services, TagDotReplacement: cfg.Tags.DotReplacement, - UseReadWriteAliases: cfg.UseReadWriteAliases, - Archive: archive, + UseReadWriteAliases: useReadWriteAliases, + ReadAliasSuffix: readAliasSuffix, RemoteReadClusters: cfg.RemoteReadClusters, Logger: logger, Tracer: tp.Tracer("esSpanStore.SpanReader"), @@ -262,9 +271,10 @@ func createSpanReader( func createSpanWriter( clientFn func() es.Client, cfg *config.Configuration, - archive bool, mFactory metrics.Factory, logger *zap.Logger, + writeAliasSuffix string, + useReadWriteAliases bool, ) (spanstore.Writer, error) { var tags []string var err error @@ -284,8 +294,8 @@ func createSpanWriter( AllTagsAsFields: cfg.Tags.AllAsFields, TagKeysAsFields: tags, TagDotReplacement: cfg.Tags.DotReplacement, - Archive: archive, - UseReadWriteAliases: cfg.UseReadWriteAliases, + UseReadWriteAliases: useReadWriteAliases, + WriteAliasSuffix: writeAliasSuffix, Logger: logger, MetricsFactory: mFactory, ServiceCacheTTL: cfg.ServiceCacheTTL, diff --git a/plugin/storage/es/factory_test.go b/plugin/storage/es/factory_test.go index 7a3412f8e56..7dcd103ebf1 100644 --- a/plugin/storage/es/factory_test.go +++ b/plugin/storage/es/factory_test.go @@ -8,6 +8,7 @@ import ( "context" "encoding/base64" "errors" + "fmt" "net/http" "net/http/httptest" "os" @@ -243,19 +244,33 @@ func TestArchiveDisabled(t *testing.T) { } func TestArchiveEnabled(t *testing.T) { - f := NewFactory() - f.primaryConfig = &escfg.Configuration{} - f.archiveConfig = &escfg.Configuration{Enabled: true} - f.newClientFn = (&mockClientBuilder{}).NewClient - err := f.Initialize(metrics.NullFactory, zap.NewNop()) - require.NoError(t, err) - defer f.Close() // Ensure resources are cleaned up if initialization is successful - w, err := f.CreateArchiveSpanWriter() - require.NoError(t, err) - assert.NotNil(t, w) - r, err := f.CreateArchiveSpanReader() - require.NoError(t, err) - assert.NotNil(t, r) + tests := []struct { + useReadWriteAliases bool + }{ + { + useReadWriteAliases: false, + }, + { + useReadWriteAliases: true, + }, + } + for _, test := range tests { + t.Run(fmt.Sprintf("useReadWriteAliases=%v", test.useReadWriteAliases), func(t *testing.T) { + f := NewFactory() + f.primaryConfig = &escfg.Configuration{} + f.archiveConfig = &escfg.Configuration{Enabled: true, UseReadWriteAliases: test.useReadWriteAliases} + f.newClientFn = (&mockClientBuilder{}).NewClient + err := f.Initialize(metrics.NullFactory, zap.NewNop()) + require.NoError(t, err) + defer f.Close() // Ensure resources are cleaned up if initialization is successful + w, err := f.CreateArchiveSpanWriter() + require.NoError(t, err) + assert.NotNil(t, w) + r, err := f.CreateArchiveSpanReader() + require.NoError(t, err) + assert.NotNil(t, r) + }) + } } func TestConfigureFromOptions(t *testing.T) { diff --git a/plugin/storage/es/spanstore/index_utils.go b/plugin/storage/es/spanstore/index_utils.go index 685df4b6e98..40a3e771545 100644 --- a/plugin/storage/es/spanstore/index_utils.go +++ b/plugin/storage/es/spanstore/index_utils.go @@ -12,8 +12,3 @@ func indexWithDate(indexPrefix, indexDateLayout string, date time.Time) string { spanDate := date.UTC().Format(indexDateLayout) return indexPrefix + spanDate } - -// returns archive index name -func archiveIndex(indexPrefix, archiveSuffix string) string { - return indexPrefix + archiveSuffix -} diff --git a/plugin/storage/es/spanstore/reader.go b/plugin/storage/es/spanstore/reader.go index d6876148faf..454726a1039 100644 --- a/plugin/storage/es/spanstore/reader.go +++ b/plugin/storage/es/spanstore/reader.go @@ -27,13 +27,10 @@ import ( ) const ( - spanIndexBaseName = "jaeger-span-" - serviceIndexBaseName = "jaeger-service-" - archiveIndexSuffix = "archive" - archiveReadIndexSuffix = archiveIndexSuffix + "-read" - archiveWriteIndexSuffix = archiveIndexSuffix + "-write" - traceIDAggregation = "traceIDs" - indexPrefixSeparator = "-" + spanIndexBaseName = "jaeger-span-" + serviceIndexBaseName = "jaeger-service-" + traceIDAggregation = "traceIDs" + indexPrefixSeparator = "-" traceIDField = "traceID" durationField = "duration" @@ -51,7 +48,7 @@ const ( defaultNumTraces = 100 - rolloverMaxSpanAge = time.Hour * 24 * 365 * 50 + dawnOfTimeSpanAge = time.Hour * 24 * 365 * 50 ) var ( @@ -109,7 +106,7 @@ type SpanReaderParams struct { SpanIndex cfg.IndexOptions ServiceIndex cfg.IndexOptions TagDotReplacement string - Archive bool + ReadAliasSuffix string UseReadWriteAliases bool RemoteReadClusters []string Logger *zap.Logger @@ -119,10 +116,16 @@ type SpanReaderParams struct { // NewSpanReader returns a new SpanReader with a metrics. func NewSpanReader(p SpanReaderParams) *SpanReader { maxSpanAge := p.MaxSpanAge + readAliasSuffix := "" // Setting the maxSpanAge to a large duration will ensure all spans in the "read" alias are accessible by queries (query window = [now - maxSpanAge, now]). // When read/write aliases are enabled, which are required for index rollovers, only the "read" alias is queried and therefore should not affect performance. if p.UseReadWriteAliases { - maxSpanAge = rolloverMaxSpanAge + maxSpanAge = dawnOfTimeSpanAge + if p.ReadAliasSuffix != "" { + readAliasSuffix = p.ReadAliasSuffix + } else { + readAliasSuffix = "read" + } } return &SpanReader{ @@ -136,9 +139,12 @@ func NewSpanReader(p SpanReaderParams) *SpanReader { spanConverter: dbmodel.NewToDomain(p.TagDotReplacement), timeRangeIndices: getLoggingTimeRangeIndexFn( p.Logger, - getTimeRangeIndexFn(p.Archive, p.UseReadWriteAliases, p.RemoteReadClusters), + addRemoteReadClusters( + getTimeRangeIndexFn(p.UseReadWriteAliases, readAliasSuffix), + p.RemoteReadClusters, + ), ), - sourceFn: getSourceFn(p.Archive, p.MaxDocCount), + sourceFn: getSourceFn(p.MaxDocCount), maxDocCount: p.MaxDocCount, useReadWriteAliases: p.UseReadWriteAliases, logger: p.Logger, @@ -161,24 +167,13 @@ func getLoggingTimeRangeIndexFn(logger *zap.Logger, fn timeRangeIndexFn) timeRan } } -func getTimeRangeIndexFn(archive, useReadWriteAliases bool, remoteReadClusters []string) timeRangeIndexFn { - if archive { - var archiveSuffix string - if useReadWriteAliases { - archiveSuffix = archiveReadIndexSuffix - } else { - archiveSuffix = archiveIndexSuffix - } - return addRemoteReadClusters(func(indexPrefix, _ /* indexDateLayout */ string, _ /* startTime */ time.Time, _ /* endTime */ time.Time, _ /* reduceDuration */ time.Duration) []string { - return []string{archiveIndex(indexPrefix, archiveSuffix)} - }, remoteReadClusters) - } +func getTimeRangeIndexFn(useReadWriteAliases bool, readAlias string) timeRangeIndexFn { if useReadWriteAliases { - return addRemoteReadClusters(func(indexPrefix string, _ /* indexDateLayout */ string, _ /* startTime */ time.Time, _ /* endTime */ time.Time, _ /* reduceDuration */ time.Duration) []string { - return []string{indexPrefix + "read"} - }, remoteReadClusters) + return func(indexPrefix, _ /* indexDateLayout */ string, _ /* startTime */ time.Time, _ /* endTime */ time.Time, _ /* reduceDuration */ time.Duration) []string { + return []string{indexPrefix + readAlias} + } } - return addRemoteReadClusters(timeRangeIndices, remoteReadClusters) + return timeRangeIndices } // Add a remote cluster prefix for each cluster and for each index and add it to the list of original indices. @@ -201,16 +196,13 @@ func addRemoteReadClusters(fn timeRangeIndexFn, remoteReadClusters []string) tim } } -func getSourceFn(archive bool, maxDocCount int) sourceFn { +func getSourceFn(maxDocCount int) sourceFn { return func(query elastic.Query, nextTime uint64) *elastic.SearchSource { - s := elastic.NewSearchSource(). + return elastic.NewSearchSource(). Query(query). - Size(maxDocCount) - if !archive { - s.Sort("startTime", true). - SearchAfter(nextTime) - } - return s + Size(maxDocCount). + Sort("startTime", true). + SearchAfter(nextTime) } } diff --git a/plugin/storage/es/spanstore/reader_test.go b/plugin/storage/es/spanstore/reader_test.go index 617d11194bf..9aa184e7aa9 100644 --- a/plugin/storage/es/spanstore/reader_test.go +++ b/plugin/storage/es/spanstore/reader_test.go @@ -118,7 +118,7 @@ func withSpanReader(t *testing.T, fn func(r *spanReaderTest)) { fn(r) } -func withArchiveSpanReader(t *testing.T, readAlias bool, fn func(r *spanReaderTest)) { +func withArchiveSpanReader(t *testing.T, readAlias bool, readAliasSuffix string, fn func(r *spanReaderTest)) { client := &mocks.Client{} tracer, exp, closer := tracerProvider(t) defer closer() @@ -134,7 +134,7 @@ func withArchiveSpanReader(t *testing.T, readAlias bool, fn func(r *spanReaderTe Tracer: tracer.Tracer("test"), MaxSpanAge: 0, TagDotReplacement: "@", - Archive: true, + ReadAliasSuffix: readAliasSuffix, UseReadWriteAliases: readAlias, }), } @@ -199,7 +199,6 @@ func TestSpanReaderIndices(t *testing.T) { }{ { params: SpanReaderParams{ - Archive: false, SpanIndex: spanIndexOpts, ServiceIndex: serviceIndexOpts, }, @@ -213,7 +212,12 @@ func TestSpanReaderIndices(t *testing.T) { }, { params: SpanReaderParams{ - Archive: false, + ReadAliasSuffix: "archive", // ignored because ReadWriteAliases is false + }, + indices: []string{spanIndexBaseName, serviceIndexBaseName}, + }, + { + params: SpanReaderParams{ SpanIndex: spanIndexOpts, ServiceIndex: serviceIndexOpts, IndexPrefix: "foo:", @@ -228,27 +232,21 @@ func TestSpanReaderIndices(t *testing.T) { }, { params: SpanReaderParams{ - Archive: true, - }, - indices: []string{spanIndexBaseName + archiveIndexSuffix, serviceIndexBaseName + archiveIndexSuffix}, - }, - { - params: SpanReaderParams{ - SpanIndex: spanIndexOpts, ServiceIndex: serviceIndexOpts, IndexPrefix: "foo:", Archive: true, + ReadAliasSuffix: "archive", + UseReadWriteAliases: true, }, - indices: []string{"foo:" + config.IndexPrefixSeparator + spanIndexBaseName + archiveIndexSuffix, "foo:" + config.IndexPrefixSeparator + serviceIndexBaseName + archiveIndexSuffix}, + indices: []string{spanIndexBaseName + "archive", serviceIndexBaseName + "archive"}, }, { params: SpanReaderParams{ - SpanIndex: spanIndexOpts, ServiceIndex: serviceIndexOpts, IndexPrefix: "foo:", Archive: true, UseReadWriteAliases: true, + SpanIndex: spanIndexOpts, ServiceIndex: serviceIndexOpts, IndexPrefix: "foo:", UseReadWriteAliases: true, ReadAliasSuffix: "archive", }, - indices: []string{"foo:" + config.IndexPrefixSeparator + spanIndexBaseName + archiveReadIndexSuffix, "foo:" + config.IndexPrefixSeparator + serviceIndexBaseName + archiveReadIndexSuffix}, + indices: []string{"foo:" + config.IndexPrefixSeparator + spanIndexBaseName + "archive", "foo:" + config.IndexPrefixSeparator + serviceIndexBaseName + "archive"}, }, { params: SpanReaderParams{ SpanIndex: spanIndexOpts, ServiceIndex: serviceIndexOpts, - Archive: false, RemoteReadClusters: []string{"cluster_one", "cluster_two"}, }, indices: []string{ @@ -262,20 +260,20 @@ func TestSpanReaderIndices(t *testing.T) { }, { params: SpanReaderParams{ - Archive: true, RemoteReadClusters: []string{"cluster_one", "cluster_two"}, + UseReadWriteAliases: true, ReadAliasSuffix: "archive", RemoteReadClusters: []string{"cluster_one", "cluster_two"}, }, indices: []string{ - spanIndexBaseName + archiveIndexSuffix, - "cluster_one:" + spanIndexBaseName + archiveIndexSuffix, - "cluster_two:" + spanIndexBaseName + archiveIndexSuffix, - serviceIndexBaseName + archiveIndexSuffix, - "cluster_one:" + serviceIndexBaseName + archiveIndexSuffix, - "cluster_two:" + serviceIndexBaseName + archiveIndexSuffix, + spanIndexBaseName + "archive", + "cluster_one:" + spanIndexBaseName + "archive", + "cluster_two:" + spanIndexBaseName + "archive", + serviceIndexBaseName + "archive", + "cluster_one:" + serviceIndexBaseName + "archive", + "cluster_two:" + serviceIndexBaseName + "archive", }, }, { params: SpanReaderParams{ - Archive: false, UseReadWriteAliases: true, RemoteReadClusters: []string{"cluster_one", "cluster_two"}, + UseReadWriteAliases: true, RemoteReadClusters: []string{"cluster_one", "cluster_two"}, }, indices: []string{ spanIndexBaseName + "read", @@ -286,19 +284,6 @@ func TestSpanReaderIndices(t *testing.T) { "cluster_two:" + serviceIndexBaseName + "read", }, }, - { - params: SpanReaderParams{ - Archive: true, UseReadWriteAliases: true, RemoteReadClusters: []string{"cluster_one", "cluster_two"}, - }, - indices: []string{ - spanIndexBaseName + archiveReadIndexSuffix, - "cluster_one:" + spanIndexBaseName + archiveReadIndexSuffix, - "cluster_two:" + spanIndexBaseName + archiveReadIndexSuffix, - serviceIndexBaseName + archiveReadIndexSuffix, - "cluster_one:" + serviceIndexBaseName + archiveReadIndexSuffix, - "cluster_two:" + serviceIndexBaseName + archiveReadIndexSuffix, - }, - }, } for _, testCase := range testCases { testCase.params.Client = clientFn @@ -1267,36 +1252,34 @@ func TestSpanReader_GetEmptyIndex(t *testing.T) { } func TestSpanReader_ArchiveTraces(t *testing.T) { - withArchiveSpanReader(t, false, func(r *spanReaderTest) { - mockSearchService(r). - Return(&elastic.SearchResult{}, nil) - mockArchiveMultiSearchService(r, "jaeger-span-archive"). - Return(&elastic.MultiSearchResult{ - Responses: []*elastic.SearchResult{}, - }, nil) - query := spanstore.GetTraceParameters{} - trace, err := r.reader.GetTrace(context.Background(), query) - require.NotEmpty(t, r.traceBuffer.GetSpans(), "Spans recorded") - require.Nil(t, trace) - require.EqualError(t, err, "trace not found") - }) -} - -func TestSpanReader_ArchiveTraces_ReadAlias(t *testing.T) { - withArchiveSpanReader(t, true, func(r *spanReaderTest) { - mockSearchService(r). - Return(&elastic.SearchResult{}, nil) - mockArchiveMultiSearchService(r, "jaeger-span-archive-read"). - Return(&elastic.MultiSearchResult{ - Responses: []*elastic.SearchResult{}, - }, nil) + testCases := []struct { + useAliases bool + suffix string + expected string + }{ + {false, "", "jaeger-span-"}, + {true, "", "jaeger-span-read"}, + {false, "foobar", "jaeger-span-"}, + {true, "foobar", "jaeger-span-foobar"}, + } - query := spanstore.GetTraceParameters{} - trace, err := r.reader.GetTrace(context.Background(), query) - require.NotEmpty(t, r.traceBuffer.GetSpans(), "Spans recorded") - require.Nil(t, trace) - require.EqualError(t, err, "trace not found") - }) + for _, tc := range testCases { + t.Run(fmt.Sprintf("useAliases=%v suffix=%s", tc.useAliases, tc.suffix), func(t *testing.T) { + withArchiveSpanReader(t, tc.useAliases, tc.suffix, func(r *spanReaderTest) { + mockSearchService(r). + Return(&elastic.SearchResult{}, nil) + mockArchiveMultiSearchService(r, tc.expected). + Return(&elastic.MultiSearchResult{ + Responses: []*elastic.SearchResult{}, + }, nil) + query := spanstore.GetTraceParameters{} + trace, err := r.reader.GetTrace(context.Background(), query) + require.NotEmpty(t, r.traceBuffer.GetSpans(), "Spans recorded") + require.Nil(t, trace) + require.EqualError(t, err, "trace not found") + }) + }) + } } func TestConvertTraceIDsStringsToModels(t *testing.T) { @@ -1342,7 +1325,7 @@ func TestBuildTraceByIDQuery(t *testing.T) { } func TestTerminateAfterNotSet(t *testing.T) { - srcFn := getSourceFn(false, 99) + srcFn := getSourceFn(99) searchSource := srcFn(elastic.NewMatchAllQuery(), 1) sp, err := searchSource.Source() require.NoError(t, err) diff --git a/plugin/storage/es/spanstore/writer.go b/plugin/storage/es/spanstore/writer.go index 465279cab25..f8647a1db0f 100644 --- a/plugin/storage/es/spanstore/writer.go +++ b/plugin/storage/es/spanstore/writer.go @@ -55,8 +55,8 @@ type SpanWriterParams struct { AllTagsAsFields bool TagKeysAsFields []string TagDotReplacement string - Archive bool UseReadWriteAliases bool + WriteAliasSuffix string ServiceCacheTTL time.Duration } @@ -67,6 +67,15 @@ func NewSpanWriter(p SpanWriterParams) *SpanWriter { serviceCacheTTL = serviceCacheTTLDefault } + writeAliasSuffix := "" + if p.UseReadWriteAliases { + if p.WriteAliasSuffix != "" { + writeAliasSuffix = p.WriteAliasSuffix + } else { + writeAliasSuffix = "write" + } + } + serviceOperationStorage := NewServiceOperationStorage(p.Client, p.Logger, serviceCacheTTL) return &SpanWriter{ client: p.Client, @@ -76,7 +85,7 @@ func NewSpanWriter(p SpanWriterParams) *SpanWriter { }, serviceWriter: serviceOperationStorage.Write, spanConverter: dbmodel.NewFromDomain(p.AllTagsAsFields, p.TagKeysAsFields, p.TagDotReplacement), - spanServiceIndex: getSpanAndServiceIndexFn(p), + spanServiceIndex: getSpanAndServiceIndexFn(p, writeAliasSuffix), } } @@ -98,21 +107,12 @@ func (s *SpanWriter) CreateTemplates(spanTemplate, serviceTemplate string, index // spanAndServiceIndexFn returns names of span and service indices type spanAndServiceIndexFn func(spanTime time.Time) (string, string) -func getSpanAndServiceIndexFn(p SpanWriterParams) spanAndServiceIndexFn { +func getSpanAndServiceIndexFn(p SpanWriterParams, writeAlias string) spanAndServiceIndexFn { spanIndexPrefix := p.IndexPrefix.Apply(spanIndexBaseName) serviceIndexPrefix := p.IndexPrefix.Apply(serviceIndexBaseName) - if p.Archive { - return func(_ time.Time) (string, string) { - if p.UseReadWriteAliases { - return archiveIndex(spanIndexPrefix, archiveWriteIndexSuffix), "" - } - return archiveIndex(spanIndexPrefix, archiveIndexSuffix), "" - } - } - if p.UseReadWriteAliases { - return func(_ /* spanTime */ time.Time) (string, string) { - return spanIndexPrefix + "write", serviceIndexPrefix + "write" + return func(_ time.Time) (string, string) { + return spanIndexPrefix + writeAlias, serviceIndexPrefix + writeAlias } } return func(date time.Time) (string, string) { diff --git a/plugin/storage/es/spanstore/writer_test.go b/plugin/storage/es/spanstore/writer_test.go index 6c4c4b388fd..bf1ef68325a 100644 --- a/plugin/storage/es/spanstore/writer_test.go +++ b/plugin/storage/es/spanstore/writer_test.go @@ -74,7 +74,7 @@ func TestSpanWriterIndices(t *testing.T) { { params: SpanWriterParams{ Client: clientFn, Logger: logger, MetricsFactory: metricsFactory, - SpanIndex: spanIndexOpts, ServiceIndex: serviceIndexOpts, Archive: false, + SpanIndex: spanIndexOpts, ServiceIndex: serviceIndexOpts, }, indices: []string{spanIndexBaseName + spanDataLayoutFormat, serviceIndexBaseName + serviceDataLayoutFormat}, }, @@ -88,37 +88,38 @@ func TestSpanWriterIndices(t *testing.T) { { params: SpanWriterParams{ Client: clientFn, Logger: logger, MetricsFactory: metricsFactory, - SpanIndex: spanIndexOpts, ServiceIndex: serviceIndexOpts, IndexPrefix: "foo:", Archive: false, + SpanIndex: spanIndexOpts, ServiceIndex: serviceIndexOpts, + WriteAliasSuffix: "archive", // ignored because UseReadWriteAliases is false }, - indices: []string{"foo:" + config.IndexPrefixSeparator + spanIndexBaseName + spanDataLayoutFormat, "foo:" + config.IndexPrefixSeparator + serviceIndexBaseName + serviceDataLayoutFormat}, + indices: []string{spanIndexBaseName + spanDataLayoutFormat, serviceIndexBaseName + serviceDataLayoutFormat}, }, { params: SpanWriterParams{ Client: clientFn, Logger: logger, MetricsFactory: metricsFactory, - SpanIndex: spanIndexOpts, ServiceIndex: serviceIndexOpts, IndexPrefix: "foo:", UseReadWriteAliases: true, + SpanIndex: spanIndexOpts, ServiceIndex: serviceIndexOpts, IndexPrefix: "foo:", }, - indices: []string{"foo:-" + spanIndexBaseName + "write", "foo:-" + serviceIndexBaseName + "write"}, + indices: []string{"foo:" + config.IndexPrefixSeparator + spanIndexBaseName + spanDataLayoutFormat, "foo:" + config.IndexPrefixSeparator + serviceIndexBaseName + serviceDataLayoutFormat}, }, { params: SpanWriterParams{ Client: clientFn, Logger: logger, MetricsFactory: metricsFactory, - SpanIndex: spanIndexOpts, ServiceIndex: serviceIndexOpts, Archive: true, + SpanIndex: spanIndexOpts, ServiceIndex: serviceIndexOpts, IndexPrefix: "foo:", UseReadWriteAliases: true, }, - indices: []string{spanIndexBaseName + archiveIndexSuffix, ""}, + indices: []string{"foo:-" + spanIndexBaseName + "write", "foo:-" + serviceIndexBaseName + "write"}, }, { params: SpanWriterParams{ Client: clientFn, Logger: logger, MetricsFactory: metricsFactory, - SpanIndex: spanIndexOpts, ServiceIndex: serviceIndexOpts, IndexPrefix: "foo:", Archive: true, + SpanIndex: spanIndexOpts, ServiceIndex: serviceIndexOpts, WriteAliasSuffix: "archive", UseReadWriteAliases: true, }, - indices: []string{"foo:" + config.IndexPrefixSeparator + spanIndexBaseName + archiveIndexSuffix, ""}, + indices: []string{spanIndexBaseName + "archive", serviceIndexBaseName + "archive"}, }, { params: SpanWriterParams{ Client: clientFn, Logger: logger, MetricsFactory: metricsFactory, - SpanIndex: spanIndexOpts, ServiceIndex: serviceIndexOpts, IndexPrefix: "foo:", Archive: true, UseReadWriteAliases: true, + SpanIndex: spanIndexOpts, ServiceIndex: serviceIndexOpts, IndexPrefix: "foo:", WriteAliasSuffix: "archive", UseReadWriteAliases: true, }, - indices: []string{"foo:" + config.IndexPrefixSeparator + spanIndexBaseName + archiveWriteIndexSuffix, ""}, + indices: []string{"foo:" + config.IndexPrefixSeparator + spanIndexBaseName + "archive", "foo:" + config.IndexPrefixSeparator + serviceIndexBaseName + "archive"}, }, } for _, testCase := range testCases {