Skip to content

Commit

Permalink
Rename TraceData to Traces in tests (#3325)
Browse files Browse the repository at this point in the history
Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
  • Loading branch information
bogdandrutu authored May 27, 2021
1 parent 66c4908 commit 6e1137c
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 33 deletions.
44 changes: 22 additions & 22 deletions translator/trace/jaeger/jaegerproto_to_traces_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
"github.com/stretchr/testify/require"

"go.opentelemetry.io/collector/consumer/pdata"
idutils "go.opentelemetry.io/collector/internal/idutils"
"go.opentelemetry.io/collector/internal/idutils"
"go.opentelemetry.io/collector/internal/testdata"
"go.opentelemetry.io/collector/translator/conventions"
tracetranslator "go.opentelemetry.io/collector/translator/trace"
Expand Down Expand Up @@ -201,7 +201,7 @@ func TestProtoBatchToInternalTraces(t *testing.T) {
jb: model.Batch{
Process: generateProtoProcess(),
},
td: generateTraceDataResourceOnly(),
td: generateTracesResourceOnly(),
},

{
Expand All @@ -211,7 +211,7 @@ func TestProtoBatchToInternalTraces(t *testing.T) {
ServiceName: tracetranslator.ResourceNoServiceName,
},
},
td: generateTraceDataResourceOnlyWithNoAttrs(),
td: generateTracesResourceOnlyWithNoAttrs(),
},

{
Expand All @@ -224,7 +224,7 @@ func TestProtoBatchToInternalTraces(t *testing.T) {
generateProtoSpanWithTraceState(),
},
},
td: generateTraceDataOneSpanNoResourceWithTraceState(),
td: generateTracesOneSpanNoResourceWithTraceState(),
},
{
name: "two-spans-child-parent",
Expand All @@ -237,7 +237,7 @@ func TestProtoBatchToInternalTraces(t *testing.T) {
generateProtoChildSpan(),
},
},
td: generateTraceDataTwoSpansChildParent(),
td: generateTracesTwoSpansChildParent(),
},

{
Expand All @@ -251,7 +251,7 @@ func TestProtoBatchToInternalTraces(t *testing.T) {
generateProtoFollowerSpan(),
},
},
td: generateTraceDataTwoSpansWithFollower(),
td: generateTracesTwoSpansWithFollower(),
},
}

Expand Down Expand Up @@ -304,7 +304,7 @@ func TestProtoBatchToInternalTracesWithTwoLibraries(t *testing.T) {
},
},
}
expected := generateTraceDataTwoSpansFromTwoLibraries()
expected := generateTracesTwoSpansFromTwoLibraries()
library1Span := expected.ResourceSpans().At(0).InstrumentationLibrarySpans().At(0)
library2Span := expected.ResourceSpans().At(0).InstrumentationLibrarySpans().At(1)

Expand Down Expand Up @@ -449,11 +449,11 @@ func TestProtoBatchesToInternalTraces(t *testing.T) {
},
}

expected := generateTraceDataOneSpanNoResource()
resource := generateTraceDataResourceOnly().ResourceSpans().At(0).Resource()
expected := generateTracesOneSpanNoResource()
resource := generateTracesResourceOnly().ResourceSpans().At(0).Resource()
resource.CopyTo(expected.ResourceSpans().At(0).Resource())
expected.ResourceSpans().Resize(2)
twoSpans := generateTraceDataTwoSpansChildParent().ResourceSpans().At(0)
twoSpans := generateTracesTwoSpansChildParent().ResourceSpans().At(0)
twoSpans.CopyTo(expected.ResourceSpans().At(1))

got := ProtoBatchesToInternalTraces(batches)
Expand Down Expand Up @@ -498,15 +498,15 @@ func TestJSpanKindToInternal(t *testing.T) {
}
}

