diff --git a/testbed/testbed/data_providers.go b/testbed/testbed/data_providers.go index e4fbd040c5e..9ae5108646b 100644 --- a/testbed/testbed/data_providers.go +++ b/testbed/testbed/data_providers.go @@ -15,7 +15,6 @@ package testbed import ( - "encoding/binary" "log" "os" "path/filepath" @@ -33,6 +32,7 @@ import ( otlpmetricscol "go.opentelemetry.io/collector/internal/data/protogen/collector/metrics/v1" otlptracecol "go.opentelemetry.io/collector/internal/data/protogen/collector/trace/v1" "go.opentelemetry.io/collector/internal/goldendataset" + "go.opentelemetry.io/collector/internal/idutils" ) // DataProvider defines the interface for generators of test data used to drive various end-to-end tests. @@ -86,8 +86,8 @@ func (dp *PerfTestDataProvider) GenerateTraces() (pdata.Traces, bool) { span := spans.At(i) // Create a span. - span.SetTraceID(GenerateSequentialTraceID(traceID)) - span.SetSpanID(GenerateSequentialSpanID(spanID)) + span.SetTraceID(idutils.UInt64ToTraceID(0, traceID)) + span.SetSpanID(idutils.UInt64ToSpanID(spanID)) span.SetName("load-generator-span") span.SetKind(pdata.SpanKindClient) attrs := span.Attributes() @@ -103,18 +103,6 @@ func (dp *PerfTestDataProvider) GenerateTraces() (pdata.Traces, bool) { return traceData, false } -func GenerateSequentialTraceID(id uint64) pdata.TraceID { - var traceID [16]byte - binary.PutUvarint(traceID[:], id) - return pdata.NewTraceID(traceID) -} - -func GenerateSequentialSpanID(id uint64) pdata.SpanID { - var spanID [8]byte - binary.PutUvarint(spanID[:], id) - return pdata.NewSpanID(spanID) -} - func (dp *PerfTestDataProvider) GenerateMetrics() (pdata.Metrics, bool) { // Generate 7 data points per metric. diff --git a/testbed/tests/trace_test.go b/testbed/tests/trace_test.go index 1cf44560b69..22846894451 100644 --- a/testbed/tests/trace_test.go +++ b/testbed/tests/trace_test.go @@ -31,6 +31,7 @@ import ( "go.opentelemetry.io/collector/config" "go.opentelemetry.io/collector/consumer/pdata" + "go.opentelemetry.io/collector/internal/idutils" "go.opentelemetry.io/collector/testbed/testbed" "go.opentelemetry.io/collector/translator/conventions" ) @@ -337,8 +338,8 @@ func verifySingleSpan( conventions.AttributeServiceName: pdata.NewAttributeValueString(serviceName), }) span := rs.InstrumentationLibrarySpans().AppendEmpty().Spans().AppendEmpty() - span.SetTraceID(testbed.GenerateSequentialTraceID(1)) - span.SetSpanID(testbed.GenerateSequentialSpanID(1)) + span.SetTraceID(idutils.UInt64ToTraceID(0, 1)) + span.SetSpanID(idutils.UInt64ToSpanID(1)) span.SetName(spanName) sender := tc.Sender.(testbed.TraceDataSender)