-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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] Add index rollover mode that can choose day and hour #2965
Changes from 2 commits
37751e6
c704add
b39325b
632700b
9788c45
eacd0ad
2d6733b
915666d
e9f8cbb
ba7b82e
0e54999
ff27c96
e8e5388
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,6 +21,7 @@ import ( | |
"encoding/json" | ||
"errors" | ||
"fmt" | ||
"strings" | ||
"time" | ||
|
||
"github.com/olivere/elastic" | ||
|
@@ -199,9 +200,16 @@ func timeRangeIndices(indexName, indexDateLayout string, startTime time.Time, en | |
var indices []string | ||
firstIndex := indexWithDate(indexName, indexDateLayout, startTime) | ||
currentIndex := indexWithDate(indexName, indexDateLayout, endTime) | ||
|
||
reduce := -24 * time.Hour | ||
if strings.HasSuffix(indexDateLayout, "15") { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's a shame There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A cleaner way is to pass freq directly as parameter, not infer it back from format string There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, I also thought previously, but if pass freq directly then will also judge this variable too( And another side, other functions will be become more complicated include Actually, I always thought this commit should be small and should not change more code, but if we need, I can do it There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fair enough. As Albert said, it would be good to at least use a named constant shared between config and span reader There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok, I see, now that we decide to add the new constant, I want to separate rollover There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sounds good. I would suggest these names |
||
reduce = -1 * time.Hour | ||
} | ||
for currentIndex != firstIndex { | ||
indices = append(indices, currentIndex) | ||
endTime = endTime.Add(-24 * time.Hour) | ||
if len(indices) == 0 || indices[len(indices)-1] != currentIndex { | ||
indices = append(indices, currentIndex) | ||
} | ||
endTime = endTime.Add(reduce) | ||
currentIndex = indexWithDate(indexName, indexDateLayout, endTime) | ||
} | ||
indices = append(indices, firstIndex) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Didn't we decide to change this msg?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@WalkerWang731 I believe we suggested to reword this to (@yurishkuro please correct if I'm wrong):