func generateTraceDataResourceOnly() pdata.Traces {
func generateTracesResourceOnly() pdata.Traces {
td := testdata.GenerateTracesOneEmptyResourceSpans()
rs := td.ResourceSpans().At(0).Resource()
rs.Attributes().InsertString(conventions.AttributeServiceName, "service-1")
rs.Attributes().InsertInt("int-attr-1", 123)
return td
}

func generateTraceDataResourceOnlyWithNoAttrs() pdata.Traces {
func generateTracesResourceOnlyWithNoAttrs() pdata.Traces {
td := testdata.GenerateTracesOneEmptyResourceSpans()
td.ResourceSpans().At(0).Resource().Attributes().InitFromMap(map[string]pdata.AttributeValue{})
return td
Expand All @@ -525,7 +525,7 @@ func generateProtoProcess() *model.Process {
}
}

func generateTraceDataOneSpanNoResource() pdata.Traces {
func generateTracesOneSpanNoResource() pdata.Traces {
td := testdata.GenerateTracesOneSpanNoResource()
span := td.ResourceSpans().At(0).InstrumentationLibrarySpans().At(0).Spans().At(0)
span.SetSpanID(pdata.NewSpanID([8]byte{0xAF, 0xAE, 0xAD, 0xAC, 0xAB, 0xAA, 0xA9, 0xA8}))
Expand All @@ -546,17 +546,17 @@ func generateTraceDataOneSpanNoResource() pdata.Traces {
return td
}

func generateTraceDataWithLibraryInfo() pdata.Traces {
td := generateTraceDataOneSpanNoResource()
func generateTracesWithLibraryInfo() pdata.Traces {
td := generateTracesOneSpanNoResource()
rs0 := td.ResourceSpans().At(0)
rs0ils0 := rs0.InstrumentationLibrarySpans().At(0)
rs0ils0.InstrumentationLibrary().SetName("io.opentelemetry.test")
rs0ils0.InstrumentationLibrary().SetVersion("0.42.0")
return td
}

func generateTraceDataOneSpanNoResourceWithTraceState() pdata.Traces {
td := generateTraceDataOneSpanNoResource()
func generateTracesOneSpanNoResourceWithTraceState() pdata.Traces {
td := generateTracesOneSpanNoResource()
span := td.ResourceSpans().At(0).InstrumentationLibrarySpans().At(0).Spans().At(0)
span.SetTraceState("lasterror=f39cd56cc44274fd5abd07ef1164246d10ce2955")
return td
Expand Down Expand Up @@ -707,8 +707,8 @@ func generateProtoSpanWithTraceState() *model.Span {
}
}

func generateTraceDataTwoSpansChildParent() pdata.Traces {
td := generateTraceDataOneSpanNoResource()
func generateTracesTwoSpansChildParent() pdata.Traces {
td := generateTracesOneSpanNoResource()
spans := td.ResourceSpans().At(0).InstrumentationLibrarySpans().At(0).Spans()
spans.Resize(2)

Expand Down Expand Up @@ -761,8 +761,8 @@ func generateProtoChildSpan() *model.Span {
}
}

func generateTraceDataTwoSpansWithFollower() pdata.Traces {
td := generateTraceDataOneSpanNoResource()
func generateTracesTwoSpansWithFollower() pdata.Traces {
td := generateTracesOneSpanNoResource()
spans := td.ResourceSpans().At(0).InstrumentationLibrarySpans().At(0).Spans()
spans.Resize(2)

Expand Down Expand Up @@ -834,7 +834,7 @@ func BenchmarkProtoBatchToInternalTraces(b *testing.B) {
}
}

func generateTraceDataTwoSpansFromTwoLibraries() pdata.Traces {
func generateTracesTwoSpansFromTwoLibraries() pdata.Traces {
td := testdata.GenerateTracesOneEmptyResourceSpans()

rs0 := td.ResourceSpans().At(0)
Expand Down
6 changes: 3 additions & 3 deletions translator/trace/jaeger/jaegerthrift_to_traces_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ func TestThriftBatchToInternalTraces(t *testing.T) {
generateThriftSpan(),
},
},
td: generateTraceDataOneSpanNoResource(),
td: generateTracesOneSpanNoResource(),
},
{
name: "two-spans-child-parent",
Expand All @@ -112,7 +112,7 @@ func TestThriftBatchToInternalTraces(t *testing.T) {
generateThriftChildSpan(),
},
},
td: generateTraceDataTwoSpansChildParent(),
td: generateTracesTwoSpansChildParent(),
},

{
Expand All @@ -123,7 +123,7 @@ func TestThriftBatchToInternalTraces(t *testing.T) {
generateThriftFollowerSpan(),
},
},
td: generateTraceDataTwoSpansWithFollower(),
td: generateTracesTwoSpansWithFollower(),
},
}

Expand Down
16 changes: 8 additions & 8 deletions translator/trace/jaeger/traces_to_jaegerproto_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ func TestInternalTracesToJaegerProto(t *testing.T) {

{
name: "no-spans",
td: generateTraceDataResourceOnly(),
td: generateTracesResourceOnly(),
jb: &model.Batch{
Process: generateProtoProcess(),
},
Expand All @@ -243,13 +243,13 @@ func TestInternalTracesToJaegerProto(t *testing.T) {

{
name: "no-resource-attrs",
td: generateTraceDataResourceOnlyWithNoAttrs(),
td: generateTracesResourceOnlyWithNoAttrs(),
err: nil,
},

{
name: "one-span-no-resources",
td: generateTraceDataOneSpanNoResourceWithTraceState(),
td: generateTracesOneSpanNoResourceWithTraceState(),
jb: &model.Batch{
Process: &model.Process{
ServiceName: tracetranslator.ResourceNoServiceName,
Expand All @@ -262,7 +262,7 @@ func TestInternalTracesToJaegerProto(t *testing.T) {
},
{
name: "library-info",
td: generateTraceDataWithLibraryInfo(),
td: generateTracesWithLibraryInfo(),
jb: &model.Batch{
Process: &model.Process{
ServiceName: tracetranslator.ResourceNoServiceName,
Expand All @@ -275,7 +275,7 @@ func TestInternalTracesToJaegerProto(t *testing.T) {
},
{
name: "two-spans-child-parent",
td: generateTraceDataTwoSpansChildParent(),
td: generateTracesTwoSpansChildParent(),
jb: &model.Batch{
Process: &model.Process{
ServiceName: tracetranslator.ResourceNoServiceName,
Expand All @@ -290,7 +290,7 @@ func TestInternalTracesToJaegerProto(t *testing.T) {

{
name: "two-spans-with-follower",
td: generateTraceDataTwoSpansWithFollower(),
td: generateTracesTwoSpansWithFollower(),
jb: &model.Batch{
Process: &model.Process{
ServiceName: tracetranslator.ResourceNoServiceName,
Expand Down Expand Up @@ -352,8 +352,8 @@ func generateProtoChildSpanWithErrorTags() *model.Span {
}

func BenchmarkInternalTracesToJaegerProto(b *testing.B) {
td := generateTraceDataTwoSpansChildParent()
resource := generateTraceDataResourceOnly().ResourceSpans().At(0).Resource()
td := generateTracesTwoSpansChildParent()
resource := generateTracesResourceOnly().ResourceSpans().At(0).Resource()
resource.CopyTo(td.ResourceSpans().At(0).Resource())

b.ResetTimer()
Expand Down

0 comments on commit 6e1137c

Please sign in to comment.