-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Pavol Loffay <[email protected]>
- Loading branch information
1 parent
48e2095
commit bfd2dbe
Showing
10 changed files
with
224 additions
and
132 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
// Copyright (c) 2018 The Jaeger Authors. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package spanstore | ||
|
||
import ( | ||
"time" | ||
) | ||
|
||
type spanAndServiceIndexFce func(spanTime time.Time) (string, string) | ||
|
||
type indicesForTimeRangeFce func(indexName string, startTime time.Time, endTime time.Time) []string | ||
|
||
func getSpanAndServiceIndexFunc(archive bool, spanIndexPrefix, serviceIndexPrefix string) spanAndServiceIndexFce { | ||
if archive { | ||
return func(date time.Time) (string, string) { | ||
return archiveIndex(spanIndexPrefix, archiveIndexSuffix), "" | ||
} | ||
} | ||
return func(date time.Time) (string, string) { | ||
return indexWithDate(spanIndexPrefix, date), indexWithDate(serviceIndexPrefix, date) | ||
} | ||
} | ||
|
||
func getIndicesFceForTimeRange(archive bool, archivePrefix string) indicesForTimeRangeFce { | ||
if archive { | ||
return func(indexName string, startTime time.Time, endTime time.Time) []string { | ||
return []string{archiveIndex(indexName, archivePrefix)} | ||
} | ||
} | ||
return indicesForTimeRange | ||
} | ||
|
||
// returns index name with date | ||
func indexWithDate(indexPrefix string, date time.Time) string { | ||
spanDate := date.UTC().Format("2006-01-02") | ||
return indexPrefix + spanDate | ||
} | ||
|
||
// returns archive index name | ||
func archiveIndex(indexPrefix, archivePrefix string) string { | ||
return indexPrefix + archivePrefix | ||
} | ||
|
||
// indicesForTimeRange returns the array of indices that we need to query, based on query params | ||
func indicesForTimeRange(indexName string, startTime time.Time, endTime time.Time) []string { | ||
var indices []string | ||
firstIndex := indexWithDate(indexName, startTime) | ||
currentIndex := indexWithDate(indexName, endTime) | ||
for currentIndex != firstIndex { | ||
indices = append(indices, currentIndex) | ||
endTime = endTime.Add(-24 * time.Hour) | ||
currentIndex = indexWithDate(indexName, endTime) | ||
} | ||
return append(indices, firstIndex) | ||
} |
Oops, something went wrong.