diff --git a/connector/routingconnector/internal/plogutil/logs_test.go b/connector/routingconnector/internal/plogutil/logs_test.go index 56637d3f9a28..b428e2e8583e 100644 --- a/connector/routingconnector/internal/plogutil/logs_test.go +++ b/connector/routingconnector/internal/plogutil/logs_test.go @@ -63,7 +63,7 @@ func TestMoveResourcesIf(t *testing.T) { from: plogutiltest.NewLogs("AB", "CD", "EF"), to: plogutiltest.NewLogs("1", "2", "3"), expectFrom: plogutiltest.NewLogs("A", "CD", "EF"), - expectTo: plogutiltest.New( + expectTo: plogutiltest.NewLogsFromOpts( plogutiltest.Resource("1", plogutiltest.Scope("2", plogutiltest.LogRecord("3")), ), @@ -132,7 +132,7 @@ func TestMoveRecordsWithContextIf(t *testing.T) { }, from: plogutiltest.NewLogs("AB", "CD", "EF"), to: plog.NewLogs(), - expectFrom: plogutiltest.New( + expectFrom: plogutiltest.NewLogsFromOpts( plogutiltest.Resource("A", plogutiltest.Scope("C", plogutiltest.LogRecord("E"), plogutiltest.LogRecord("F")), plogutiltest.Scope("D", plogutiltest.LogRecord("E"), plogutiltest.LogRecord("F")), @@ -161,7 +161,7 @@ func TestMoveRecordsWithContextIf(t *testing.T) { }, from: plogutiltest.NewLogs("AB", "CD", "EF"), to: plog.NewLogs(), - expectFrom: plogutiltest.New( + expectFrom: plogutiltest.NewLogsFromOpts( plogutiltest.Resource("A", plogutiltest.Scope("C", plogutiltest.LogRecord("E"), plogutiltest.LogRecord("F")), plogutiltest.Scope("D", plogutiltest.LogRecord("E")), @@ -191,7 +191,7 @@ func TestMoveRecordsWithContextIf(t *testing.T) { }, from: plogutiltest.NewLogs("AB", "CD", "EF"), to: plog.NewLogs(), - expectFrom: plogutiltest.New( + expectFrom: plogutiltest.NewLogsFromOpts( plogutiltest.Resource("A", plogutiltest.Scope("C", plogutiltest.LogRecord("E"), plogutiltest.LogRecord("F")), plogutiltest.Scope("D", plogutiltest.LogRecord("E"), plogutiltest.LogRecord("F")), @@ -211,7 +211,7 @@ func TestMoveRecordsWithContextIf(t *testing.T) { from: plogutiltest.NewLogs("AB", "CD", "EF"), to: plogutiltest.NewLogs("1", "2", "3"), expectFrom: plogutiltest.NewLogs("AB", "C", "EF"), - expectTo: plogutiltest.New( + expectTo: plogutiltest.NewLogsFromOpts( plogutiltest.Resource("1", plogutiltest.Scope("2", plogutiltest.LogRecord("3")), ), diff --git a/connector/routingconnector/internal/plogutiltest/logs.go b/connector/routingconnector/internal/plogutiltest/logs.go index 675d5ad3eb85..81bd5761a3b2 100644 --- a/connector/routingconnector/internal/plogutiltest/logs.go +++ b/connector/routingconnector/internal/plogutiltest/logs.go @@ -37,7 +37,7 @@ func NewLogs(resourceIDs, scopeIDs, logRecordIDs string) plog.Logs { return ld } -func New(resources ...plog.ResourceLogs) plog.Logs { +func NewLogsFromOpts(resources ...plog.ResourceLogs) plog.Logs { ld := plog.NewLogs() for _, resource := range resources { resource.CopyTo(ld.ResourceLogs().AppendEmpty()) diff --git a/connector/routingconnector/internal/plogutiltest/logs_test.go b/connector/routingconnector/internal/plogutiltest/logs_test.go index 0f9d0de631aa..c00cef21bec4 100644 --- a/connector/routingconnector/internal/plogutiltest/logs_test.go +++ b/connector/routingconnector/internal/plogutiltest/logs_test.go @@ -17,7 +17,7 @@ func TestNewLogs(t *testing.T) { t.Run("empty", func(t *testing.T) { expected := plog.NewLogs() assert.NoError(t, plogtest.CompareLogs(expected, plogutiltest.NewLogs("", "", ""))) - assert.NoError(t, plogtest.CompareLogs(expected, plogutiltest.New())) + assert.NoError(t, plogtest.CompareLogs(expected, plogutiltest.NewLogsFromOpts())) }) t.Run("simple", func(t *testing.T) { @@ -32,7 +32,7 @@ func TestNewLogs(t *testing.T) { return ld }() assert.NoError(t, plogtest.CompareLogs(expected, plogutiltest.NewLogs("A", "B", "C"))) - assert.NoError(t, plogtest.CompareLogs(expected, plogutiltest.New( + assert.NoError(t, plogtest.CompareLogs(expected, plogutiltest.NewLogsFromOpts( plogutiltest.Resource("A", plogutiltest.Scope("B", plogutiltest.LogRecord("C"))), ))) }) @@ -55,7 +55,7 @@ func TestNewLogs(t *testing.T) { return ld }() assert.NoError(t, plogtest.CompareLogs(expected, plogutiltest.NewLogs("AB", "C", "D"))) - assert.NoError(t, plogtest.CompareLogs(expected, plogutiltest.New( + assert.NoError(t, plogtest.CompareLogs(expected, plogutiltest.NewLogsFromOpts( plogutiltest.Resource("A", plogutiltest.Scope("C", plogutiltest.LogRecord("D"))), plogutiltest.Resource("B", plogutiltest.Scope("C", plogutiltest.LogRecord("D"))), ))) @@ -77,7 +77,7 @@ func TestNewLogs(t *testing.T) { return ld }() assert.NoError(t, plogtest.CompareLogs(expected, plogutiltest.NewLogs("A", "BC", "D"))) - assert.NoError(t, plogtest.CompareLogs(expected, plogutiltest.New( + assert.NoError(t, plogtest.CompareLogs(expected, plogutiltest.NewLogsFromOpts( plogutiltest.Resource("A", plogutiltest.Scope("B", plogutiltest.LogRecord("D")), plogutiltest.Scope("C", plogutiltest.LogRecord("D")), @@ -99,7 +99,7 @@ func TestNewLogs(t *testing.T) { return ld }() assert.NoError(t, plogtest.CompareLogs(expected, plogutiltest.NewLogs("A", "B", "CD"))) - assert.NoError(t, plogtest.CompareLogs(expected, plogutiltest.New( + assert.NoError(t, plogtest.CompareLogs(expected, plogutiltest.NewLogsFromOpts( plogutiltest.Resource("A", plogutiltest.Scope("B", plogutiltest.LogRecord("C"), plogutiltest.LogRecord("D"))), ))) }) @@ -127,7 +127,7 @@ func TestNewLogs(t *testing.T) { l.Body().SetStr("logG") // resourceB.scopeD.logG return ld }() - assert.NoError(t, plogtest.CompareLogs(expected, plogutiltest.New( + assert.NoError(t, plogtest.CompareLogs(expected, plogutiltest.NewLogsFromOpts( plogutiltest.Resource("A", plogutiltest.Scope("C", plogutiltest.LogRecord("E")), plogutiltest.Scope("D", plogutiltest.LogRecord("E")), diff --git a/connector/routingconnector/internal/pmetricutiltest/metrics.go b/connector/routingconnector/internal/pmetricutiltest/metrics.go index 18b59eb29cf8..fb1902759e70 100644 --- a/connector/routingconnector/internal/pmetricutiltest/metrics.go +++ b/connector/routingconnector/internal/pmetricutiltest/metrics.go @@ -5,7 +5,7 @@ package pmetricutiltest // import "github.com/open-telemetry/opentelemetry-colle import "go.opentelemetry.io/collector/pdata/pmetric" -// TestMetrics returns a pmetric.Metrics with a uniform structure where resources, scopes, metrics, +// NewMetrics returns a pmetric.Metrics with a uniform structure where resources, scopes, metrics, // and datapoints are identical across all instances, except for one identifying field. // // Identifying fields: @@ -14,7 +14,7 @@ import "go.opentelemetry.io/collector/pdata/pmetric" // - Metrics have a name with a value of "metricN" and a single time series of data points. // - DataPoints have an attribute "dpName" with a value of "dpN". // -// Example: TestMetrics("AB", "XYZ", "MN", "1234") returns: +// Example: NewMetrics("AB", "XYZ", "MN", "1234") returns: // // resourceA, resourceB // each with scopeX, scopeY, scopeZ diff --git a/connector/routingconnector/internal/ptraceutil/traces_test.go b/connector/routingconnector/internal/ptraceutil/traces_test.go index 40d05c5bec8e..9baca4fda0a1 100644 --- a/connector/routingconnector/internal/ptraceutil/traces_test.go +++ b/connector/routingconnector/internal/ptraceutil/traces_test.go @@ -130,12 +130,21 @@ func TestMoveSpansWithContextIf(t *testing.T) { from: ptraceutiltest.NewTraces("AB", "CD", "EF", "GH"), to: ptrace.NewTraces(), expectFrom: ptraceutiltest.NewTracesFromOpts( - ptraceutiltest.WithResource('A', - ptraceutiltest.WithScope('C', ptraceutiltest.WithSpan('E', "GH"), ptraceutiltest.WithSpan('F', "GH")), - ptraceutiltest.WithScope('D', ptraceutiltest.WithSpan('E', "GH"), ptraceutiltest.WithSpan('F', "GH")), + ptraceutiltest.Resource("A", + ptraceutiltest.Scope("C", + ptraceutiltest.Span("E", ptraceutiltest.SpanEvent("G"), ptraceutiltest.SpanEvent("H")), + ptraceutiltest.Span("F", ptraceutiltest.SpanEvent("G"), ptraceutiltest.SpanEvent("H")), + ), + ptraceutiltest.Scope("D", + ptraceutiltest.Span("E", ptraceutiltest.SpanEvent("G"), ptraceutiltest.SpanEvent("H")), + ptraceutiltest.Span("F", ptraceutiltest.SpanEvent("G"), ptraceutiltest.SpanEvent("H")), + ), ), - ptraceutiltest.WithResource('B', - ptraceutiltest.WithScope('D', ptraceutiltest.WithSpan('E', "GH"), ptraceutiltest.WithSpan('F', "GH")), + ptraceutiltest.Resource("B", + ptraceutiltest.Scope("D", + ptraceutiltest.Span("E", ptraceutiltest.SpanEvent("G"), ptraceutiltest.SpanEvent("H")), + ptraceutiltest.Span("F", ptraceutiltest.SpanEvent("G"), ptraceutiltest.SpanEvent("H")), + ), ), ), expectTo: ptraceutiltest.NewTraces("B", "C", "EF", "GH"), @@ -159,13 +168,24 @@ func TestMoveSpansWithContextIf(t *testing.T) { from: ptraceutiltest.NewTraces("AB", "CD", "EF", "GH"), to: ptrace.NewTraces(), expectFrom: ptraceutiltest.NewTracesFromOpts( - ptraceutiltest.WithResource('A', - ptraceutiltest.WithScope('C', ptraceutiltest.WithSpan('E', "GH"), ptraceutiltest.WithSpan('F', "GH")), - ptraceutiltest.WithScope('D', ptraceutiltest.WithSpan('E', "GH")), + ptraceutiltest.Resource("A", + ptraceutiltest.Scope("C", + ptraceutiltest.Span("E", ptraceutiltest.SpanEvent("G"), ptraceutiltest.SpanEvent("H")), + ptraceutiltest.Span("F", ptraceutiltest.SpanEvent("G"), ptraceutiltest.SpanEvent("H")), + ), + ptraceutiltest.Scope("D", + ptraceutiltest.Span("E", ptraceutiltest.SpanEvent("G"), ptraceutiltest.SpanEvent("H")), + ), ), - ptraceutiltest.WithResource('B', - ptraceutiltest.WithScope('C', ptraceutiltest.WithSpan('E', "GH"), ptraceutiltest.WithSpan('F', "GH")), - ptraceutiltest.WithScope('D', ptraceutiltest.WithSpan('E', "GH"), ptraceutiltest.WithSpan('F', "GH")), + ptraceutiltest.Resource("B", + ptraceutiltest.Scope("C", + ptraceutiltest.Span("E", ptraceutiltest.SpanEvent("G"), ptraceutiltest.SpanEvent("H")), + ptraceutiltest.Span("F", ptraceutiltest.SpanEvent("G"), ptraceutiltest.SpanEvent("H")), + ), + ptraceutiltest.Scope("D", + ptraceutiltest.Span("E", ptraceutiltest.SpanEvent("G"), ptraceutiltest.SpanEvent("H")), + ptraceutiltest.Span("F", ptraceutiltest.SpanEvent("G"), ptraceutiltest.SpanEvent("H")), + ), ), ), expectTo: ptraceutiltest.NewTraces("A", "D", "F", "GH"), @@ -189,13 +209,23 @@ func TestMoveSpansWithContextIf(t *testing.T) { from: ptraceutiltest.NewTraces("AB", "CD", "EF", "GH"), to: ptrace.NewTraces(), expectFrom: ptraceutiltest.NewTracesFromOpts( - ptraceutiltest.WithResource('A', - ptraceutiltest.WithScope('C', ptraceutiltest.WithSpan('E', "GH"), ptraceutiltest.WithSpan('F', "GH")), - ptraceutiltest.WithScope('D', ptraceutiltest.WithSpan('E', "GH"), ptraceutiltest.WithSpan('F', "GH")), + ptraceutiltest.Resource("A", + ptraceutiltest.Scope("C", + ptraceutiltest.Span("E", ptraceutiltest.SpanEvent("G"), ptraceutiltest.SpanEvent("H")), + ptraceutiltest.Span("F", ptraceutiltest.SpanEvent("G"), ptraceutiltest.SpanEvent("H")), + ), + ptraceutiltest.Scope("D", + ptraceutiltest.Span("E", ptraceutiltest.SpanEvent("G"), ptraceutiltest.SpanEvent("H")), + ptraceutiltest.Span("F", ptraceutiltest.SpanEvent("G"), ptraceutiltest.SpanEvent("H")), + ), ), - ptraceutiltest.WithResource('B', - ptraceutiltest.WithScope('C', ptraceutiltest.WithSpan('F', "GH")), - ptraceutiltest.WithScope('D', ptraceutiltest.WithSpan('F', "GH")), + ptraceutiltest.Resource("B", + ptraceutiltest.Scope("C", + ptraceutiltest.Span("F", ptraceutiltest.SpanEvent("G"), ptraceutiltest.SpanEvent("H")), + ), + ptraceutiltest.Scope("D", + ptraceutiltest.Span("F", ptraceutiltest.SpanEvent("G"), ptraceutiltest.SpanEvent("H")), + ), ), ), expectTo: ptraceutiltest.NewTraces("B", "CD", "E", "GH"), @@ -209,9 +239,19 @@ func TestMoveSpansWithContextIf(t *testing.T) { to: ptraceutiltest.NewTraces("1", "2", "3", "4"), expectFrom: ptraceutiltest.NewTraces("AB", "C", "EF", "GH"), expectTo: ptraceutiltest.NewTracesFromOpts( - ptraceutiltest.WithResource('1', ptraceutiltest.WithScope('2', ptraceutiltest.WithSpan('3', "4"))), - ptraceutiltest.WithResource('A', ptraceutiltest.WithScope('D', ptraceutiltest.WithSpan('E', "GH"), ptraceutiltest.WithSpan('F', "GH"))), - ptraceutiltest.WithResource('B', ptraceutiltest.WithScope('D', ptraceutiltest.WithSpan('E', "GH"), ptraceutiltest.WithSpan('F', "GH"))), + ptraceutiltest.Resource("1", ptraceutiltest.Scope("2", ptraceutiltest.Span("3", ptraceutiltest.SpanEvent("4")))), + ptraceutiltest.Resource("A", + ptraceutiltest.Scope("D", + ptraceutiltest.Span("E", ptraceutiltest.SpanEvent("G"), ptraceutiltest.SpanEvent("H")), + ptraceutiltest.Span("F", ptraceutiltest.SpanEvent("G"), ptraceutiltest.SpanEvent("H")), + ), + ), + ptraceutiltest.Resource("B", + ptraceutiltest.Scope("D", + ptraceutiltest.Span("E", ptraceutiltest.SpanEvent("G"), ptraceutiltest.SpanEvent("H")), + ptraceutiltest.Span("F", ptraceutiltest.SpanEvent("G"), ptraceutiltest.SpanEvent("H")), + ), + ), ), }, } diff --git a/connector/routingconnector/internal/ptraceutiltest/traces.go b/connector/routingconnector/internal/ptraceutiltest/traces.go index 4317a113e34b..b6d4413cbc2c 100644 --- a/connector/routingconnector/internal/ptraceutiltest/traces.go +++ b/connector/routingconnector/internal/ptraceutiltest/traces.go @@ -43,56 +43,43 @@ func NewTraces(resourceIDs, scopeIDs, spanIDs, spanEventIDs string) ptrace.Trace return td } -type Resource struct { - id byte - scopes []Scope -} - -type Scope struct { - id byte - spans []Span -} - -type Span struct { - id byte - spanEvents string +func NewTracesFromOpts(resources ...ptrace.ResourceSpans) ptrace.Traces { + md := ptrace.NewTraces() + for _, resource := range resources { + resource.CopyTo(md.ResourceSpans().AppendEmpty()) + } + return md } -func WithResource(id byte, scopes ...Scope) Resource { - r := Resource{id: id} - r.scopes = append(r.scopes, scopes...) - return r +func Resource(id string, scopes ...ptrace.ScopeSpans) ptrace.ResourceSpans { + rm := ptrace.NewResourceSpans() + rm.Resource().Attributes().PutStr("resourceName", "resource"+id) + for _, scope := range scopes { + scope.CopyTo(rm.ScopeSpans().AppendEmpty()) + } + return rm } -func WithScope(id byte, spans ...Span) Scope { - s := Scope{id: id} - s.spans = append(s.spans, spans...) +func Scope(id string, spans ...ptrace.Span) ptrace.ScopeSpans { + s := ptrace.NewScopeSpans() + s.Scope().SetName("scope" + id) + for _, span := range spans { + span.CopyTo(s.Spans().AppendEmpty()) + } return s } -func WithSpan(id byte, spanEvents string) Span { - return Span{id: id, spanEvents: spanEvents} +func Span(id string, ses ...ptrace.SpanEvent) ptrace.Span { + m := ptrace.NewSpan() + m.SetName("span" + id) + for _, se := range ses { + se.CopyTo(m.Events().AppendEmpty()) + } + return m } -// NewTracesFromOpts creates a ptrace.Traces with the specified resources, scopes, metrics, -// and data points. The general idea is the same as NewMetrics, but this function allows for -// more flexibility in creating non-uniform structures. -func NewTracesFromOpts(resources ...Resource) ptrace.Traces { - td := ptrace.NewTraces() - for _, resource := range resources { - r := td.ResourceSpans().AppendEmpty() - r.Resource().Attributes().PutStr("resourceName", "resource"+string(resource.id)) - for _, scope := range resource.scopes { - ss := r.ScopeSpans().AppendEmpty() - ss.Scope().SetName("scope" + string(scope.id)) - for _, span := range scope.spans { - s := ss.Spans().AppendEmpty() - s.SetName("span" + string(span.id)) - for i := 0; i < len(span.spanEvents); i++ { - s.Events().AppendEmpty().Attributes().PutStr("spanEventName", "spanEvent"+string(span.spanEvents[i])) - } - } - } - } - return td +func SpanEvent(id string) ptrace.SpanEvent { + dp := ptrace.NewSpanEvent() + dp.Attributes().PutStr("spanEventName", "spanEvent"+id) + return dp } diff --git a/connector/routingconnector/internal/ptraceutiltest/traces_test.go b/connector/routingconnector/internal/ptraceutiltest/traces_test.go index b0bb12690f6d..0c72431638dc 100644 --- a/connector/routingconnector/internal/ptraceutiltest/traces_test.go +++ b/connector/routingconnector/internal/ptraceutiltest/traces_test.go @@ -33,15 +33,10 @@ func TestNewTraces(t *testing.T) { se.Attributes().PutStr("spanEventName", "spanEventD") // resourceA.scopeB.spanC.spanEventD return td }() - fromOpts := ptraceutiltest.NewTracesFromOpts( - ptraceutiltest.WithResource('A', - ptraceutiltest.WithScope('B', - ptraceutiltest.WithSpan('C', "D"), - ), - ), - ) assert.NoError(t, ptracetest.CompareTraces(expected, ptraceutiltest.NewTraces("A", "B", "C", "D"))) - assert.NoError(t, ptracetest.CompareTraces(expected, fromOpts)) + assert.NoError(t, ptracetest.CompareTraces(expected, ptraceutiltest.NewTracesFromOpts( + ptraceutiltest.Resource("A", ptraceutiltest.Scope("B", ptraceutiltest.Span("C", ptraceutiltest.SpanEvent("D")))), + ))) }) t.Run("two_resources", func(t *testing.T) { @@ -65,20 +60,11 @@ func TestNewTraces(t *testing.T) { se.Attributes().PutStr("spanEventName", "spanEventE") // resourceB.scopeC.spanD.spanEventE return td }() - fromOpts := ptraceutiltest.NewTracesFromOpts( - ptraceutiltest.WithResource('A', - ptraceutiltest.WithScope('C', - ptraceutiltest.WithSpan('D', "E"), - ), - ), - ptraceutiltest.WithResource('B', - ptraceutiltest.WithScope('C', - ptraceutiltest.WithSpan('D', "E"), - ), - ), - ) assert.NoError(t, ptracetest.CompareTraces(expected, ptraceutiltest.NewTraces("AB", "C", "D", "E"))) - assert.NoError(t, ptracetest.CompareTraces(expected, fromOpts)) + assert.NoError(t, ptracetest.CompareTraces(expected, ptraceutiltest.NewTracesFromOpts( + ptraceutiltest.Resource("A", ptraceutiltest.Scope("C", ptraceutiltest.Span("D", ptraceutiltest.SpanEvent("E")))), + ptraceutiltest.Resource("B", ptraceutiltest.Scope("C", ptraceutiltest.Span("D", ptraceutiltest.SpanEvent("E")))), + ))) }) t.Run("two_scopes", func(t *testing.T) { @@ -100,18 +86,13 @@ func TestNewTraces(t *testing.T) { se.Attributes().PutStr("spanEventName", "spanEventE") // resourceA.scopeC.spanD.spanEventE return td }() - fromOpts := ptraceutiltest.NewTracesFromOpts( - ptraceutiltest.WithResource('A', - ptraceutiltest.WithScope('B', - ptraceutiltest.WithSpan('D', "E"), - ), - ptraceutiltest.WithScope('C', - ptraceutiltest.WithSpan('D', "E"), - ), - ), - ) assert.NoError(t, ptracetest.CompareTraces(expected, ptraceutiltest.NewTraces("A", "BC", "D", "E"))) - assert.NoError(t, ptracetest.CompareTraces(expected, fromOpts)) + assert.NoError(t, ptracetest.CompareTraces(expected, ptraceutiltest.NewTracesFromOpts( + ptraceutiltest.Resource("A", + ptraceutiltest.Scope("B", ptraceutiltest.Span("D", ptraceutiltest.SpanEvent("E"))), + ptraceutiltest.Scope("C", ptraceutiltest.Span("D", ptraceutiltest.SpanEvent("E"))), + ), + ))) }) t.Run("two_spans", func(t *testing.T) { @@ -131,16 +112,15 @@ func TestNewTraces(t *testing.T) { se.Attributes().PutStr("spanEventName", "spanEventE") // resourceA.scopeB.spanD.spanEventE return td }() - fromOpts := ptraceutiltest.NewTracesFromOpts( - ptraceutiltest.WithResource('A', - ptraceutiltest.WithScope('B', - ptraceutiltest.WithSpan('C', "E"), - ptraceutiltest.WithSpan('D', "E"), + assert.NoError(t, ptracetest.CompareTraces(expected, ptraceutiltest.NewTraces("A", "B", "CD", "E"))) + assert.NoError(t, ptracetest.CompareTraces(expected, ptraceutiltest.NewTracesFromOpts( + ptraceutiltest.Resource("A", + ptraceutiltest.Scope("B", + ptraceutiltest.Span("C", ptraceutiltest.SpanEvent("E")), + ptraceutiltest.Span("D", ptraceutiltest.SpanEvent("E")), ), ), - ) - assert.NoError(t, ptracetest.CompareTraces(expected, ptraceutiltest.NewTraces("A", "B", "CD", "E"))) - assert.NoError(t, ptracetest.CompareTraces(expected, fromOpts)) + ))) }) t.Run("two_spanevents", func(t *testing.T) { @@ -158,14 +138,13 @@ func TestNewTraces(t *testing.T) { se.Attributes().PutStr("spanEventName", "spanEventE") // resourceA.scopeB.spanC.spanEventE return td }() - fromOpts := ptraceutiltest.NewTracesFromOpts( - ptraceutiltest.WithResource('A', - ptraceutiltest.WithScope('B', - ptraceutiltest.WithSpan('C', "DE"), + assert.NoError(t, ptracetest.CompareTraces(expected, ptraceutiltest.NewTraces("A", "B", "C", "DE"))) + assert.NoError(t, ptracetest.CompareTraces(expected, ptraceutiltest.NewTracesFromOpts( + ptraceutiltest.Resource("A", + ptraceutiltest.Scope("B", + ptraceutiltest.Span("C", ptraceutiltest.SpanEvent("D"), ptraceutiltest.SpanEvent("E")), ), ), - ) - assert.NoError(t, ptracetest.CompareTraces(expected, ptraceutiltest.NewTraces("A", "B", "C", "DE"))) - assert.NoError(t, ptracetest.CompareTraces(expected, fromOpts)) + ))) }) } diff --git a/connector/routingconnector/logs_test.go b/connector/routingconnector/logs_test.go index bcad290a28bc..3cf9ca03321a 100644 --- a/connector/routingconnector/logs_test.go +++ b/connector/routingconnector/logs_test.go @@ -811,7 +811,7 @@ func TestLogsConnectorDetailed(t *testing.T) { input: plogutiltest.NewLogs("AB", "CD", "EF"), expectSink0: plogutiltest.NewLogs("B", "D", "EF"), expectSink1: plog.Logs{}, - expectSinkD: plogutiltest.New( + expectSinkD: plogutiltest.NewLogsFromOpts( plogutiltest.Resource("A", plogutiltest.Scope("C", plogutiltest.LogRecord("E"), plogutiltest.LogRecord("F")), plogutiltest.Scope("D", plogutiltest.LogRecord("E"), plogutiltest.LogRecord("F")), diff --git a/connector/routingconnector/traces_test.go b/connector/routingconnector/traces_test.go index 78f7e46f414a..fb597e2a6968 100644 --- a/connector/routingconnector/traces_test.go +++ b/connector/routingconnector/traces_test.go @@ -766,12 +766,21 @@ func TestTracesConnectorDetailed(t *testing.T) { expectSink0: ptraceutiltest.NewTraces("B", "D", "EF", "GH"), expectSink1: ptrace.Traces{}, expectSinkD: ptraceutiltest.NewTracesFromOpts( - ptraceutiltest.WithResource('A', - ptraceutiltest.WithScope('C', ptraceutiltest.WithSpan('E', "GH"), ptraceutiltest.WithSpan('F', "GH")), - ptraceutiltest.WithScope('D', ptraceutiltest.WithSpan('E', "GH"), ptraceutiltest.WithSpan('F', "GH")), + ptraceutiltest.Resource("A", + ptraceutiltest.Scope("C", + ptraceutiltest.Span("E", ptraceutiltest.SpanEvent("G"), ptraceutiltest.SpanEvent("H")), + ptraceutiltest.Span("F", ptraceutiltest.SpanEvent("G"), ptraceutiltest.SpanEvent("H")), + ), + ptraceutiltest.Scope("D", + ptraceutiltest.Span("E", ptraceutiltest.SpanEvent("G"), ptraceutiltest.SpanEvent("H")), + ptraceutiltest.Span("F", ptraceutiltest.SpanEvent("G"), ptraceutiltest.SpanEvent("H")), + ), ), - ptraceutiltest.WithResource('B', - ptraceutiltest.WithScope('C', ptraceutiltest.WithSpan('E', "GH"), ptraceutiltest.WithSpan('F', "GH")), + ptraceutiltest.Resource("B", + ptraceutiltest.Scope("C", + ptraceutiltest.Span("E", ptraceutiltest.SpanEvent("G"), ptraceutiltest.SpanEvent("H")), + ptraceutiltest.Span("F", ptraceutiltest.SpanEvent("G"), ptraceutiltest.SpanEvent("H")), + ), ), ), },