Skip to content

Commit

Permalink
Fix time conversion from internal to otlp (#606)
Browse files Browse the repository at this point in the history
Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
  • Loading branch information
bogdandrutu authored Mar 31, 2020
1 parent 02b6be1 commit 1f6ffa9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
4 changes: 2 additions & 2 deletions exporters/otlp/internal/transform/span.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ func span(sd *export.SpanData) *tracepb.Span {
SpanId: sd.SpanContext.SpanID[:],
ParentSpanId: sd.ParentSpanID[:],
Status: status(sd.StatusCode, sd.StatusMessage),
StartTimeUnixNano: uint64(sd.StartTime.Nanosecond()),
EndTimeUnixNano: uint64(sd.EndTime.Nanosecond()),
StartTimeUnixNano: uint64(sd.StartTime.UnixNano()),
EndTimeUnixNano: uint64(sd.EndTime.UnixNano()),
Links: links(sd.Links),
Kind: spanKind(sd.SpanKind),
Name: sd.Name,
Expand Down
7 changes: 4 additions & 3 deletions exporters/otlp/internal/transform/span_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,8 @@ func TestEmptySpanData(t *testing.T) {
func TestSpanData(t *testing.T) {
// Full test of span data transform.

startTime := time.Now()
// March 31, 2020 5:01:26 1234nanos (UTC)
startTime := time.Unix(1585674086, 1234)
endTime := startTime.Add(10 * time.Second)
spanData := &export.SpanData{
SpanContext: core.SpanContext{
Expand Down Expand Up @@ -332,8 +333,8 @@ func TestSpanData(t *testing.T) {
ParentSpanId: []byte{0xEF, 0xEE, 0xED, 0xEC, 0xEB, 0xEA, 0xE9, 0xE8},
Name: spanData.Name,
Kind: tracepb.Span_SERVER,
StartTimeUnixNano: uint64(startTime.Nanosecond()),
EndTimeUnixNano: uint64(endTime.Nanosecond()),
StartTimeUnixNano: uint64(1585674086000001234),
EndTimeUnixNano: uint64(1585674096000001234),
Status: status(spanData.StatusCode, spanData.StatusMessage),
Events: spanEvents(spanData.MessageEvents),
Links: links(spanData.Links),
Expand Down

0 comments on commit 1f6ffa9

Please sign in to comment.