Skip to content

Commit

Permalink
fix(backend): matching trigger span duration and trigger time duratio…
Browse files Browse the repository at this point in the history
…ns (#2740)
  • Loading branch information
xoscar authored and danielbdias committed Jun 16, 2023
1 parent f379df7 commit 8d0f32c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
4 changes: 4 additions & 0 deletions server/model/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ func durationInMillieconds(d time.Duration) int {
return int(d.Milliseconds())
}

func durationInNanoseconds(d time.Duration) int {
return int(d.Nanoseconds())
}

func durationInSeconds(d time.Duration) int {
return int(math.Ceil(d.Seconds()))
}
Expand Down
2 changes: 1 addition & 1 deletion server/model/spans.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ func NewTracetestRootSpan(run Run) Span {
return AugmentRootSpan(Span{
ID: IDGen.SpanID(),
Name: TriggerSpanName,
StartTime: run.CreatedAt,
StartTime: run.ServiceTriggeredAt,
EndTime: run.ServiceTriggerCompletedAt,
Attributes: Attributes{},
Children: []*Span{},
Expand Down
4 changes: 2 additions & 2 deletions server/model/traces.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ func spanType(attrs Attributes) string {
}

func spanDuration(span Span) string {
timeDifference := span.EndTime.Sub(span.StartTime)
return fmt.Sprintf("%d", int64(timeDifference))
timeDifference := timeDiff(span.StartTime, span.EndTime)
return fmt.Sprintf("%d", durationInNanoseconds(timeDifference))
}

func (t *Trace) Sort() Trace {
Expand Down

0 comments on commit 8d0f32c

Please sign in to comment.