This commit is contained in:
Jeanette Tan 2023-04-26 22:22:31 +08:00
parent 0fccba0db9
commit a064ec6fc1
4 changed files with 11 additions and 10 deletions

View file

@ -73,7 +73,7 @@ func main() {
c, err := tsdb.NewLeveledCompactorWithChunkSize(ctx, nil, logger, []int64{0}, nil, segmentSizeMB*1024*1024, nil, true) c, err := tsdb.NewLeveledCompactorWithChunkSize(ctx, nil, logger, []int64{0}, nil, segmentSizeMB*1024*1024, nil, true)
if err != nil { if err != nil {
log.Fatalln("creating compator", err) log.Panicln("creating compactor", err)
} }
opts := tsdb.DefaultLeveledCompactorConcurrencyOptions() opts := tsdb.DefaultLeveledCompactorConcurrencyOptions()
@ -84,6 +84,6 @@ func main() {
_, err = c.CompactWithSplitting(outputDir, blockDirs, nil, uint64(shardCount)) _, err = c.CompactWithSplitting(outputDir, blockDirs, nil, uint64(shardCount))
if err != nil { if err != nil {
log.Fatalln("compacting", err) log.Panicln("compacting", err)
} }
} }

View file

@ -132,13 +132,13 @@ type MonitoringAssignment_Target struct {
// E.g., `backend-01` // E.g., `backend-01`
Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
// Scheme on which to scrape the target. // Scheme on which to scrape the target.
//E.g., `http` // E.g., `http`
Scheme string `protobuf:"bytes,2,opt,name=scheme,proto3" json:"scheme,omitempty"` Scheme string `protobuf:"bytes,2,opt,name=scheme,proto3" json:"scheme,omitempty"`
// Address (preferably IP) for the service // Address (preferably IP) for the service
// E.g., `backend.svc` or `10.1.4.32:9090` // E.g., `backend.svc` or `10.1.4.32:9090`
Address string `protobuf:"bytes,3,opt,name=address,proto3" json:"address,omitempty"` Address string `protobuf:"bytes,3,opt,name=address,proto3" json:"address,omitempty"`
// Optional path to append to the address for scraping // Optional path to append to the address for scraping
//E.g., `/metrics` // E.g., `/metrics`
MetricsPath string `protobuf:"bytes,4,opt,name=metrics_path,json=metricsPath,proto3" json:"metrics_path,omitempty"` MetricsPath string `protobuf:"bytes,4,opt,name=metrics_path,json=metricsPath,proto3" json:"metrics_path,omitempty"`
// Arbitrary labels associated with that particular target. // Arbitrary labels associated with that particular target.
// //

View file

@ -195,7 +195,7 @@ func findSetMatchesInternal(re *syntax.Regexp, base string) (matches []string, c
} }
var matches []string var matches []string
var totalSet int var totalSet int
for i := 0; i+1 < len(re.Rune); i = i + 2 { for i := 0; i+1 < len(re.Rune); i += 2 {
totalSet += int(re.Rune[i+1]-re.Rune[i]) + 1 totalSet += int(re.Rune[i+1]-re.Rune[i]) + 1
} }
// limits the total characters that can be used to create matches. // limits the total characters that can be used to create matches.
@ -204,7 +204,7 @@ func findSetMatchesInternal(re *syntax.Regexp, base string) (matches []string, c
if totalSet > maxSetMatches { if totalSet > maxSetMatches {
return nil, false return nil, false
} }
for i := 0; i+1 < len(re.Rune); i = i + 2 { for i := 0; i+1 < len(re.Rune); i += 2 {
lo, hi := re.Rune[i], re.Rune[i+1] lo, hi := re.Rune[i], re.Rune[i+1]
for c := lo; c <= hi; c++ { for c := lo; c <= hi; c++ {
matches = append(matches, base+string(c)) matches = append(matches, base+string(c))
@ -566,7 +566,8 @@ type containsStringMatcher struct {
func (m *containsStringMatcher) Matches(s string) bool { func (m *containsStringMatcher) Matches(s string) bool {
for _, substr := range m.substrings { for _, substr := range m.substrings {
if m.right != nil && m.left != nil { switch {
case m.right != nil && m.left != nil:
searchStartPos := 0 searchStartPos := 0
for { for {
@ -588,12 +589,12 @@ func (m *containsStringMatcher) Matches(s string) bool {
// Continue searching for another occurrence of the substring inside the text. // Continue searching for another occurrence of the substring inside the text.
searchStartPos = pos + 1 searchStartPos = pos + 1
} }
} else if m.left != nil { case m.left != nil:
// If we have to check for characters on the left then we need to match a suffix. // If we have to check for characters on the left then we need to match a suffix.
if strings.HasSuffix(s, substr) && m.left.Matches(s[:len(s)-len(substr)]) { if strings.HasSuffix(s, substr) && m.left.Matches(s[:len(s)-len(substr)]) {
return true return true
} }
} else if m.right != nil { case m.right != nil:
if strings.HasPrefix(s, substr) && m.right.Matches(s[len(substr):]) { if strings.HasPrefix(s, substr) && m.right.Matches(s[len(substr):]) {
return true return true
} }

View file

@ -594,7 +594,7 @@ func (c *LeveledCompactor) compactOOO(dest string, oooHead *OOOCompactionHead, s
blockSize := oooHead.ChunkRange() blockSize := oooHead.ChunkRange()
oooHeadMint, oooHeadMaxt := oooHead.MinTime(), oooHead.MaxTime() oooHeadMint, oooHeadMaxt := oooHead.MinTime(), oooHead.MaxTime()
ulids := make([][]ulid.ULID, 0) ulids := make([][]ulid.ULID, 0)
for t := blockSize * (oooHeadMint / blockSize); t <= oooHeadMaxt; t = t + blockSize { for t := blockSize * (oooHeadMint / blockSize); t <= oooHeadMaxt; t += blockSize {
mint, maxt := t, t+blockSize mint, maxt := t, t+blockSize
outBlocks = append(outBlocks, make([]shardedBlock, shardCount)) outBlocks = append(outBlocks, make([]shardedBlock, shardCount))