mirror of
https://github.com/hanzoai/traces.git
synced 2026-10-30 18:20:41 +00:00
* rename batches property of Trace to ResourceSpans to be OTEL compatible * added test to assert that the response hasn't change * update test data * fix unmarshall test * changelog * fix e2e * try to fix flaky test * create helper functions to marshal and unmarshal traces to OTEL compatible schema * added better documentation
83 lines
1.3 KiB
Go
83 lines
1.3 KiB
Go
package trace
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/grafana/tempo/pkg/tempopb"
|
|
v1 "github.com/grafana/tempo/pkg/tempopb/trace/v1"
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestSortTrace(t *testing.T) {
|
|
tests := []struct {
|
|
input *tempopb.Trace
|
|
expected *tempopb.Trace
|
|
}{
|
|
{
|
|
input: &tempopb.Trace{},
|
|
expected: &tempopb.Trace{},
|
|
},
|
|
|
|
{
|
|
input: &tempopb.Trace{
|
|
ResourceSpans: []*v1.ResourceSpans{
|
|
{
|
|
ScopeSpans: []*v1.ScopeSpans{
|
|
{
|
|
Spans: []*v1.Span{
|
|
{
|
|
StartTimeUnixNano: 2,
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
{
|
|
ScopeSpans: []*v1.ScopeSpans{
|
|
{
|
|
Spans: []*v1.Span{
|
|
{
|
|
StartTimeUnixNano: 1,
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
expected: &tempopb.Trace{
|
|
ResourceSpans: []*v1.ResourceSpans{
|
|
{
|
|
ScopeSpans: []*v1.ScopeSpans{
|
|
{
|
|
Spans: []*v1.Span{
|
|
{
|
|
StartTimeUnixNano: 1,
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
{
|
|
ScopeSpans: []*v1.ScopeSpans{
|
|
{
|
|
Spans: []*v1.Span{
|
|
{
|
|
StartTimeUnixNano: 2,
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
}
|
|
|
|
for _, tt := range tests {
|
|
SortTrace(tt.input)
|
|
|
|
assert.Equal(t, tt.expected, tt.input)
|
|
}
|
|
}
|