Skip to content

Commit

Permalink
Merge pull request #156 from ymtdzzz/feature/replace_trace_id_with_la…
Browse files Browse the repository at this point in the history
…tency

Replace trace ID with latency in trace list
  • Loading branch information
ymtdzzz authored Sep 9, 2024
2 parents 96decb6 + bb71ce5 commit 8847bae
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
7 changes: 4 additions & 3 deletions tuiexporter/internal/tui/component/trace.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import (

var spanTableHeader = [5]string{
" ", // Error indicator
"Trace ID",
"Service Name",
"Latency",
"Received At",
"Span Name",
}
Expand Down Expand Up @@ -69,11 +69,12 @@ func (s SpanDataForTable) getCellFromSpan(span *telemetry.SpanData, column int)
}
}
case 1:
text = span.Span.TraceID().String()
case 2:
if sname, ok := span.ResourceSpan.Resource().Attributes().Get("service.name"); ok {
text = sname.AsString()
}
case 2:
duration := span.Span.EndTimestamp().AsTime().Sub(span.Span.StartTimestamp().AsTime())
text = duration.String()
case 3:
text = span.ReceivedAt.Local().Format("2006-01-02 15:04:05")
case 4:
Expand Down
12 changes: 6 additions & 6 deletions tuiexporter/internal/tui/component/trace_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,16 +113,16 @@ func TestSpanDataForTable(t *testing.T) {
want: "",
},
{
name: "trace ID trace 1 span-1-1-1",
row: 0,
name: "service name trace 1 span-2-1-1",
row: 1,
column: 1,
want: "01000000000000000000000000000000",
want: "test-service-2",
},
{
name: "service name trace 1 span-2-1-1",
row: 1,
name: "latency span-1-1-1",
row: 0,
column: 2,
want: "test-service-2",
want: "200ms",
},
{
name: "received at trace 2 span-1-1-1",
Expand Down

0 comments on commit 8847bae

Please sign in to comment.