From d024895ee190829cbbdd6f4eaa55bf9858cb9ff5 Mon Sep 17 00:00:00 2001 From: Ziqi Zhao Date: Thu, 26 Jan 2023 13:03:06 +0800 Subject: [PATCH] [pkg/pdatatest] add more test cases for trace Signed-off-by: Ziqi Zhao --- .chloggen/add_test_for_traces.yaml | 16 +++ .../resourcespans-amount-unequal/actual.json | 28 ++++ .../expected.json | 16 +++ .../actual.json | 28 ++++ .../expected.json | 28 ++++ .../scopespans-amount-unequal/actual.json | 30 ++++ .../scopespans-amount-unequal/expected.json | 24 ++++ .../actual.json | 30 ++++ .../expected.json | 30 ++++ .../actual.json | 30 ++++ .../expected.json | 30 ++++ .../actual.json | 46 +++++++ .../expected.json | 36 +++++ .../actual.json | 46 +++++++ .../expected.json | 46 +++++++ .../actual.json | 40 ++++++ .../expected.json | 40 ++++++ .../actual.json | 40 ++++++ .../expected.json | 40 ++++++ .../actual.json | 40 ++++++ .../expected.json | 40 ++++++ .../actual.json | 40 ++++++ .../expected.json | 40 ++++++ .../actual.json | 44 ++++++ .../expected.json | 37 +++++ .../actual.json | 40 ++++++ .../expected.json | 40 ++++++ .../actual.json | 59 ++++++++ .../expected.json | 37 +++++ .../actual.json | 39 ++++++ .../expected.json | 39 ++++++ .../actual.json | 39 ++++++ .../expected.json | 39 ++++++ .../actual.json | 38 +++++ .../expected.json | 38 +++++ .../actual.json | 40 ++++++ .../expected.json | 40 ++++++ .../actual.json | 41 ++++++ .../expected.json | 37 +++++ .../actual.json | 37 +++++ .../expected.json | 37 +++++ .../actual.json | 39 ++++++ .../expected.json | 39 ++++++ pkg/pdatatest/ptracetest/traces.go | 15 +- pkg/pdatatest/ptracetest/traces_test.go | 130 +++++++++++++++++- 45 files changed, 1718 insertions(+), 10 deletions(-) create mode 100644 .chloggen/add_test_for_traces.yaml create mode 100644 pkg/pdatatest/ptracetest/testdata/resourcespans-amount-unequal/actual.json create mode 100644 pkg/pdatatest/ptracetest/testdata/resourcespans-amount-unequal/expected.json create mode 100644 pkg/pdatatest/ptracetest/testdata/resourcespans-attributes-mismatch/actual.json create mode 100644 pkg/pdatatest/ptracetest/testdata/resourcespans-attributes-mismatch/expected.json create mode 100644 pkg/pdatatest/ptracetest/testdata/scopespans-amount-unequal/actual.json create mode 100644 pkg/pdatatest/ptracetest/testdata/scopespans-amount-unequal/expected.json create mode 100644 pkg/pdatatest/ptracetest/testdata/scopespans-scope-name-mismatch/actual.json create mode 100644 pkg/pdatatest/ptracetest/testdata/scopespans-scope-name-mismatch/expected.json create mode 100644 pkg/pdatatest/ptracetest/testdata/scopespans-scope-version-mismatch/actual.json create mode 100644 pkg/pdatatest/ptracetest/testdata/scopespans-scope-version-mismatch/expected.json create mode 100644 pkg/pdatatest/ptracetest/testdata/scopespans-spans-amount-unequal/actual.json create mode 100644 pkg/pdatatest/ptracetest/testdata/scopespans-spans-amount-unequal/expected.json create mode 100644 pkg/pdatatest/ptracetest/testdata/scopespans-spans-attributes-mismatch/actual.json create mode 100644 pkg/pdatatest/ptracetest/testdata/scopespans-spans-attributes-mismatch/expected.json create mode 100644 pkg/pdatatest/ptracetest/testdata/scopespans-spans-droppedattributescount-mismatch/actual.json create mode 100644 pkg/pdatatest/ptracetest/testdata/scopespans-spans-droppedattributescount-mismatch/expected.json create mode 100644 pkg/pdatatest/ptracetest/testdata/scopespans-spans-droppedeventscount-mismatch/actual.json create mode 100644 pkg/pdatatest/ptracetest/testdata/scopespans-spans-droppedeventscount-mismatch/expected.json create mode 100644 pkg/pdatatest/ptracetest/testdata/scopespans-spans-droppedlinkscount-mismatch/actual.json create mode 100644 pkg/pdatatest/ptracetest/testdata/scopespans-spans-droppedlinkscount-mismatch/expected.json create mode 100644 pkg/pdatatest/ptracetest/testdata/scopespans-spans-endtimestamp-mismatch/actual.json create mode 100644 pkg/pdatatest/ptracetest/testdata/scopespans-spans-endtimestamp-mismatch/expected.json create mode 100644 pkg/pdatatest/ptracetest/testdata/scopespans-spans-events-mismatch/actual.json create mode 100644 pkg/pdatatest/ptracetest/testdata/scopespans-spans-events-mismatch/expected.json create mode 100644 pkg/pdatatest/ptracetest/testdata/scopespans-spans-kind-mismatch/actual.json create mode 100644 pkg/pdatatest/ptracetest/testdata/scopespans-spans-kind-mismatch/expected.json create mode 100644 pkg/pdatatest/ptracetest/testdata/scopespans-spans-links-mismatch/actual.json create mode 100644 pkg/pdatatest/ptracetest/testdata/scopespans-spans-links-mismatch/expected.json create mode 100644 pkg/pdatatest/ptracetest/testdata/scopespans-spans-name-mismatch/actual.json create mode 100644 pkg/pdatatest/ptracetest/testdata/scopespans-spans-name-mismatch/expected.json create mode 100644 pkg/pdatatest/ptracetest/testdata/scopespans-spans-parentspanid-mismatch/actual.json create mode 100644 pkg/pdatatest/ptracetest/testdata/scopespans-spans-parentspanid-mismatch/expected.json create mode 100644 pkg/pdatatest/ptracetest/testdata/scopespans-spans-spanid-mismatch/actual.json create mode 100644 pkg/pdatatest/ptracetest/testdata/scopespans-spans-spanid-mismatch/expected.json create mode 100644 pkg/pdatatest/ptracetest/testdata/scopespans-spans-starttimestamp-mismatch/actual.json create mode 100644 pkg/pdatatest/ptracetest/testdata/scopespans-spans-starttimestamp-mismatch/expected.json create mode 100644 pkg/pdatatest/ptracetest/testdata/scopespans-spans-status-mismatch/actual.json create mode 100644 pkg/pdatatest/ptracetest/testdata/scopespans-spans-status-mismatch/expected.json create mode 100644 pkg/pdatatest/ptracetest/testdata/scopespans-spans-traceid-mismatch/actual.json create mode 100644 pkg/pdatatest/ptracetest/testdata/scopespans-spans-traceid-mismatch/expected.json create mode 100644 pkg/pdatatest/ptracetest/testdata/scopespans-spans-tracestate-mismatch/actual.json create mode 100644 pkg/pdatatest/ptracetest/testdata/scopespans-spans-tracestate-mismatch/expected.json diff --git a/.chloggen/add_test_for_traces.yaml b/.chloggen/add_test_for_traces.yaml new file mode 100644 index 000000000000..ac098142deba --- /dev/null +++ b/.chloggen/add_test_for_traces.yaml @@ -0,0 +1,16 @@ +# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' +change_type: enhancement + +# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver) +component: pkg/pdatatest + +# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). +note: Adds more test cases for traces + +# One or more tracking issues related to the change +issues: [18030] + +# (Optional) One or more lines of additional information to render under the primary note. +# These lines will be padded with 2 spaces and then inserted directly into the document. +# Use pipe (|) for multiline entries. +subtext: diff --git a/pkg/pdatatest/ptracetest/testdata/resourcespans-amount-unequal/actual.json b/pkg/pdatatest/ptracetest/testdata/resourcespans-amount-unequal/actual.json new file mode 100644 index 000000000000..afbf1dfdbfb6 --- /dev/null +++ b/pkg/pdatatest/ptracetest/testdata/resourcespans-amount-unequal/actual.json @@ -0,0 +1,28 @@ +{ + "resourceSpans": [ + { + "resource": { + "attributes": [ + { + "key": "host.name", + "value": { + "stringValue": "node1" + } + } + ] + } + }, + { + "resource": { + "attributes": [ + { + "key": "pod.name", + "value": { + "stringValue": "pod2" + } + } + ] + } + } + ] +} diff --git a/pkg/pdatatest/ptracetest/testdata/resourcespans-amount-unequal/expected.json b/pkg/pdatatest/ptracetest/testdata/resourcespans-amount-unequal/expected.json new file mode 100644 index 000000000000..c5eda08df145 --- /dev/null +++ b/pkg/pdatatest/ptracetest/testdata/resourcespans-amount-unequal/expected.json @@ -0,0 +1,16 @@ +{ + "resourceSpans": [ + { + "resource": { + "attributes": [ + { + "key": "host.name", + "value": { + "stringValue": "node1" + } + } + ] + } + } + ] +} diff --git a/pkg/pdatatest/ptracetest/testdata/resourcespans-attributes-mismatch/actual.json b/pkg/pdatatest/ptracetest/testdata/resourcespans-attributes-mismatch/actual.json new file mode 100644 index 000000000000..afbf1dfdbfb6 --- /dev/null +++ b/pkg/pdatatest/ptracetest/testdata/resourcespans-attributes-mismatch/actual.json @@ -0,0 +1,28 @@ +{ + "resourceSpans": [ + { + "resource": { + "attributes": [ + { + "key": "host.name", + "value": { + "stringValue": "node1" + } + } + ] + } + }, + { + "resource": { + "attributes": [ + { + "key": "pod.name", + "value": { + "stringValue": "pod2" + } + } + ] + } + } + ] +} diff --git a/pkg/pdatatest/ptracetest/testdata/resourcespans-attributes-mismatch/expected.json b/pkg/pdatatest/ptracetest/testdata/resourcespans-attributes-mismatch/expected.json new file mode 100644 index 000000000000..4844722a4f01 --- /dev/null +++ b/pkg/pdatatest/ptracetest/testdata/resourcespans-attributes-mismatch/expected.json @@ -0,0 +1,28 @@ +{ + "resourceSpans": [ + { + "resource": { + "attributes": [ + { + "key": "host.name", + "value": { + "stringValue": "node1" + } + } + ] + } + }, + { + "resource": { + "attributes": [ + { + "key": "pod.name", + "value": { + "stringValue": "pod1" + } + } + ] + } + } + ] +} diff --git a/pkg/pdatatest/ptracetest/testdata/scopespans-amount-unequal/actual.json b/pkg/pdatatest/ptracetest/testdata/scopespans-amount-unequal/actual.json new file mode 100644 index 000000000000..b6a61ee6732a --- /dev/null +++ b/pkg/pdatatest/ptracetest/testdata/scopespans-amount-unequal/actual.json @@ -0,0 +1,30 @@ +{ + "resourceSpans": [ + { + "resource": { + "attributes": [ + { + "key": "host.name", + "value": { + "stringValue": "host1" + } + } + ] + }, + "scopeSpans": [ + { + "scope": { + "name": "scope1", + "version": "v0.1.0" + } + }, + { + "scope": { + "name": "scope2", + "version": "v0.1.0" + } + } + ] + } + ] +} diff --git a/pkg/pdatatest/ptracetest/testdata/scopespans-amount-unequal/expected.json b/pkg/pdatatest/ptracetest/testdata/scopespans-amount-unequal/expected.json new file mode 100644 index 000000000000..be7b03eb02c5 --- /dev/null +++ b/pkg/pdatatest/ptracetest/testdata/scopespans-amount-unequal/expected.json @@ -0,0 +1,24 @@ +{ + "resourceSpans": [ + { + "resource": { + "attributes": [ + { + "key": "host.name", + "value": { + "stringValue": "host1" + } + } + ] + }, + "scopeSpans": [ + { + "scope": { + "name": "scope1", + "version": "v0.1.0" + } + } + ] + } + ] +} diff --git a/pkg/pdatatest/ptracetest/testdata/scopespans-scope-name-mismatch/actual.json b/pkg/pdatatest/ptracetest/testdata/scopespans-scope-name-mismatch/actual.json new file mode 100644 index 000000000000..b6a61ee6732a --- /dev/null +++ b/pkg/pdatatest/ptracetest/testdata/scopespans-scope-name-mismatch/actual.json @@ -0,0 +1,30 @@ +{ + "resourceSpans": [ + { + "resource": { + "attributes": [ + { + "key": "host.name", + "value": { + "stringValue": "host1" + } + } + ] + }, + "scopeSpans": [ + { + "scope": { + "name": "scope1", + "version": "v0.1.0" + } + }, + { + "scope": { + "name": "scope2", + "version": "v0.1.0" + } + } + ] + } + ] +} diff --git a/pkg/pdatatest/ptracetest/testdata/scopespans-scope-name-mismatch/expected.json b/pkg/pdatatest/ptracetest/testdata/scopespans-scope-name-mismatch/expected.json new file mode 100644 index 000000000000..0f8368386338 --- /dev/null +++ b/pkg/pdatatest/ptracetest/testdata/scopespans-scope-name-mismatch/expected.json @@ -0,0 +1,30 @@ +{ + "resourceSpans": [ + { + "resource": { + "attributes": [ + { + "key": "host.name", + "value": { + "stringValue": "host1" + } + } + ] + }, + "scopeSpans": [ + { + "scope": { + "name": "scope1", + "version": "v0.1.0" + } + }, + { + "scope": { + "name": "scope3", + "version": "v0.1.0" + } + } + ] + } + ] +} diff --git a/pkg/pdatatest/ptracetest/testdata/scopespans-scope-version-mismatch/actual.json b/pkg/pdatatest/ptracetest/testdata/scopespans-scope-version-mismatch/actual.json new file mode 100644 index 000000000000..b6a61ee6732a --- /dev/null +++ b/pkg/pdatatest/ptracetest/testdata/scopespans-scope-version-mismatch/actual.json @@ -0,0 +1,30 @@ +{ + "resourceSpans": [ + { + "resource": { + "attributes": [ + { + "key": "host.name", + "value": { + "stringValue": "host1" + } + } + ] + }, + "scopeSpans": [ + { + "scope": { + "name": "scope1", + "version": "v0.1.0" + } + }, + { + "scope": { + "name": "scope2", + "version": "v0.1.0" + } + } + ] + } + ] +} diff --git a/pkg/pdatatest/ptracetest/testdata/scopespans-scope-version-mismatch/expected.json b/pkg/pdatatest/ptracetest/testdata/scopespans-scope-version-mismatch/expected.json new file mode 100644 index 000000000000..b8bc71cf79bd --- /dev/null +++ b/pkg/pdatatest/ptracetest/testdata/scopespans-scope-version-mismatch/expected.json @@ -0,0 +1,30 @@ +{ + "resourceSpans": [ + { + "resource": { + "attributes": [ + { + "key": "host.name", + "value": { + "stringValue": "host1" + } + } + ] + }, + "scopeSpans": [ + { + "scope": { + "name": "scope1", + "version": "v0.1.0" + } + }, + { + "scope": { + "name": "scope2", + "version": "v0.2.0" + } + } + ] + } + ] +} diff --git a/pkg/pdatatest/ptracetest/testdata/scopespans-spans-amount-unequal/actual.json b/pkg/pdatatest/ptracetest/testdata/scopespans-spans-amount-unequal/actual.json new file mode 100644 index 000000000000..197d29fc1af5 --- /dev/null +++ b/pkg/pdatatest/ptracetest/testdata/scopespans-spans-amount-unequal/actual.json @@ -0,0 +1,46 @@ +{ + "resourceSpans": [ + { + "resource": { + "attributes": [ + { + "key": "host.name", + "value": { + "stringValue": "node1" + } + } + ] + }, + "scopeSpans": [ + { + "spans": [ + { + "attributes": [ + { + "key": "key1", + "value": { + "stringValue": "value1" + } + } + ] + }, + { + "attributes": [ + { + "key": "key2", + "value": { + "stringValue": "value2" + } + } + ] + } + ], + "scope": { + "name": "collector", + "version": "v0.1.0" + } + } + ] + } + ] +} diff --git a/pkg/pdatatest/ptracetest/testdata/scopespans-spans-amount-unequal/expected.json b/pkg/pdatatest/ptracetest/testdata/scopespans-spans-amount-unequal/expected.json new file mode 100644 index 000000000000..4f52deaae7cb --- /dev/null +++ b/pkg/pdatatest/ptracetest/testdata/scopespans-spans-amount-unequal/expected.json @@ -0,0 +1,36 @@ +{ + "resourceSpans": [ + { + "resource": { + "attributes": [ + { + "key": "host.name", + "value": { + "stringValue": "node1" + } + } + ] + }, + "scopeSpans": [ + { + "spans": [ + { + "attributes": [ + { + "key": "key1", + "value": { + "stringValue": "value1" + } + } + ] + } + ], + "scope": { + "name": "collector", + "version": "v0.1.0" + } + } + ] + } + ] +} diff --git a/pkg/pdatatest/ptracetest/testdata/scopespans-spans-attributes-mismatch/actual.json b/pkg/pdatatest/ptracetest/testdata/scopespans-spans-attributes-mismatch/actual.json new file mode 100644 index 000000000000..197d29fc1af5 --- /dev/null +++ b/pkg/pdatatest/ptracetest/testdata/scopespans-spans-attributes-mismatch/actual.json @@ -0,0 +1,46 @@ +{ + "resourceSpans": [ + { + "resource": { + "attributes": [ + { + "key": "host.name", + "value": { + "stringValue": "node1" + } + } + ] + }, + "scopeSpans": [ + { + "spans": [ + { + "attributes": [ + { + "key": "key1", + "value": { + "stringValue": "value1" + } + } + ] + }, + { + "attributes": [ + { + "key": "key2", + "value": { + "stringValue": "value2" + } + } + ] + } + ], + "scope": { + "name": "collector", + "version": "v0.1.0" + } + } + ] + } + ] +} diff --git a/pkg/pdatatest/ptracetest/testdata/scopespans-spans-attributes-mismatch/expected.json b/pkg/pdatatest/ptracetest/testdata/scopespans-spans-attributes-mismatch/expected.json new file mode 100644 index 000000000000..1d499481030c --- /dev/null +++ b/pkg/pdatatest/ptracetest/testdata/scopespans-spans-attributes-mismatch/expected.json @@ -0,0 +1,46 @@ +{ + "resourceSpans": [ + { + "resource": { + "attributes": [ + { + "key": "host.name", + "value": { + "stringValue": "node1" + } + } + ] + }, + "scopeSpans": [ + { + "spans": [ + { + "attributes": [ + { + "key": "key1", + "value": { + "stringValue": "value1" + } + } + ] + }, + { + "attributes": [ + { + "key": "key2", + "value": { + "stringValue": "value3" + } + } + ] + } + ], + "scope": { + "name": "collector", + "version": "v0.1.0" + } + } + ] + } + ] +} diff --git a/pkg/pdatatest/ptracetest/testdata/scopespans-spans-droppedattributescount-mismatch/actual.json b/pkg/pdatatest/ptracetest/testdata/scopespans-spans-droppedattributescount-mismatch/actual.json new file mode 100644 index 000000000000..2156afedd434 --- /dev/null +++ b/pkg/pdatatest/ptracetest/testdata/scopespans-spans-droppedattributescount-mismatch/actual.json @@ -0,0 +1,40 @@ +{ + "resourceSpans": [ + { + "resource": { + "attributes": [ + { + "key": "host.name", + "value": { + "stringValue": "node1" + } + } + ] + }, + "scopeSpans": [ + { + "spans": [ + { + "attributes": [ + { + "key": "key1", + "value": { + "stringValue": "value1" + } + } + ], + "droppedAttributesCount": 0, + "name": "span1", + "spanId": "fd0da883bb27cd6b", + "traceId": "8c8b1765a7b0acf0b66aa4623fcb7bd5" + } + ], + "scope": { + "name": "collector", + "version": "v0.1.0" + } + } + ] + } + ] +} diff --git a/pkg/pdatatest/ptracetest/testdata/scopespans-spans-droppedattributescount-mismatch/expected.json b/pkg/pdatatest/ptracetest/testdata/scopespans-spans-droppedattributescount-mismatch/expected.json new file mode 100644 index 000000000000..b51af5aba05e --- /dev/null +++ b/pkg/pdatatest/ptracetest/testdata/scopespans-spans-droppedattributescount-mismatch/expected.json @@ -0,0 +1,40 @@ +{ + "resourceSpans": [ + { + "resource": { + "attributes": [ + { + "key": "host.name", + "value": { + "stringValue": "node1" + } + } + ] + }, + "scopeSpans": [ + { + "spans": [ + { + "attributes": [ + { + "key": "key1", + "value": { + "stringValue": "value1" + } + } + ], + "droppedAttributesCount": 1, + "name": "span1", + "spanId": "fd0da883bb27cd6b", + "traceId": "8c8b1765a7b0acf0b66aa4623fcb7bd5" + } + ], + "scope": { + "name": "collector", + "version": "v0.1.0" + } + } + ] + } + ] +} diff --git a/pkg/pdatatest/ptracetest/testdata/scopespans-spans-droppedeventscount-mismatch/actual.json b/pkg/pdatatest/ptracetest/testdata/scopespans-spans-droppedeventscount-mismatch/actual.json new file mode 100644 index 000000000000..d799ad95db7a --- /dev/null +++ b/pkg/pdatatest/ptracetest/testdata/scopespans-spans-droppedeventscount-mismatch/actual.json @@ -0,0 +1,40 @@ +{ + "resourceSpans": [ + { + "resource": { + "attributes": [ + { + "key": "host.name", + "value": { + "stringValue": "node1" + } + } + ] + }, + "scopeSpans": [ + { + "spans": [ + { + "attributes": [ + { + "key": "key1", + "value": { + "stringValue": "value1" + } + } + ], + "droppedEventsCount": 0, + "name": "span1", + "spanId": "fd0da883bb27cd6b", + "traceId": "8c8b1765a7b0acf0b66aa4623fcb7bd5" + } + ], + "scope": { + "name": "collector", + "version": "v0.1.0" + } + } + ] + } + ] +} diff --git a/pkg/pdatatest/ptracetest/testdata/scopespans-spans-droppedeventscount-mismatch/expected.json b/pkg/pdatatest/ptracetest/testdata/scopespans-spans-droppedeventscount-mismatch/expected.json new file mode 100644 index 000000000000..c786894f0ca9 --- /dev/null +++ b/pkg/pdatatest/ptracetest/testdata/scopespans-spans-droppedeventscount-mismatch/expected.json @@ -0,0 +1,40 @@ +{ + "resourceSpans": [ + { + "resource": { + "attributes": [ + { + "key": "host.name", + "value": { + "stringValue": "node1" + } + } + ] + }, + "scopeSpans": [ + { + "spans": [ + { + "attributes": [ + { + "key": "key1", + "value": { + "stringValue": "value1" + } + } + ], + "droppedEventsCount": 1, + "name": "span1", + "spanId": "fd0da883bb27cd6b", + "traceId": "8c8b1765a7b0acf0b66aa4623fcb7bd5" + } + ], + "scope": { + "name": "collector", + "version": "v0.1.0" + } + } + ] + } + ] +} diff --git a/pkg/pdatatest/ptracetest/testdata/scopespans-spans-droppedlinkscount-mismatch/actual.json b/pkg/pdatatest/ptracetest/testdata/scopespans-spans-droppedlinkscount-mismatch/actual.json new file mode 100644 index 000000000000..278cee73e509 --- /dev/null +++ b/pkg/pdatatest/ptracetest/testdata/scopespans-spans-droppedlinkscount-mismatch/actual.json @@ -0,0 +1,40 @@ +{ + "resourceSpans": [ + { + "resource": { + "attributes": [ + { + "key": "host.name", + "value": { + "stringValue": "node1" + } + } + ] + }, + "scopeSpans": [ + { + "spans": [ + { + "attributes": [ + { + "key": "key1", + "value": { + "stringValue": "value1" + } + } + ], + "droppedLinksCount": 0, + "name": "span1", + "spanId": "fd0da883bb27cd6b", + "traceId": "8c8b1765a7b0acf0b66aa4623fcb7bd5" + } + ], + "scope": { + "name": "collector", + "version": "v0.1.0" + } + } + ] + } + ] +} diff --git a/pkg/pdatatest/ptracetest/testdata/scopespans-spans-droppedlinkscount-mismatch/expected.json b/pkg/pdatatest/ptracetest/testdata/scopespans-spans-droppedlinkscount-mismatch/expected.json new file mode 100644 index 000000000000..60c89bf99b8c --- /dev/null +++ b/pkg/pdatatest/ptracetest/testdata/scopespans-spans-droppedlinkscount-mismatch/expected.json @@ -0,0 +1,40 @@ +{ + "resourceSpans": [ + { + "resource": { + "attributes": [ + { + "key": "host.name", + "value": { + "stringValue": "node1" + } + } + ] + }, + "scopeSpans": [ + { + "spans": [ + { + "attributes": [ + { + "key": "key1", + "value": { + "stringValue": "value1" + } + } + ], + "droppedLinksCount": 1, + "name": "span1", + "spanId": "fd0da883bb27cd6b", + "traceId": "8c8b1765a7b0acf0b66aa4623fcb7bd5" + } + ], + "scope": { + "name": "collector", + "version": "v0.1.0" + } + } + ] + } + ] +} diff --git a/pkg/pdatatest/ptracetest/testdata/scopespans-spans-endtimestamp-mismatch/actual.json b/pkg/pdatatest/ptracetest/testdata/scopespans-spans-endtimestamp-mismatch/actual.json new file mode 100644 index 000000000000..0f1b19f6e1b2 --- /dev/null +++ b/pkg/pdatatest/ptracetest/testdata/scopespans-spans-endtimestamp-mismatch/actual.json @@ -0,0 +1,40 @@ +{ + "resourceSpans": [ + { + "resource": { + "attributes": [ + { + "key": "host.name", + "value": { + "stringValue": "node1" + } + } + ] + }, + "scopeSpans": [ + { + "spans": [ + { + "attributes": [ + { + "key": "key1", + "value": { + "stringValue": "value1" + } + } + ], + "name": "span1", + "spanId": "fd0da883bb27cd6b", + "endTimeUnixNano": "11651379494838206464", + "traceId": "8c8b1765a7b0acf0b66aa4623fcb7bd5" + } + ], + "scope": { + "name": "collector", + "version": "v0.1.0" + } + } + ] + } + ] +} diff --git a/pkg/pdatatest/ptracetest/testdata/scopespans-spans-endtimestamp-mismatch/expected.json b/pkg/pdatatest/ptracetest/testdata/scopespans-spans-endtimestamp-mismatch/expected.json new file mode 100644 index 000000000000..e3131e148f9b --- /dev/null +++ b/pkg/pdatatest/ptracetest/testdata/scopespans-spans-endtimestamp-mismatch/expected.json @@ -0,0 +1,40 @@ +{ + "resourceSpans": [ + { + "resource": { + "attributes": [ + { + "key": "host.name", + "value": { + "stringValue": "node1" + } + } + ] + }, + "scopeSpans": [ + { + "spans": [ + { + "attributes": [ + { + "key": "key1", + "value": { + "stringValue": "value1" + } + } + ], + "name": "span1", + "spanId": "fd0da883bb27cd6b", + "endTimeUnixNano": "11651379494838206400", + "traceId": "8c8b1765a7b0acf0b66aa4623fcb7bd5" + } + ], + "scope": { + "name": "collector", + "version": "v0.1.0" + } + } + ] + } + ] +} diff --git a/pkg/pdatatest/ptracetest/testdata/scopespans-spans-events-mismatch/actual.json b/pkg/pdatatest/ptracetest/testdata/scopespans-spans-events-mismatch/actual.json new file mode 100644 index 000000000000..e56177a1bf92 --- /dev/null +++ b/pkg/pdatatest/ptracetest/testdata/scopespans-spans-events-mismatch/actual.json @@ -0,0 +1,44 @@ +{ + "resourceSpans": [ + { + "resource": { + "attributes": [ + { + "key": "host.name", + "value": { + "stringValue": "node1" + } + } + ] + }, + "scopeSpans": [ + { + "spans": [ + { + "attributes": [ + { + "key": "key1", + "value": { + "stringValue": "value1" + } + } + ], + "events": [ + { + "name": "Sub span event", + "attributes": null, + "droppedAttributeCount": 0 + } + ], + "traceId": "8c8b1765a7b0acf0b66aa4623fcb7bd5" + } + ], + "scope": { + "name": "collector", + "version": "v0.1.0" + } + } + ] + } + ] +} diff --git a/pkg/pdatatest/ptracetest/testdata/scopespans-spans-events-mismatch/expected.json b/pkg/pdatatest/ptracetest/testdata/scopespans-spans-events-mismatch/expected.json new file mode 100644 index 000000000000..83b59cb7afa3 --- /dev/null +++ b/pkg/pdatatest/ptracetest/testdata/scopespans-spans-events-mismatch/expected.json @@ -0,0 +1,37 @@ +{ + "resourceSpans": [ + { + "resource": { + "attributes": [ + { + "key": "host.name", + "value": { + "stringValue": "node1" + } + } + ] + }, + "scopeSpans": [ + { + "spans": [ + { + "attributes": [ + { + "key": "key1", + "value": { + "stringValue": "value1" + } + } + ], + "traceId": "8c8b1765a7b0acf0b66aa4623fcb7bd5" + } + ], + "scope": { + "name": "collector", + "version": "v0.1.0" + } + } + ] + } + ] +} diff --git a/pkg/pdatatest/ptracetest/testdata/scopespans-spans-kind-mismatch/actual.json b/pkg/pdatatest/ptracetest/testdata/scopespans-spans-kind-mismatch/actual.json new file mode 100644 index 000000000000..90190d031aef --- /dev/null +++ b/pkg/pdatatest/ptracetest/testdata/scopespans-spans-kind-mismatch/actual.json @@ -0,0 +1,40 @@ +{ + "resourceSpans": [ + { + "resource": { + "attributes": [ + { + "key": "host.name", + "value": { + "stringValue": "node1" + } + } + ] + }, + "scopeSpans": [ + { + "spans": [ + { + "attributes": [ + { + "key": "key1", + "value": { + "stringValue": "value1" + } + } + ], + "name": "span1", + "kind": 2, + "spanId": "fd0da883bb27cd6b", + "traceId": "8c8b1765a7b0acf0b66aa4623fcb7bd5" + } + ], + "scope": { + "name": "collector", + "version": "v0.1.0" + } + } + ] + } + ] +} diff --git a/pkg/pdatatest/ptracetest/testdata/scopespans-spans-kind-mismatch/expected.json b/pkg/pdatatest/ptracetest/testdata/scopespans-spans-kind-mismatch/expected.json new file mode 100644 index 000000000000..16af8e4c84b5 --- /dev/null +++ b/pkg/pdatatest/ptracetest/testdata/scopespans-spans-kind-mismatch/expected.json @@ -0,0 +1,40 @@ +{ + "resourceSpans": [ + { + "resource": { + "attributes": [ + { + "key": "host.name", + "value": { + "stringValue": "node1" + } + } + ] + }, + "scopeSpans": [ + { + "spans": [ + { + "attributes": [ + { + "key": "key1", + "value": { + "stringValue": "value1" + } + } + ], + "name": "span1", + "kind": 1, + "spanId": "fd0da883bb27cd6b", + "traceId": "8c8b1765a7b0acf0b66aa4623fcb7bd5" + } + ], + "scope": { + "name": "collector", + "version": "v0.1.0" + } + } + ] + } + ] +} diff --git a/pkg/pdatatest/ptracetest/testdata/scopespans-spans-links-mismatch/actual.json b/pkg/pdatatest/ptracetest/testdata/scopespans-spans-links-mismatch/actual.json new file mode 100644 index 000000000000..eaf865d6f79c --- /dev/null +++ b/pkg/pdatatest/ptracetest/testdata/scopespans-spans-links-mismatch/actual.json @@ -0,0 +1,59 @@ +{ + "resourceSpans": [ + { + "resource": { + "attributes": [ + { + "key": "host.name", + "value": { + "stringValue": "node1" + } + } + ] + }, + "scopeSpans": [ + { + "spans": [ + { + "attributes": [ + { + "key": "key1", + "value": { + "stringValue": "value1" + } + } + ], + "links": [ + { + "traceId": "8c8b1765a7b0acf0b66aa4623fcb7bd5", + "spanId": "fd0da883bb27cd6b", + "traceState": "", + "attributes": [ + { + "key": "testKey1", + "value": { + "stringValue": "teststringvalue1" + } + }, + { + "key": "testKey2", + "value": { + "stringValue": "teststringvalue2" + } + } + ], + "droppedAttributesCount": 0 + } + ], + "traceId": "8c8b1765a7b0acf0b66aa4623fcb7bd5" + } + ], + "scope": { + "name": "collector", + "version": "v0.1.0" + } + } + ] + } + ] +} diff --git a/pkg/pdatatest/ptracetest/testdata/scopespans-spans-links-mismatch/expected.json b/pkg/pdatatest/ptracetest/testdata/scopespans-spans-links-mismatch/expected.json new file mode 100644 index 000000000000..83b59cb7afa3 --- /dev/null +++ b/pkg/pdatatest/ptracetest/testdata/scopespans-spans-links-mismatch/expected.json @@ -0,0 +1,37 @@ +{ + "resourceSpans": [ + { + "resource": { + "attributes": [ + { + "key": "host.name", + "value": { + "stringValue": "node1" + } + } + ] + }, + "scopeSpans": [ + { + "spans": [ + { + "attributes": [ + { + "key": "key1", + "value": { + "stringValue": "value1" + } + } + ], + "traceId": "8c8b1765a7b0acf0b66aa4623fcb7bd5" + } + ], + "scope": { + "name": "collector", + "version": "v0.1.0" + } + } + ] + } + ] +} diff --git a/pkg/pdatatest/ptracetest/testdata/scopespans-spans-name-mismatch/actual.json b/pkg/pdatatest/ptracetest/testdata/scopespans-spans-name-mismatch/actual.json new file mode 100644 index 000000000000..bea12a5bfc3b --- /dev/null +++ b/pkg/pdatatest/ptracetest/testdata/scopespans-spans-name-mismatch/actual.json @@ -0,0 +1,39 @@ +{ + "resourceSpans": [ + { + "resource": { + "attributes": [ + { + "key": "host.name", + "value": { + "stringValue": "node1" + } + } + ] + }, + "scopeSpans": [ + { + "spans": [ + { + "attributes": [ + { + "key": "key1", + "value": { + "stringValue": "value1" + } + } + ], + "name": "span1", + "spanId": "fd0da883bb27cd6b", + "traceId": "8c8b1765a7b0acf0b66aa4623fcb7bd5" + } + ], + "scope": { + "name": "collector", + "version": "v0.1.0" + } + } + ] + } + ] +} diff --git a/pkg/pdatatest/ptracetest/testdata/scopespans-spans-name-mismatch/expected.json b/pkg/pdatatest/ptracetest/testdata/scopespans-spans-name-mismatch/expected.json new file mode 100644 index 000000000000..b3e06bea4b22 --- /dev/null +++ b/pkg/pdatatest/ptracetest/testdata/scopespans-spans-name-mismatch/expected.json @@ -0,0 +1,39 @@ +{ + "resourceSpans": [ + { + "resource": { + "attributes": [ + { + "key": "host.name", + "value": { + "stringValue": "node1" + } + } + ] + }, + "scopeSpans": [ + { + "spans": [ + { + "attributes": [ + { + "key": "key1", + "value": { + "stringValue": "value1" + } + } + ], + "name": "span2", + "spanId": "fd0da883bb27cd6b", + "traceId": "8c8b1765a7b0acf0b66aa4623fcb7bd5" + } + ], + "scope": { + "name": "collector", + "version": "v0.1.0" + } + } + ] + } + ] +} diff --git a/pkg/pdatatest/ptracetest/testdata/scopespans-spans-parentspanid-mismatch/actual.json b/pkg/pdatatest/ptracetest/testdata/scopespans-spans-parentspanid-mismatch/actual.json new file mode 100644 index 000000000000..329aa61ad83f --- /dev/null +++ b/pkg/pdatatest/ptracetest/testdata/scopespans-spans-parentspanid-mismatch/actual.json @@ -0,0 +1,39 @@ +{ + "resourceSpans": [ + { + "resource": { + "attributes": [ + { + "key": "host.name", + "value": { + "stringValue": "node1" + } + } + ] + }, + "scopeSpans": [ + { + "spans": [ + { + "attributes": [ + { + "key": "key1", + "value": { + "stringValue": "value1" + } + } + ], + "parentSpanId": "bcff497b5a47310f", + "spanId": "fd0da883bb27cd6b", + "traceId": "8c8b1765a7b0acf0b66aa4623fcb7bd5" + } + ], + "scope": { + "name": "collector", + "version": "v0.1.0" + } + } + ] + } + ] +} diff --git a/pkg/pdatatest/ptracetest/testdata/scopespans-spans-parentspanid-mismatch/expected.json b/pkg/pdatatest/ptracetest/testdata/scopespans-spans-parentspanid-mismatch/expected.json new file mode 100644 index 000000000000..de1d9bb16f2a --- /dev/null +++ b/pkg/pdatatest/ptracetest/testdata/scopespans-spans-parentspanid-mismatch/expected.json @@ -0,0 +1,39 @@ +{ + "resourceSpans": [ + { + "resource": { + "attributes": [ + { + "key": "host.name", + "value": { + "stringValue": "node1" + } + } + ] + }, + "scopeSpans": [ + { + "spans": [ + { + "attributes": [ + { + "key": "key1", + "value": { + "stringValue": "value1" + } + } + ], + "parentSpanId": "310fbcff497b5a47", + "spanId": "fd0da883bb27cd6b", + "traceId": "8c8b1765a7b0acf0b66aa4623fcb7bd5" + } + ], + "scope": { + "name": "collector", + "version": "v0.1.0" + } + } + ] + } + ] +} diff --git a/pkg/pdatatest/ptracetest/testdata/scopespans-spans-spanid-mismatch/actual.json b/pkg/pdatatest/ptracetest/testdata/scopespans-spans-spanid-mismatch/actual.json new file mode 100644 index 000000000000..2bdd3c23551d --- /dev/null +++ b/pkg/pdatatest/ptracetest/testdata/scopespans-spans-spanid-mismatch/actual.json @@ -0,0 +1,38 @@ +{ + "resourceSpans": [ + { + "resource": { + "attributes": [ + { + "key": "host.name", + "value": { + "stringValue": "node1" + } + } + ] + }, + "scopeSpans": [ + { + "spans": [ + { + "attributes": [ + { + "key": "key1", + "value": { + "stringValue": "value1" + } + } + ], + "spanId": "fd0da883bb27cd6b", + "traceId": "8c8b1765a7b0acf0b66aa4623fcb7bd5" + } + ], + "scope": { + "name": "collector", + "version": "v0.1.0" + } + } + ] + } + ] +} diff --git a/pkg/pdatatest/ptracetest/testdata/scopespans-spans-spanid-mismatch/expected.json b/pkg/pdatatest/ptracetest/testdata/scopespans-spans-spanid-mismatch/expected.json new file mode 100644 index 000000000000..856a1c224544 --- /dev/null +++ b/pkg/pdatatest/ptracetest/testdata/scopespans-spans-spanid-mismatch/expected.json @@ -0,0 +1,38 @@ +{ + "resourceSpans": [ + { + "resource": { + "attributes": [ + { + "key": "host.name", + "value": { + "stringValue": "node1" + } + } + ] + }, + "scopeSpans": [ + { + "spans": [ + { + "attributes": [ + { + "key": "key1", + "value": { + "stringValue": "value1" + } + } + ], + "spanId": "d0dfa883bb27cd6b", + "traceId": "8c8b1765a7b0acf0b66aa4623fcb7bd5" + } + ], + "scope": { + "name": "collector", + "version": "v0.1.0" + } + } + ] + } + ] +} diff --git a/pkg/pdatatest/ptracetest/testdata/scopespans-spans-starttimestamp-mismatch/actual.json b/pkg/pdatatest/ptracetest/testdata/scopespans-spans-starttimestamp-mismatch/actual.json new file mode 100644 index 000000000000..238959da7287 --- /dev/null +++ b/pkg/pdatatest/ptracetest/testdata/scopespans-spans-starttimestamp-mismatch/actual.json @@ -0,0 +1,40 @@ +{ + "resourceSpans": [ + { + "resource": { + "attributes": [ + { + "key": "host.name", + "value": { + "stringValue": "node1" + } + } + ] + }, + "scopeSpans": [ + { + "spans": [ + { + "attributes": [ + { + "key": "key1", + "value": { + "stringValue": "value1" + } + } + ], + "name": "span1", + "spanId": "fd0da883bb27cd6b", + "startTimeUnixNano": "11651379494838206464", + "traceId": "8c8b1765a7b0acf0b66aa4623fcb7bd5" + } + ], + "scope": { + "name": "collector", + "version": "v0.1.0" + } + } + ] + } + ] +} diff --git a/pkg/pdatatest/ptracetest/testdata/scopespans-spans-starttimestamp-mismatch/expected.json b/pkg/pdatatest/ptracetest/testdata/scopespans-spans-starttimestamp-mismatch/expected.json new file mode 100644 index 000000000000..36857cac0d0b --- /dev/null +++ b/pkg/pdatatest/ptracetest/testdata/scopespans-spans-starttimestamp-mismatch/expected.json @@ -0,0 +1,40 @@ +{ + "resourceSpans": [ + { + "resource": { + "attributes": [ + { + "key": "host.name", + "value": { + "stringValue": "node1" + } + } + ] + }, + "scopeSpans": [ + { + "spans": [ + { + "attributes": [ + { + "key": "key1", + "value": { + "stringValue": "value1" + } + } + ], + "name": "span1", + "spanId": "fd0da883bb27cd6b", + "startTimeUnixNano": "11651379494838206400", + "traceId": "8c8b1765a7b0acf0b66aa4623fcb7bd5" + } + ], + "scope": { + "name": "collector", + "version": "v0.1.0" + } + } + ] + } + ] +} diff --git a/pkg/pdatatest/ptracetest/testdata/scopespans-spans-status-mismatch/actual.json b/pkg/pdatatest/ptracetest/testdata/scopespans-spans-status-mismatch/actual.json new file mode 100644 index 000000000000..9ccb35724af5 --- /dev/null +++ b/pkg/pdatatest/ptracetest/testdata/scopespans-spans-status-mismatch/actual.json @@ -0,0 +1,41 @@ +{ + "resourceSpans": [ + { + "resource": { + "attributes": [ + { + "key": "host.name", + "value": { + "stringValue": "node1" + } + } + ] + }, + "scopeSpans": [ + { + "spans": [ + { + "attributes": [ + { + "key": "key1", + "value": { + "stringValue": "value1" + } + } + ], + "status": { + "code": 1, + "description": "" + }, + "traceId": "8c8b1765a7b0acf0b66aa4623fcb7bd5" + } + ], + "scope": { + "name": "collector", + "version": "v0.1.0" + } + } + ] + } + ] +} diff --git a/pkg/pdatatest/ptracetest/testdata/scopespans-spans-status-mismatch/expected.json b/pkg/pdatatest/ptracetest/testdata/scopespans-spans-status-mismatch/expected.json new file mode 100644 index 000000000000..83b59cb7afa3 --- /dev/null +++ b/pkg/pdatatest/ptracetest/testdata/scopespans-spans-status-mismatch/expected.json @@ -0,0 +1,37 @@ +{ + "resourceSpans": [ + { + "resource": { + "attributes": [ + { + "key": "host.name", + "value": { + "stringValue": "node1" + } + } + ] + }, + "scopeSpans": [ + { + "spans": [ + { + "attributes": [ + { + "key": "key1", + "value": { + "stringValue": "value1" + } + } + ], + "traceId": "8c8b1765a7b0acf0b66aa4623fcb7bd5" + } + ], + "scope": { + "name": "collector", + "version": "v0.1.0" + } + } + ] + } + ] +} diff --git a/pkg/pdatatest/ptracetest/testdata/scopespans-spans-traceid-mismatch/actual.json b/pkg/pdatatest/ptracetest/testdata/scopespans-spans-traceid-mismatch/actual.json new file mode 100644 index 000000000000..83b59cb7afa3 --- /dev/null +++ b/pkg/pdatatest/ptracetest/testdata/scopespans-spans-traceid-mismatch/actual.json @@ -0,0 +1,37 @@ +{ + "resourceSpans": [ + { + "resource": { + "attributes": [ + { + "key": "host.name", + "value": { + "stringValue": "node1" + } + } + ] + }, + "scopeSpans": [ + { + "spans": [ + { + "attributes": [ + { + "key": "key1", + "value": { + "stringValue": "value1" + } + } + ], + "traceId": "8c8b1765a7b0acf0b66aa4623fcb7bd5" + } + ], + "scope": { + "name": "collector", + "version": "v0.1.0" + } + } + ] + } + ] +} diff --git a/pkg/pdatatest/ptracetest/testdata/scopespans-spans-traceid-mismatch/expected.json b/pkg/pdatatest/ptracetest/testdata/scopespans-spans-traceid-mismatch/expected.json new file mode 100644 index 000000000000..4ef2074050a3 --- /dev/null +++ b/pkg/pdatatest/ptracetest/testdata/scopespans-spans-traceid-mismatch/expected.json @@ -0,0 +1,37 @@ +{ + "resourceSpans": [ + { + "resource": { + "attributes": [ + { + "key": "host.name", + "value": { + "stringValue": "node1" + } + } + ] + }, + "scopeSpans": [ + { + "spans": [ + { + "attributes": [ + { + "key": "key1", + "value": { + "stringValue": "value1" + } + } + ], + "traceId": "b8cb1765a7b0acf0b66aa4623fcb7bd5" + } + ], + "scope": { + "name": "collector", + "version": "v0.1.0" + } + } + ] + } + ] +} diff --git a/pkg/pdatatest/ptracetest/testdata/scopespans-spans-tracestate-mismatch/actual.json b/pkg/pdatatest/ptracetest/testdata/scopespans-spans-tracestate-mismatch/actual.json new file mode 100644 index 000000000000..355c55b878f1 --- /dev/null +++ b/pkg/pdatatest/ptracetest/testdata/scopespans-spans-tracestate-mismatch/actual.json @@ -0,0 +1,39 @@ +{ + "resourceSpans": [ + { + "resource": { + "attributes": [ + { + "key": "host.name", + "value": { + "stringValue": "node1" + } + } + ] + }, + "scopeSpans": [ + { + "spans": [ + { + "attributes": [ + { + "key": "key1", + "value": { + "stringValue": "value1" + } + } + ], + "spanId": "fd0da883bb27cd6b", + "traceId": "8c8b1765a7b0acf0b66aa4623fcb7bd5", + "traceState": "xx" + } + ], + "scope": { + "name": "collector", + "version": "v0.1.0" + } + } + ] + } + ] +} diff --git a/pkg/pdatatest/ptracetest/testdata/scopespans-spans-tracestate-mismatch/expected.json b/pkg/pdatatest/ptracetest/testdata/scopespans-spans-tracestate-mismatch/expected.json new file mode 100644 index 000000000000..3de2f4036ea5 --- /dev/null +++ b/pkg/pdatatest/ptracetest/testdata/scopespans-spans-tracestate-mismatch/expected.json @@ -0,0 +1,39 @@ +{ + "resourceSpans": [ + { + "resource": { + "attributes": [ + { + "key": "host.name", + "value": { + "stringValue": "node1" + } + } + ] + }, + "scopeSpans": [ + { + "spans": [ + { + "attributes": [ + { + "key": "key1", + "value": { + "stringValue": "value1" + } + } + ], + "spanId": "fd0da883bb27cd6b", + "traceId": "8c8b1765a7b0acf0b66aa4623fcb7bd5", + "traceState": "yy" + } + ], + "scope": { + "name": "collector", + "version": "v0.1.0" + } + } + ] + } + ] +} diff --git a/pkg/pdatatest/ptracetest/traces.go b/pkg/pdatatest/ptracetest/traces.go index d86066c6338c..b130c3f33261 100644 --- a/pkg/pdatatest/ptracetest/traces.go +++ b/pkg/pdatatest/ptracetest/traces.go @@ -242,12 +242,12 @@ func CompareSpan(expected, actual ptrace.Span) error { } if expected.TraceID() != actual.TraceID() { - errs = multierr.Append(errs, fmt.Errorf("trace ID doesn't match expected: %d, actual: %d", + errs = multierr.Append(errs, fmt.Errorf("trace ID doesn't match expected: %s, actual: %s", expected.TraceID(), actual.TraceID())) } if expected.SpanID() != actual.SpanID() { - errs = multierr.Append(errs, fmt.Errorf("span ID doesn't match expected: %d, actual: %d", + errs = multierr.Append(errs, fmt.Errorf("span ID doesn't match expected: %s, actual: %s", expected.SpanID(), actual.SpanID())) } @@ -257,7 +257,7 @@ func CompareSpan(expected, actual ptrace.Span) error { } if expected.ParentSpanID() != actual.ParentSpanID() { - errs = multierr.Append(errs, fmt.Errorf("parent span ID doesn't match expected: %d, actual: %d", + errs = multierr.Append(errs, fmt.Errorf("parent span ID doesn't match expected: %s, actual: %s", expected.ParentSpanID(), actual.ParentSpanID())) } @@ -287,8 +287,7 @@ func CompareSpan(expected, actual ptrace.Span) error { } if !reflect.DeepEqual(expected.Events(), actual.Events()) { - errs = multierr.Append(errs, fmt.Errorf("events doesn't match expected: %v, actual: %v", - expected.Events(), actual.Events())) + errs = multierr.Append(errs, fmt.Errorf("events doesn't match")) } if expected.DroppedEventsCount() != actual.DroppedEventsCount() { @@ -297,8 +296,7 @@ func CompareSpan(expected, actual ptrace.Span) error { } if !reflect.DeepEqual(expected.Links(), actual.Links()) { - errs = multierr.Append(errs, fmt.Errorf("links doesn't match expected: %v, actual: %v", - expected.Links(), actual.Links())) + errs = multierr.Append(errs, fmt.Errorf("links doesn't match")) } if expected.DroppedLinksCount() != actual.DroppedLinksCount() { @@ -307,8 +305,7 @@ func CompareSpan(expected, actual ptrace.Span) error { } if !reflect.DeepEqual(expected.Status(), actual.Status()) { - errs = multierr.Append(errs, fmt.Errorf("status doesn't match expected: %v, actual: %v", - expected.Status(), actual.Status())) + errs = multierr.Append(errs, fmt.Errorf("status doesn't match")) } return errs diff --git a/pkg/pdatatest/ptracetest/traces_test.go b/pkg/pdatatest/ptracetest/traces_test.go index da52a601e5db..424b2419bfee 100644 --- a/pkg/pdatatest/ptracetest/traces_test.go +++ b/pkg/pdatatest/ptracetest/traces_test.go @@ -59,6 +59,134 @@ func TestCompareTraces(t *testing.T) { ), withOptions: nil, }, + { + name: "resourcespans-amount-unequal", + withoutOptions: multierr.Combine( + errors.New("number of resources doesn't match expected: 1, actual: 2"), + ), + }, + { + name: "resourcespans-attributes-mismatch", + withoutOptions: multierr.Combine( + errors.New("missing expected resource: map[pod.name:pod1]"), + errors.New("unexpected resource: map[pod.name:pod2]"), + ), + }, + { + name: "scopespans-amount-unequal", + withoutOptions: multierr.Combine( + errors.New("resource \"map[host.name:host1]\": number of scopes doesn't match expected: 1, actual: 2"), + ), + }, + { + name: "scopespans-scope-name-mismatch", + withoutOptions: multierr.Combine( + errors.New("resource \"map[host.name:host1]\": missing expected scope: scope3; resource \"map[host.name:host1]\": unexpected scope: scope2"), + ), + }, + { + name: "scopespans-scope-version-mismatch", + withoutOptions: multierr.Combine( + errors.New("resource \"map[host.name:host1]\": scope \"scope2\": version doesn't match expected: v0.2.0, actual: v0.1.0"), + ), + }, + { + name: "scopespans-spans-amount-unequal", + withoutOptions: multierr.Combine( + errors.New("resource \"map[host.name:node1]\": scope \"collector\": number of spans doesn't match expected: 1, actual: 2"), + ), + }, + { + name: "scopespans-spans-attributes-mismatch", + withoutOptions: multierr.Combine( + errors.New("resource \"map[host.name:node1]\": scope \"collector\": span \"\": attributes don't match expected: map[key2:value2], actual: map[key2:value3]"), + ), + }, + { + name: "scopespans-spans-traceid-mismatch", + withoutOptions: multierr.Combine( + errors.New("resource \"map[host.name:node1]\": scope \"collector\": span \"\": trace ID doesn't match expected: 8c8b1765a7b0acf0b66aa4623fcb7bd5, actual: b8cb1765a7b0acf0b66aa4623fcb7bd5"), + ), + }, + { + name: "scopespans-spans-spanid-mismatch", + withoutOptions: multierr.Combine( + errors.New("resource \"map[host.name:node1]\": scope \"collector\": span \"\": span ID doesn't match expected: fd0da883bb27cd6b, actual: d0dfa883bb27cd6b"), + ), + }, + { + name: "scopespans-spans-tracestate-mismatch", + withoutOptions: multierr.Combine( + errors.New("resource \"map[host.name:node1]\": scope \"collector\": span \"\": trace state doesn't match expected: xx, actual: yy"), + ), + }, + { + name: "scopespans-spans-parentspanid-mismatch", + withoutOptions: multierr.Combine( + errors.New("resource \"map[host.name:node1]\": scope \"collector\": span \"\": parent span ID doesn't match expected: bcff497b5a47310f, actual: 310fbcff497b5a47"), + ), + }, + { + name: "scopespans-spans-name-mismatch", + withoutOptions: multierr.Combine( + errors.New("resource \"map[host.name:node1]\": scope \"collector\": missing expected span: span2"), + errors.New("resource \"map[host.name:node1]\": scope \"collector\": unexpected span: span1"), + ), + }, + { + name: "scopespans-spans-kind-mismatch", + withoutOptions: multierr.Combine( + errors.New("resource \"map[host.name:node1]\": scope \"collector\": span \"span1\": kind doesn't match expected: 2, actual: 1"), + ), + }, + { + name: "scopespans-spans-starttimestamp-mismatch", + withoutOptions: multierr.Combine( + errors.New("resource \"map[host.name:node1]\": scope \"collector\": span \"span1\": start timestamp doesn't match expected: 11651379494838206464, actual: 11651379494838206400"), + ), + }, + { + name: "scopespans-spans-endtimestamp-mismatch", + withoutOptions: multierr.Combine( + errors.New("resource \"map[host.name:node1]\": scope \"collector\": span \"span1\": end timestamp doesn't match expected: 11651379494838206464, actual: 11651379494838206400"), + ), + }, + { + name: "scopespans-spans-droppedattributescount-mismatch", + withoutOptions: multierr.Combine( + errors.New("resource \"map[host.name:node1]\": scope \"collector\": span \"span1\": dropped attributes count doesn't match expected: 0, actual: 1"), + ), + }, + { + name: "scopespans-spans-events-mismatch", + withoutOptions: multierr.Combine( + errors.New("resource \"map[host.name:node1]\": scope \"collector\": span \"\": events doesn't match"), + ), + }, + { + name: "scopespans-spans-droppedeventscount-mismatch", + withoutOptions: multierr.Combine( + errors.New("resource \"map[host.name:node1]\": scope \"collector\": span \"span1\": dropped events count doesn't match expected: 0, actual: 1"), + ), + }, + { + name: "scopespans-spans-links-mismatch", + withoutOptions: multierr.Combine( + errors.New("resource \"map[host.name:node1]\": scope \"collector\": span \"\": links doesn't match"), + ), + }, + { + name: "scopespans-spans-droppedlinkscount-mismatch", + withoutOptions: multierr.Combine( + errors.New("resource \"map[host.name:node1]\": scope \"collector\": span \"span1\": dropped links count doesn't match expected: 0, actual: 1"), + ), + }, + { + name: "scopespans-spans-status-mismatch", + withoutOptions: multierr.Combine( + errors.New("resource \"map[host.name:node1]\": scope \"collector\": span \"\": status doesn't match"), + ), + }, } for _, tc := range tcs { @@ -75,7 +203,7 @@ func TestCompareTraces(t *testing.T) { if tc.withoutOptions == nil { assert.NoError(t, err) } else { - assert.EqualError(t, tc.withoutOptions, err.Error()) + assert.EqualError(t, err, tc.withoutOptions.Error()) } if tc.compareOptions == nil {