Skip to content

Commit

Permalink
fix: skip spans with negative duration (#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
srikanthccv authored Sep 23, 2022
1 parent d582399 commit d12fe28
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions processor/signozspanmetricsprocessor/processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -591,6 +591,13 @@ func getRemoteAddress(span ptrace.Span) (string, bool) {
}

func (p *processorImp) aggregateMetricsForSpan(serviceName string, span ptrace.Span, resourceAttr pcommon.Map) {

// Ideally shouldn't happen but if for some reason span end time is before start time,
// ignore the span. We don't want to count negative latency.
if span.EndTimestamp() < span.StartTimestamp() {
return
}

latencyInMilliseconds := float64(span.EndTimestamp()-span.StartTimestamp()) / float64(time.Millisecond.Nanoseconds())

// Binary search to find the latencyInMilliseconds bucket index.
Expand Down

0 comments on commit d12fe28

Please sign in to comment.