Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix trace event time conversion from internal to otlp #896

Merged
merged 3 commits into from
Jul 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion exporters/otlp/internal/transform/span.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ func spanEvents(es []export.Event) []*tracepb.Span_Event {
events = append(events,
&tracepb.Span_Event{
Name: e.Name,
TimeUnixNano: uint64(e.Time.Nanosecond()),
TimeUnixNano: uint64(e.Time.UnixNano()),
Attributes: Attributes(e.Attributes),
// TODO (rghetia) : Add Drop Counts when supported.
},
Expand Down
12 changes: 6 additions & 6 deletions exporters/otlp/internal/transform/span_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,26 +77,26 @@ func TestEmptySpanEvent(t *testing.T) {

func TestSpanEvent(t *testing.T) {
attrs := []kv.KeyValue{kv.Int("one", 1), kv.Int("two", 2)}
now := time.Now()
eventTime := time.Date(2020, 5, 20, 0, 0, 0, 0, time.UTC)
got := spanEvents([]export.Event{
{
Name: "test 1",
Attributes: []kv.KeyValue{},
Time: now,
Time: eventTime,
},
{
Name: "test 2",
Attributes: attrs,
Time: now,
Time: eventTime,
},
})
if !assert.Len(t, got, 2) {
return
}
uNow := uint64(now.Nanosecond())
assert.Equal(t, &tracepb.Span_Event{Name: "test 1", Attributes: nil, TimeUnixNano: uNow}, got[0])
eventTimestamp := uint64(1589932800 * 1e9)
assert.Equal(t, &tracepb.Span_Event{Name: "test 1", Attributes: nil, TimeUnixNano: eventTimestamp}, got[0])
// Do not test Attributes directly, just that the return value goes to the correct field.
assert.Equal(t, &tracepb.Span_Event{Name: "test 2", Attributes: Attributes(attrs), TimeUnixNano: uNow}, got[1])
assert.Equal(t, &tracepb.Span_Event{Name: "test 2", Attributes: Attributes(attrs), TimeUnixNano: eventTimestamp}, got[1])
}

func TestExcessiveSpanEvents(t *testing.T) {
Expand Down