Skip to content

Commit

Permalink
Warn about time adjustment in spans
Browse files Browse the repository at this point in the history
Time adjustment is confusing to many people, as you can see in jaegertracing#961.

This change adds a warning if we do any time adjustments,
so that it's at least clear that adjustments happened.

Signed-off-by: Ivan Babrou <github@ivan.computer>
  • Loading branch information
bobrik committed Feb 2, 2020
1 parent 7d339ef commit a8cb126
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
6 changes: 6 additions & 0 deletions model/adjuster/clockskew.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,13 @@ func (a *clockSkewAdjuster) calculateSkew(child *node, parent *node) time.Durati
}

func (a *clockSkewAdjuster) adjustTimestamps(n *node, skew clockSkew) {
if skew.delta == 0 {
return
}

n.span.StartTime = n.span.StartTime.Add(skew.delta)
n.span.Warnings = append(n.span.Warnings, fmt.Sprintf("This span's timestamps were adjusted by %v", skew.delta))

for i := range n.span.Logs {
n.span.Logs[i].Timestamp = n.span.Logs[i].Timestamp.Add(skew.delta)
}
Expand Down
8 changes: 6 additions & 2 deletions model/adjuster/clockskew_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,12 @@ func TestClockSkewAdjuster(t *testing.T) {
}
assert.Equal(t, err, testCase.err)
} else {
for _, span := range trace.Spans {
assert.Len(t, span.Warnings, 0, "no warnings in span %s", span.SpanID)
for i, span := range trace.Spans {
if testCase.trace[i].adjusted == testCase.trace[i].startTime {
assert.Len(t, span.Warnings, 0, "no warnings in span %s", span.SpanID)
} else {
assert.Len(t, span.Warnings, 1, "warning about adjutment added to span %s", span.SpanID)
}
}
}
for _, proto := range testCase.trace {
Expand Down

0 comments on commit a8cb126

Please sign in to comment.