Skip to content

Commit

Permalink
Remove Redundant Constants
Browse files Browse the repository at this point in the history
Signed-off-by: Mahad Zaryab <[email protected]>
  • Loading branch information
mahadzaryab1 committed Oct 6, 2024
1 parent 60cc5a3 commit aec39e5
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 21 deletions.
8 changes: 4 additions & 4 deletions plugin/storage/es/dependencystore/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ import (

"github.com/jaegertracing/jaeger/model"
"github.com/jaegertracing/jaeger/pkg/es"
"github.com/jaegertracing/jaeger/pkg/es/config"
"github.com/jaegertracing/jaeger/plugin/storage/es/dependencystore/dbmodel"
)

const (
dependencyType = "dependencies"
dependencyIndex = "jaeger-dependencies-"
indexPrefixSeparator = "-"
dependencyType = "dependencies"
dependencyIndex = "jaeger-dependencies-"
)

// DependencyStore handles all queries and insertions to ElasticSearch dependencies
Expand Down Expand Up @@ -59,7 +59,7 @@ func NewDependencyStore(p Params) *DependencyStore {

func prefixIndexName(prefix, index string) string {
if prefix != "" {
return prefix + indexPrefixSeparator + index
return prefix + config.IndexPrefixSeparator + index
}
return index
}
Expand Down
5 changes: 3 additions & 2 deletions plugin/storage/es/dependencystore/storage_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (

"github.com/jaegertracing/jaeger/model"
"github.com/jaegertracing/jaeger/pkg/es"
"github.com/jaegertracing/jaeger/pkg/es/config"
"github.com/jaegertracing/jaeger/pkg/es/mocks"
"github.com/jaegertracing/jaeger/pkg/testutils"
"github.com/jaegertracing/jaeger/storage/dependencystore"
Expand Down Expand Up @@ -234,14 +235,14 @@ func TestGetReadIndices(t *testing.T) {
params: Params{IndexPrefix: "foo:", IndexDateLayout: "2006-01-02"},
lookback: 1 * time.Hour,
indices: []string{
"foo:" + indexPrefixSeparator + dependencyIndex + fixedTime.Format("2006-01-02"),
"foo:" + config.IndexPrefixSeparator + dependencyIndex + fixedTime.Format("2006-01-02"),
},
},
{
params: Params{IndexPrefix: "foo-", IndexDateLayout: "2006-01-02"},
lookback: 0,
indices: []string{
"foo-" + indexPrefixSeparator + dependencyIndex + fixedTime.Format("2006-01-02"),
"foo-" + config.IndexPrefixSeparator + dependencyIndex + fixedTime.Format("2006-01-02"),
},
},
}
Expand Down
2 changes: 1 addition & 1 deletion plugin/storage/es/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ func createDependencyReader(
Client: clientFn,
Logger: logger,
IndexPrefix: cfg.Indices.Dependencies.Prefix,
IndexDateLayout: cfg.Indices.Dependencies.RolloverFrequency,
IndexDateLayout: cfg.Indices.Dependencies.DateLayout,
MaxDocCount: cfg.MaxDocCount,
UseReadWriteAliases: cfg.UseReadWriteAliases,
})
Expand Down
2 changes: 1 addition & 1 deletion plugin/storage/es/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ func initFromViper(cfg *namespaceConfig, v *viper.Viper) {
cfg.Indices.Sampling.DateLayout = initDateLayout(cfg.Indices.Sampling.RolloverFrequency, separator)

// Daily is recommended for dependencies calculation, and this index size is very small
cfg.Indices.Dependencies.DateLayout = initDateLayout(cfg.Indices.Dependencies.RolloverFrequency, separator)
cfg.Indices.Dependencies.DateLayout = initDateLayout(cfg.Indices.Dependencies.DateLayout, separator)
var err error
cfg.TLS, err = cfg.getTLSFlagsConfig().InitFromViper(v)
if err != nil {
Expand Down
12 changes: 6 additions & 6 deletions plugin/storage/es/samplingstore/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ import (

"github.com/jaegertracing/jaeger/cmd/collector/app/sampling/model"
"github.com/jaegertracing/jaeger/pkg/es"
"github.com/jaegertracing/jaeger/pkg/es/config"
"github.com/jaegertracing/jaeger/plugin/storage/es/samplingstore/dbmodel"
)

const (
samplingIndex = "jaeger-sampling"
throughputType = "throughput-sampling"
probabilitiesType = "probabilities-sampling"
indexPrefixSeparator = "-"
samplingIndex = "jaeger-sampling"
throughputType = "throughput-sampling"
probabilitiesType = "probabilities-sampling"
)

type SamplingStore struct {
Expand All @@ -48,7 +48,7 @@ func NewSamplingStore(p Params) *SamplingStore {
return &SamplingStore{
client: p.Client,
logger: p.Logger,
samplingIndexPrefix: p.PrefixedIndexName() + indexPrefixSeparator,
samplingIndexPrefix: p.PrefixedIndexName() + config.IndexPrefixSeparator,
indexDateLayout: p.IndexDateLayout,
maxDocCount: p.MaxDocCount,
indexRolloverFrequency: p.IndexRolloverFrequency,
Expand Down Expand Up @@ -186,7 +186,7 @@ func getReadIndices(indexName, indexDateLayout string, startTime time.Time, endT

func (p *Params) PrefixedIndexName() string {
if p.IndexPrefix != "" {
return p.IndexPrefix + indexPrefixSeparator + samplingIndex
return p.IndexPrefix + config.IndexPrefixSeparator + samplingIndex
}
return samplingIndex
}
Expand Down
3 changes: 2 additions & 1 deletion plugin/storage/es/samplingstore/storage_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (

samplemodel "github.com/jaegertracing/jaeger/cmd/collector/app/sampling/model"
"github.com/jaegertracing/jaeger/pkg/es"
"github.com/jaegertracing/jaeger/pkg/es/config"
"github.com/jaegertracing/jaeger/pkg/es/mocks"
"github.com/jaegertracing/jaeger/pkg/testutils"
"github.com/jaegertracing/jaeger/plugin/storage/es/samplingstore/dbmodel"
Expand Down Expand Up @@ -77,7 +78,7 @@ func TestNewIndexPrefix(t *testing.T) {
IndexDateLayout: "2006-01-02",
MaxDocCount: defaultMaxDocCount,
})
assert.Equal(t, test.expected+samplingIndex+indexPrefixSeparator, r.samplingIndexPrefix)
assert.Equal(t, test.expected+samplingIndex+config.IndexPrefixSeparator, r.samplingIndexPrefix)
})
}
}
Expand Down
6 changes: 3 additions & 3 deletions plugin/storage/es/spanstore/reader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ func TestSpanReaderIndices(t *testing.T) {
params: SpanReaderParams{
Archive: false, SpanIndex: spanIndexOptsWithFoo, ServiceIndex: serviceIndexOptsWithFoo,
},
indices: []string{"foo:" + indexPrefixSeparator + spanIndexBaseName + spanDataLayoutFormat, "foo:" + indexPrefixSeparator + serviceIndexBaseName + serviceDataLayoutFormat},
indices: []string{"foo:" + config.IndexPrefixSeparator + spanIndexBaseName + spanDataLayoutFormat, "foo:" + config.IndexPrefixSeparator + serviceIndexBaseName + serviceDataLayoutFormat},
},
{
params: SpanReaderParams{
Expand All @@ -236,13 +236,13 @@ func TestSpanReaderIndices(t *testing.T) {
params: SpanReaderParams{
SpanIndex: spanIndexOptsWithFoo, ServiceIndex: serviceIndexOptsWithFoo, Archive: true,
},
indices: []string{"foo:" + indexPrefixSeparator + spanIndexBaseName + archiveIndexSuffix, "foo:" + indexPrefixSeparator + serviceIndexBaseName + archiveIndexSuffix},
indices: []string{"foo:" + config.IndexPrefixSeparator + spanIndexBaseName + archiveIndexSuffix, "foo:" + config.IndexPrefixSeparator + serviceIndexBaseName + archiveIndexSuffix},
},
{
params: SpanReaderParams{
SpanIndex: spanIndexOptsWithFoo, ServiceIndex: serviceIndexOptsWithFoo, Archive: true, UseReadWriteAliases: true,
},
indices: []string{"foo:" + indexPrefixSeparator + spanIndexBaseName + archiveReadIndexSuffix, "foo:" + indexPrefixSeparator + serviceIndexBaseName + archiveReadIndexSuffix},
indices: []string{"foo:" + config.IndexPrefixSeparator + spanIndexBaseName + archiveReadIndexSuffix, "foo:" + config.IndexPrefixSeparator + serviceIndexBaseName + archiveReadIndexSuffix},
},
{
params: SpanReaderParams{
Expand Down
6 changes: 3 additions & 3 deletions plugin/storage/es/spanstore/writer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func TestSpanWriterIndices(t *testing.T) {
Client: clientFn, Logger: logger, MetricsFactory: metricsFactory,
SpanIndex: spanIndexOptsWithFoo, ServiceIndex: serviceIndexOptsWithFoo, Archive: false,
},
indices: []string{"foo:" + indexPrefixSeparator + spanIndexBaseName + spanDataLayoutFormat, "foo:" + indexPrefixSeparator + serviceIndexBaseName + serviceDataLayoutFormat},
indices: []string{"foo:" + config.IndexPrefixSeparator + spanIndexBaseName + spanDataLayoutFormat, "foo:" + config.IndexPrefixSeparator + serviceIndexBaseName + serviceDataLayoutFormat},
},
{
params: SpanWriterParams{
Expand All @@ -112,14 +112,14 @@ func TestSpanWriterIndices(t *testing.T) {
Client: clientFn, Logger: logger, MetricsFactory: metricsFactory,
SpanIndex: spanIndexOptsWithFoo, ServiceIndex: serviceIndexOptsWithFoo, Archive: true,
},
indices: []string{"foo:" + indexPrefixSeparator + spanIndexBaseName + archiveIndexSuffix, ""},
indices: []string{"foo:" + config.IndexPrefixSeparator + spanIndexBaseName + archiveIndexSuffix, ""},
},
{
params: SpanWriterParams{
Client: clientFn, Logger: logger, MetricsFactory: metricsFactory,
SpanIndex: spanIndexOptsWithFoo, ServiceIndex: serviceIndexOptsWithFoo, Archive: true, UseReadWriteAliases: true,
},
indices: []string{"foo:" + indexPrefixSeparator + spanIndexBaseName + archiveWriteIndexSuffix, ""},
indices: []string{"foo:" + config.IndexPrefixSeparator + spanIndexBaseName + archiveWriteIndexSuffix, ""},
},
}
for _, testCase := range testCases {
Expand Down

0 comments on commit aec39e5

Please sign in to comment.