Skip to content

Commit

Permalink
Don't make a nested if, break out early if no tenant configsZ
Browse files Browse the repository at this point in the history
  • Loading branch information
paul1r committed Jun 20, 2024
1 parent 07a82f0 commit 6b6d3d6
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions pkg/ingester/stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -369,16 +369,18 @@ func (s *stream) storeEntries(ctx context.Context, entries []logproto.Entry, usa
}

func (s *stream) handleLoggingOfDuplicateEntry(entry logproto.Entry) {
if s.configs != nil {
if s.configs.LogDuplicateMetrics(s.tenant) {
s.metrics.duplicateLogBytesTotal.WithLabelValues(s.tenant).Add(float64(len(entry.Line)))
}
if s.configs.LogDuplicateStreamInfo(s.tenant) {
errMsg := fmt.Sprintf("duplicate log entry at timestamp %s for stream %s", entry.Timestamp.Format(time.RFC3339), s.labelsString)
dupErr := errors.New(errMsg)
s.writeFailures.Log(s.tenant, dupErr)
}
if s.configs == nil {
return
}
if s.configs.LogDuplicateMetrics(s.tenant) {
s.metrics.duplicateLogBytesTotal.WithLabelValues(s.tenant).Add(float64(len(entry.Line)))
}
if s.configs.LogDuplicateStreamInfo(s.tenant) {
errMsg := fmt.Sprintf("duplicate log entry at timestamp %s for stream %s", entry.Timestamp.Format(time.RFC3339), s.labelsString)
dupErr := errors.New(errMsg)
s.writeFailures.Log(s.tenant, dupErr)
}

}

func (s *stream) validateEntries(ctx context.Context, entries []logproto.Entry, isReplay, rateLimitWholeStream bool, usageTracker push.UsageTracker) ([]logproto.Entry, []entryWithError) {
Expand Down

0 comments on commit 6b6d3d6

Please sign in to comment.