Skip to content

Commit

Permalink
[chore] Use upstream functions for testing
Browse files Browse the repository at this point in the history
Signed-off-by: odubajDT <[email protected]>
  • Loading branch information
odubajDT committed Dec 9, 2024
1 parent 426a67d commit 76d9866
Show file tree
Hide file tree
Showing 20 changed files with 100 additions and 380 deletions.
12 changes: 10 additions & 2 deletions internal/testbed/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@ go 1.23.3
require (
github.com/Dynatrace/dynatrace-otel-collector/internal/testcommon v0.0.0
github.com/google/uuid v1.6.0
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/core/idutils v0.0.0
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/k8stest v0.0.0
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatatest v0.114.0
github.com/open-telemetry/opentelemetry-collector-contrib/testbed v0.114.0
github.com/stretchr/testify v1.10.0
go.opentelemetry.io/collector/component v0.114.0
go.opentelemetry.io/collector/consumer v0.114.0
go.opentelemetry.io/collector/consumer/consumertest v0.114.0
go.opentelemetry.io/collector/pdata v1.20.0
go.opentelemetry.io/collector/pdata v1.21.0
go.opentelemetry.io/collector/semconv v0.114.0
golang.org/x/exp v0.0.0-20241204233417-43b7b7cde48d
gopkg.in/yaml.v3 v3.0.1
Expand Down Expand Up @@ -237,7 +239,7 @@ require (
google.golang.org/genproto/googleapis/api v0.0.0-20241104194629-dd2ea8efbc28 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20241104194629-dd2ea8efbc28 // indirect
google.golang.org/grpc v1.67.1 // indirect
google.golang.org/protobuf v1.35.1 // indirect
google.golang.org/protobuf v1.35.2 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
k8s.io/api v0.31.3 // indirect
Expand All @@ -255,3 +257,9 @@ require (
replace cloud.google.com/go => cloud.google.com/go v0.116.0

replace github.com/Dynatrace/dynatrace-otel-collector/internal/testcommon v0.0.0 => ../testcommon

replace go.opentelemetry.io/collector/pdata => go.opentelemetry.io/collector/pdata v1.20.0

replace github.com/open-telemetry/opentelemetry-collector-contrib/pkg/k8stest => github.com/odubajdt/opentelemetry-collector-contrib/pkg/k8stest v0.0.0-20241204065521-e8229166c49e

replace github.com/open-telemetry/opentelemetry-collector-contrib/pkg/core/idutils => github.com/odubajdt/opentelemetry-collector-contrib/pkg/core/idutils v0.0.0-20241209065856-0d90d3626d49
8 changes: 6 additions & 2 deletions internal/testbed/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -2636,6 +2636,10 @@ github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ=
github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f h1:KUppIJq7/+SVif2QVs3tOP0zanoHgBEVAwHxUSIzRqU=
github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
github.com/odubajdt/opentelemetry-collector-contrib/pkg/core/idutils v0.0.0-20241209065856-0d90d3626d49 h1:l4SG1DZRiBHdTUF7ftvFfY4e0ykoF7aaO3F3BOFeydo=
github.com/odubajdt/opentelemetry-collector-contrib/pkg/core/idutils v0.0.0-20241209065856-0d90d3626d49/go.mod h1:Tzo5qNzpdYthoH2DhCiwShPbFLzIVS9/ZVMwW64lg+g=
github.com/odubajdt/opentelemetry-collector-contrib/pkg/k8stest v0.0.0-20241204065521-e8229166c49e h1:jy3HcXCjQq9pT9rRAesI3gYOB0Tidz8F0w2nVjvFy4U=
github.com/odubajdt/opentelemetry-collector-contrib/pkg/k8stest v0.0.0-20241204065521-e8229166c49e/go.mod h1:YTEb5fOk4yWbRPaijdzL4xlCO6Cbnpv1EGmiKaMtDLs=
github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE=
github.com/onsi/ginkgo/v2 v2.19.0 h1:9Cnnf7UHo57Hy3k6/m5k3dRfGTMXGvxhHFvkDTCTpvA=
github.com/onsi/ginkgo/v2 v2.19.0/go.mod h1:rlwLi9PilAFJ8jCg9UE1QP6VBpd6/xj3SRC0d6TU0To=
Expand Down Expand Up @@ -3931,8 +3935,8 @@ google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHh
google.golang.org/protobuf v1.34.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
google.golang.org/protobuf v1.34.1/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw=
google.golang.org/protobuf v1.35.1 h1:m3LfL6/Ca+fqnjnlqQXNpFPABW1UD7mjh8KO2mKFytA=
google.golang.org/protobuf v1.35.1/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
google.golang.org/protobuf v1.35.2 h1:8Ar7bF+apOIoThw1EdZl0p1oWvMqTHmpA2fRTyZO8io=
google.golang.org/protobuf v1.35.2/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
Expand Down
19 changes: 10 additions & 9 deletions internal/testbed/integration/combinedload/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,27 @@ import (
"github.com/Dynatrace/dynatrace-otel-collector/internal/testcommon/k8stest"
oteltest "github.com/Dynatrace/dynatrace-otel-collector/internal/testcommon/oteltest"
"github.com/google/uuid"
otelk8stest "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/k8stest"
"github.com/stretchr/testify/require"
"go.opentelemetry.io/collector/consumer/consumertest"
)

func TestLoad_Combined(t *testing.T) {
testDir := filepath.Join("testdata")

k8sClient, err := k8stest.NewK8sClient()
k8sClient, err := otelk8stest.NewK8sClient(k8stest.TestKubeConfig)
require.NoError(t, err)

// Create the namespace specific for the test
nsFile := filepath.Join(testDir, "namespace.yaml")
buf, err := os.ReadFile(nsFile)
require.NoErrorf(t, err, "failed to read namespace object file %s", nsFile)
nsObj, err := k8stest.CreateObject(k8sClient, buf)
nsObj, err := otelk8stest.CreateObject(k8sClient, buf)
require.NoErrorf(t, err, "failed to create k8s namespace from file %s", nsFile)

testNs := nsObj.GetName()
defer func() {
require.NoErrorf(t, k8stest.DeleteObject(k8sClient, nsObj), "failed to delete namespace %s", testNs)
require.NoErrorf(t, otelk8stest.DeleteObject(k8sClient, nsObj), "failed to delete namespace %s", testNs)
}()

tracesConsumer := new(consumertest.TracesSink)
Expand Down Expand Up @@ -70,7 +71,7 @@ func TestLoad_Combined(t *testing.T) {

// start up metrics-server
t.Log("deploying metrics-server...")
err = k8stest.PerformOperationOnYAMLFiles(k8sClient, filepath.Join(testDir, "metrics-server"), k8stest.CreateObject)
err = k8stest.PerformOperationOnYAMLFiles(k8sClient, filepath.Join(testDir, "metrics-server"), otelk8stest.CreateObject)
require.NoErrorf(t, err, "failed to create k8s metrics server")

defer func() {
Expand All @@ -88,24 +89,24 @@ func TestLoad_Combined(t *testing.T) {
require.NoError(t, err)

testID := uuid.NewString()[:8]
collectorObjs := k8stest.CreateCollectorObjects(t, k8sClient, testID, filepath.Join(testDir, "collector"), "")
collectorObjs := otelk8stest.CreateCollectorObjects(t, k8sClient, testID, filepath.Join(testDir, "collector"))

createTeleOpts := &k8stest.TelemetrygenCreateOpts{
createTeleOpts := &otelk8stest.TelemetrygenCreateOpts{
ManifestsDir: filepath.Join(testDir, "telemetrygen"),
TestID: testID,
OtlpEndpoint: fmt.Sprintf("otelcol-%s.%s:4317", testID, testNs),
DataTypes: []string{""},
}

telemetryGenObjs, telemetryGenObjInfos := k8stest.CreateTelemetryGenObjects(t, k8sClient, createTeleOpts)
telemetryGenObjs, telemetryGenObjInfos := otelk8stest.CreateTelemetryGenObjects(t, k8sClient, createTeleOpts)
defer func() {
for _, obj := range append(collectorObjs, telemetryGenObjs...) {
require.NoErrorf(t, k8stest.DeleteObject(k8sClient, obj), "failed to delete object %s", obj.GetName())
require.NoErrorf(t, otelk8stest.DeleteObject(k8sClient, obj), "failed to delete object %s", obj.GetName())
}
}()

for _, info := range telemetryGenObjInfos {
k8stest.WaitForTelemetryGenToStart(t, k8sClient, info.Namespace, info.PodLabelSelectors, info.Workload, info.DataType)
otelk8stest.WaitForTelemetryGenToStart(t, k8sClient, info.Namespace, info.PodLabelSelectors, info.Workload, info.DataType)
}

otelColPodName, err := k8stest.GetPodNameByLabels(k8sClient.DynamicClient, testNs, map[string]string{
Expand Down
2 changes: 1 addition & 1 deletion internal/testbed/integration/config_examples_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ import (
"go.opentelemetry.io/collector/pdata/ptrace"
semconv "go.opentelemetry.io/collector/semconv/v1.18.0"

"github.com/Dynatrace/dynatrace-otel-collector/internal/testcommon/idutils"
"github.com/Dynatrace/dynatrace-otel-collector/internal/testcommon/testutil"
"github.com/open-telemetry/opentelemetry-collector-contrib/pkg/core/idutils"
)

func TestConfigTailSampling(t *testing.T) {
Expand Down
15 changes: 8 additions & 7 deletions internal/testbed/integration/k8senrichment/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/Dynatrace/dynatrace-otel-collector/internal/testcommon/k8stest"
oteltest "github.com/Dynatrace/dynatrace-otel-collector/internal/testcommon/oteltest"
"github.com/google/uuid"
otelk8stest "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/k8stest"
"github.com/stretchr/testify/require"
"go.opentelemetry.io/collector/consumer/consumertest"
)
Expand All @@ -34,19 +35,19 @@ func TestE2E_ClusterRBAC(t *testing.T) {
testDir := filepath.Join("testdata")
configExamplesDir := "../../../../config_examples"

k8sClient, err := k8stest.NewK8sClient()
k8sClient, err := otelk8stest.NewK8sClient(k8stest.TestKubeConfig)
require.NoError(t, err)

// Create the namespace specific for the test
nsFile := filepath.Join(testDir, "namespace.yaml")
buf, err := os.ReadFile(nsFile)
require.NoErrorf(t, err, "failed to read namespace object file %s", nsFile)
nsObj, err := k8stest.CreateObject(k8sClient, buf)
nsObj, err := otelk8stest.CreateObject(k8sClient, buf)
require.NoErrorf(t, err, "failed to create k8s namespace from file %s", nsFile)

testNs := nsObj.GetName()
defer func() {
require.NoErrorf(t, k8stest.DeleteObject(k8sClient, nsObj), "failed to delete namespace %s", testNs)
require.NoErrorf(t, otelk8stest.DeleteObject(k8sClient, nsObj), "failed to delete namespace %s", testNs)
}()

tracesConsumer := new(consumertest.TracesSink)
Expand All @@ -68,21 +69,21 @@ func TestE2E_ClusterRBAC(t *testing.T) {
"k8s_enrichment.yaml",
),
)
createTeleOpts := &k8stest.TelemetrygenCreateOpts{
createTeleOpts := &otelk8stest.TelemetrygenCreateOpts{
ManifestsDir: filepath.Join(testDir, "telemetrygen"),
TestID: testID,
OtlpEndpoint: fmt.Sprintf("otelcol-%s.%s:4317", testID, testNs),
DataTypes: []string{"traces"},
}
telemetryGenObjs, telemetryGenObjInfos := k8stest.CreateTelemetryGenObjects(t, k8sClient, createTeleOpts)
telemetryGenObjs, telemetryGenObjInfos := otelk8stest.CreateTelemetryGenObjects(t, k8sClient, createTeleOpts)
defer func() {
for _, obj := range append(collectorObjs, telemetryGenObjs...) {
require.NoErrorf(t, k8stest.DeleteObject(k8sClient, obj), "failed to delete object %s", obj.GetName())
require.NoErrorf(t, otelk8stest.DeleteObject(k8sClient, obj), "failed to delete object %s", obj.GetName())
}
}()

for _, info := range telemetryGenObjInfos {
k8stest.WaitForTelemetryGenToStart(t, k8sClient, info.Namespace, info.PodLabelSelectors, info.Workload, info.DataType)
otelk8stest.WaitForTelemetryGenToStart(t, k8sClient, info.Namespace, info.PodLabelSelectors, info.Workload, info.DataType)
}

wantEntries := 30 // Minimal number of traces to wait for.
Expand Down
9 changes: 5 additions & 4 deletions internal/testbed/integration/prometheus/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/Dynatrace/dynatrace-otel-collector/internal/testcommon/k8stest"
oteltest "github.com/Dynatrace/dynatrace-otel-collector/internal/testcommon/oteltest"
"github.com/google/uuid"
otelk8stest "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/k8stest"
"github.com/stretchr/testify/require"
"go.opentelemetry.io/collector/consumer/consumertest"
)
Expand All @@ -22,19 +23,19 @@ func TestE2E_PrometheusNodeExporter(t *testing.T) {
testDir := filepath.Join("testdata")
configExamplesDir := "../../../../config_examples"

k8sClient, err := k8stest.NewK8sClient()
k8sClient, err := otelk8stest.NewK8sClient(k8stest.TestKubeConfig)
require.NoError(t, err)

// Create the namespace specific for the test
nsFile := filepath.Join(testDir, "namespace.yaml")
buf, err := os.ReadFile(nsFile)
require.NoErrorf(t, err, "failed to read namespace object file %s", nsFile)
nsObj, err := k8stest.CreateObject(k8sClient, buf)
nsObj, err := otelk8stest.CreateObject(k8sClient, buf)
require.NoErrorf(t, err, "failed to create k8s namespace from file %s", nsFile)

testNs := nsObj.GetName()
defer func() {
require.NoErrorf(t, k8stest.DeleteObject(k8sClient, nsObj), "failed to delete namespace %s", testNs)
require.NoErrorf(t, otelk8stest.DeleteObject(k8sClient, nsObj), "failed to delete namespace %s", testNs)
}()

// Install Prometheus Node exporter
Expand All @@ -59,7 +60,7 @@ func TestE2E_PrometheusNodeExporter(t *testing.T) {
)
defer func() {
for _, obj := range collectorObjs {
require.NoErrorf(t, k8stest.DeleteObject(k8sClient, obj), "failed to delete object %s", obj.GetName())
require.NoErrorf(t, otelk8stest.DeleteObject(k8sClient, obj), "failed to delete object %s", obj.GetName())
}
}()

Expand Down
15 changes: 8 additions & 7 deletions internal/testbed/integration/redaction/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/Dynatrace/dynatrace-otel-collector/internal/testcommon/k8stest"
oteltest "github.com/Dynatrace/dynatrace-otel-collector/internal/testcommon/oteltest"
"github.com/google/uuid"
otelk8stest "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/k8stest"
"github.com/stretchr/testify/require"
"go.opentelemetry.io/collector/consumer/consumertest"
)
Expand All @@ -19,19 +20,19 @@ func TestE2E_RedactionProcessor(t *testing.T) {
testDir := filepath.Join("testdata")
configExamplesDir := "../../../../config_examples"

k8sClient, err := k8stest.NewK8sClient()
k8sClient, err := otelk8stest.NewK8sClient(k8stest.TestKubeConfig)
require.NoError(t, err)

// Create the namespace specific for the test
nsFile := filepath.Join(testDir, "namespace.yaml")
buf, err := os.ReadFile(nsFile)
require.NoErrorf(t, err, "failed to read namespace object file %s", nsFile)
nsObj, err := k8stest.CreateObject(k8sClient, buf)
nsObj, err := otelk8stest.CreateObject(k8sClient, buf)
require.NoErrorf(t, err, "failed to create k8s namespace from file %s", nsFile)

testNs := nsObj.GetName()
defer func() {
require.NoErrorf(t, k8stest.DeleteObject(k8sClient, nsObj), "failed to delete namespace %s", testNs)
require.NoErrorf(t, otelk8stest.DeleteObject(k8sClient, nsObj), "failed to delete namespace %s", testNs)
}()

tracesConsumer := new(consumertest.TracesSink)
Expand All @@ -51,21 +52,21 @@ func TestE2E_RedactionProcessor(t *testing.T) {
filepath.Join(configExamplesDir, "k8s_attribute_redaction.yaml"),
)

createTeleOpts := &k8stest.TelemetrygenCreateOpts{
createTeleOpts := &otelk8stest.TelemetrygenCreateOpts{
ManifestsDir: filepath.Join(testDir, "telemetrygen"),
TestID: testID,
OtlpEndpoint: fmt.Sprintf("otelcol-%s.%s:4317", testID, testNs),
DataTypes: []string{"traces"},
}
telemetryGenObjs, telemetryGenObjInfos := k8stest.CreateTelemetryGenObjects(t, k8sClient, createTeleOpts)
telemetryGenObjs, telemetryGenObjInfos := otelk8stest.CreateTelemetryGenObjects(t, k8sClient, createTeleOpts)
defer func() {
for _, obj := range append(collectorObjs, telemetryGenObjs...) {
require.NoErrorf(t, k8stest.DeleteObject(k8sClient, obj), "failed to delete object %s", obj.GetName())
require.NoErrorf(t, otelk8stest.DeleteObject(k8sClient, obj), "failed to delete object %s", obj.GetName())
}
}()

for _, info := range telemetryGenObjInfos {
k8stest.WaitForTelemetryGenToStart(t, k8sClient, info.Namespace, info.PodLabelSelectors, info.Workload, info.DataType)
otelk8stest.WaitForTelemetryGenToStart(t, k8sClient, info.Namespace, info.PodLabelSelectors, info.Workload, info.DataType)
}

wantEntries := 30 // Minimal number of traces to wait for.
Expand Down
11 changes: 6 additions & 5 deletions internal/testbed/integration/statsd/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (

"github.com/Dynatrace/dynatrace-otel-collector/internal/testcommon/k8stest"
"github.com/Dynatrace/dynatrace-otel-collector/internal/testcommon/oteltest"
otelk8stest "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/k8stest"
)

// TestE2E_StatsdReceiver tests the "Ingest data from Statsd" use case
Expand All @@ -25,19 +26,19 @@ func TestE2E_StatsdReceiver(t *testing.T) {
testDir := filepath.Join("testdata")
configExamplesDir := "../../../../config_examples"

k8sClient, err := k8stest.NewK8sClient()
k8sClient, err := otelk8stest.NewK8sClient(k8stest.TestKubeConfig)
require.NoError(t, err)

// Create the namespace specific for the test
nsFile := filepath.Join(testDir, "namespace.yaml")
buf, err := os.ReadFile(nsFile)
require.NoErrorf(t, err, "failed to read namespace object file %s", nsFile)
nsObj, err := k8stest.CreateObject(k8sClient, buf)
nsObj, err := otelk8stest.CreateObject(k8sClient, buf)
require.NoErrorf(t, err, "failed to create k8s namespace from file %s", nsFile)

testNs := nsObj.GetName()
defer func() {
require.NoErrorf(t, k8stest.DeleteObject(k8sClient, nsObj), "failed to delete namespace %s", testNs)
require.NoErrorf(t, otelk8stest.DeleteObject(k8sClient, nsObj), "failed to delete namespace %s", testNs)
}()

metricsConsumer := new(consumertest.MetricsSink)
Expand Down Expand Up @@ -65,12 +66,12 @@ func TestE2E_StatsdReceiver(t *testing.T) {
jobFile := filepath.Join(testDir, "statsd", "job.yaml")
buf, err = os.ReadFile(jobFile)
require.NoErrorf(t, err, "failed to read job object file %s", jobFile)
jobObj, err := k8stest.CreateObject(k8sClient, buf)
jobObj, err := otelk8stest.CreateObject(k8sClient, buf)
require.NoErrorf(t, err, "failed to create k8s job from file %s", nsFile)

defer func() {
for _, obj := range append(collectorObjs, jobObj) {
require.NoErrorf(t, k8stest.DeleteObject(k8sClient, obj), "failed to delete object %s", obj.GetName())
require.NoErrorf(t, otelk8stest.DeleteObject(k8sClient, obj), "failed to delete object %s", obj.GetName())
}
}()

Expand Down
12 changes: 8 additions & 4 deletions internal/testbed/integration/trace_validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import (
"github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatatest/ptracetest"
"github.com/stretchr/testify/require"

"github.com/Dynatrace/dynatrace-otel-collector/internal/testcommon/idutils"
"github.com/open-telemetry/opentelemetry-collector-contrib/testbed/testbed"
"go.opentelemetry.io/collector/pdata/pcommon"
"go.opentelemetry.io/collector/pdata/ptrace"
)

Expand Down Expand Up @@ -61,10 +61,10 @@ func assertExpectedSpansAreInReceived(t *testing.T, expected, actual []ptrace.Tr
recdSpan := spans.At(k)
require.Contains(t,
expectedMap,
idutils.TraceIDAndSpanIDToString(recdSpan.TraceID(), recdSpan.SpanID()),
traceIDAndSpanIDToString(recdSpan.TraceID(), recdSpan.SpanID()),
fmt.Sprintf("Span with ID: %q not found among expected spans", recdSpan.SpanID()))

err := ptracetest.CompareTraces(expectedMap[idutils.TraceIDAndSpanIDToString(recdSpan.TraceID(), recdSpan.SpanID())],
err := ptracetest.CompareTraces(expectedMap[traceIDAndSpanIDToString(recdSpan.TraceID(), recdSpan.SpanID())],
td,
ptracetest.IgnoreSpansOrder(),
ptracetest.IgnoreEndTimestamp(),
Expand Down Expand Up @@ -98,10 +98,14 @@ func populateSpansMap(expectedMap map[string]ptrace.Traces, tds []ptrace.Traces)
spans := ilss.At(j).Spans()
for k := 0; k < spans.Len(); k++ {
span := spans.At(k)
key := idutils.TraceIDAndSpanIDToString(span.TraceID(), span.SpanID())
key := traceIDAndSpanIDToString(span.TraceID(), span.SpanID())
expectedMap[key] = td
}
}
}
}
}

func traceIDAndSpanIDToString(traceID pcommon.TraceID, spanID pcommon.SpanID) string {
return fmt.Sprintf("%s-%s", traceID.String(), spanID.String())
}
Loading

0 comments on commit 76d9866

Please sign in to comment.