From 75dc4208eeb7456bd63c24e35132c3d4bf2e2847 Mon Sep 17 00:00:00 2001 From: Ruben van Staden Date: Thu, 20 Feb 2025 14:45:06 -0500 Subject: [PATCH] resolve merge conflicts in apm-data plugin unit test --- docs/changelog/119995.yaml | 5 +++ .../ingest-pipelines/traces-apm@pipeline.yaml | 11 +++-- .../rest-api-spec/test/20_traces_ingest.yml | 42 ++++++++++++++++--- 3 files changed, 49 insertions(+), 9 deletions(-) create mode 100644 docs/changelog/119995.yaml diff --git a/docs/changelog/119995.yaml b/docs/changelog/119995.yaml new file mode 100644 index 0000000000000..e9ee8bc5b8458 --- /dev/null +++ b/docs/changelog/119995.yaml @@ -0,0 +1,5 @@ +pr: 119995 +summary: "apm-data: Use representative count as event.success_count if available" +area: Ingest Node +type: bug +issues: [] diff --git a/x-pack/plugin/apm-data/src/main/resources/ingest-pipelines/traces-apm@pipeline.yaml b/x-pack/plugin/apm-data/src/main/resources/ingest-pipelines/traces-apm@pipeline.yaml index f79c07ff40ac0..476cddee48639 100644 --- a/x-pack/plugin/apm-data/src/main/resources/ingest-pipelines/traces-apm@pipeline.yaml +++ b/x-pack/plugin/apm-data/src/main/resources/ingest-pipelines/traces-apm@pipeline.yaml @@ -30,13 +30,16 @@ processors: field: ["event.duration"] ignore_failure: true ignore_missing: true -- set: - if: ctx.event?.outcome == 'success' - field: event.success_count - value: 1 - set: if: ctx.event?.outcome == 'failure' field: event.success_count value: 0 +- set: + if: ctx.event?.outcome == 'success' + field: event.success_count + value: 1 +- script: + if: ctx.event?.outcome == 'success' && ctx[ctx.processor?.event]?.representative_count != null + source: ctx.event.success_count = ctx[ctx.processor?.event]?.representative_count; - pipeline: name: apm@pipeline diff --git a/x-pack/plugin/apm-data/src/yamlRestTest/resources/rest-api-spec/test/20_traces_ingest.yml b/x-pack/plugin/apm-data/src/yamlRestTest/resources/rest-api-spec/test/20_traces_ingest.yml index 2750cc487d1d3..7fd37cc68484d 100644 --- a/x-pack/plugin/apm-data/src/yamlRestTest/resources/rest-api-spec/test/20_traces_ingest.yml +++ b/x-pack/plugin/apm-data/src/yamlRestTest/resources/rest-api-spec/test/20_traces_ingest.yml @@ -80,7 +80,35 @@ setup: - '{"@timestamp": "2017-06-22", "event": {"outcome": "unknown"}}' - create: {} - - '{"@timestamp": "2017-06-22", "event": {"outcome": "success"}}' + - '{ + "@timestamp": "2017-06-22", + "processor": {"event": "transaction"}, + "event": {"outcome": "success"}, + "transaction": {"representative_count": 2} + }' + + - create: {} + - '{ + "@timestamp": "2017-06-22", + "processor": {"event": "span"}, + "event": {"outcome": "success"}, + "span": {"representative_count": 3} + }' + + - create: {} + - '{ + "@timestamp": "2017-06-22", + "processor": {"event": "span"}, + "event": {"outcome": "success"}, + "span": {"representative_count": null} + }' + + - create: {} + - '{ + "@timestamp": "2017-06-22", + "processor": {"event": "transaction"}, + "event": {"outcome": "success"} + }' - create: {} - '{"@timestamp": "2017-06-22", "event": {"outcome": "failure"}}' @@ -92,11 +120,15 @@ setup: index: traces-apm-testing body: fields: ["event.success_count"] - - length: { hits.hits: 4 } + - length: { hits.hits: 7 } - match: { hits.hits.0.fields: null } - match: { hits.hits.1.fields: null } - - match: { hits.hits.2.fields: {"event.success_count": [1]} } - - match: { hits.hits.3.fields: {"event.success_count": [0]} } + - match: { hits.hits.2.fields: {"event.success_count": [2]} } + - match: { hits.hits.3.fields: {"event.success_count": [3]} } + - match: { hits.hits.4.fields: {"event.success_count": [1]} } + - match: { hits.hits.5.fields: {"event.success_count": [1]} } + - match: { hits.hits.6.fields: {"event.success_count": [0]} } + --- "Test traces-apm-* setting event.ingested via ingest pipeline": - requires: @@ -123,4 +155,4 @@ setup: fields: ["event.ingested"] - length: { hits.hits: 2 } - is_after: { hits.hits.1.fields.event\.ingested.0: "2017-06-22T00:00:00.000Z" } - +