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

Set lookback in ES rollover to distant past #3169

Merged
merged 3 commits into from
Aug 5, 2021
Merged
Show file tree
Hide file tree
Changes from 2 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: 9 additions & 1 deletion plugin/storage/es/spanstore/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ const (
tagValueField = "value"

defaultNumTraces = 100

rolloverMaxSpanAge = time.Hour * 24 * 365 * 100
)

var (
Expand Down Expand Up @@ -129,10 +131,16 @@ type SpanReaderParams struct {

// NewSpanReader returns a new SpanReader with a metrics.
func NewSpanReader(p SpanReaderParams) *SpanReader {
maxSpanAge := p.MaxSpanAge
// 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
}
return &SpanReader{
client: p.Client,
logger: p.Logger,
maxSpanAge: p.MaxSpanAge,
maxSpanAge: maxSpanAge,
serviceOperationStorage: NewServiceOperationStorage(p.Client, p.Logger, 0), // the decorator takes care of metrics
spanIndexPrefix: indexNames(p.IndexPrefix, spanIndex),
serviceIndexPrefix: indexNames(p.IndexPrefix, serviceIndex),
Expand Down
36 changes: 27 additions & 9 deletions plugin/storage/es/spanstore/reader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"
"github.com/stretchr/testify/require"
"github.com/uber/jaeger-lib/metrics"
"github.com/uber/jaeger-lib/metrics/metricstest"
"go.uber.org/zap"

Expand Down Expand Up @@ -132,14 +131,33 @@ func withArchiveSpanReader(readAlias bool, fn func(r *spanReaderTest)) {
var _ spanstore.Reader = &SpanReader{} // check API conformance

func TestNewSpanReader(t *testing.T) {
client := &mocks.Client{}
reader := NewSpanReader(SpanReaderParams{
Client: client,
Logger: zap.NewNop(),
MaxSpanAge: 0,
MetricsFactory: metrics.NullFactory,
IndexPrefix: ""})
assert.NotNil(t, reader)
tests := []struct {
name string
params SpanReaderParams
maxSpanAge time.Duration
}{
{
name: "no rollover",
params: SpanReaderParams{
MaxSpanAge: time.Hour * 72,
},
maxSpanAge: time.Hour * 72,
},
{
name: "rollover enabled",
params: SpanReaderParams{
MaxSpanAge: time.Hour * 72,
UseReadWriteAliases: true,
},
maxSpanAge: time.Hour * 24 * 365 * 100,
},
}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
reader := NewSpanReader(test.params)
require.NotNil(t, reader)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think you're missing the assertion on test.maxSpanAge here (I would rename it test.wantMaxSpanAge to make it clear it's the expected value)?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doh, fixed

})
}
}

func TestSpanReaderIndices(t *testing.T) {
Expand Down