Skip to content

Commit

Permalink
Remove couple of Append usages (#2976)
Browse files Browse the repository at this point in the history
Signed-off-by: Bogdan Drutu <[email protected]>
  • Loading branch information
bogdandrutu authored Apr 21, 2021
1 parent 034902c commit ea77b8f
Showing 1 changed file with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -223,9 +223,7 @@ func Test_tracesamplerprocessor_SamplingPercentageRange_MultipleResourceSpans(t
func Test_tracesamplerprocessor_SpanSamplingPriority(t *testing.T) {
singleSpanWithAttrib := func(key string, attribValue pdata.AttributeValue) pdata.Traces {
traces := pdata.NewTraces()
rs := traces.ResourceSpans().AppendEmpty()
instrLibrarySpans := rs.InstrumentationLibrarySpans().AppendEmpty()
instrLibrarySpans.Spans().Append(getSpanWithAttributes(key, attribValue))
initSpanWithAttributes(key, attribValue, traces.ResourceSpans().AppendEmpty().InstrumentationLibrarySpans().AppendEmpty().Spans().AppendEmpty())
return traces
}
tests := []struct {
Expand Down Expand Up @@ -410,11 +408,15 @@ func Test_parseSpanSamplingPriority(t *testing.T) {

func getSpanWithAttributes(key string, value pdata.AttributeValue) pdata.Span {
span := pdata.NewSpan()
span.SetName("spanName")
span.Attributes().InitFromMap(map[string]pdata.AttributeValue{key: value})
initSpanWithAttributes(key, value, span)
return span
}

func initSpanWithAttributes(key string, value pdata.AttributeValue, dest pdata.Span) {
dest.SetName("spanName")
dest.Attributes().InitFromMap(map[string]pdata.AttributeValue{key: value})
}

// Test_hash ensures that the hash function supports different key lengths even if in
// practice it is only expected to receive keys with length 16 (trace id length in OC proto).
func Test_hash(t *testing.T) {
Expand Down

0 comments on commit ea77b8f

Please sign in to comment.