Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add representative count to apm-data plugin #119995

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ processors:
field: ["event.duration"]
ignore_failure: true
ignore_missing: true
- set:
- script:
if: ctx.event?.outcome == 'success'
field: event.success_count
value: 1
source: |
ctx.event.success_count = ctx[ctx.processor?.event]?.representative_count;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't think of a reason why representative count would be missing, but I still think a null check feels safer.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Not a response to @carsonip, just a comment on the same section of the code.) What eventually happens with the value of the event.success_count? Does it make sense to pop a null in there or will that blow up later processing?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at apm-server source code, event.success_count can be nil: https://github.com/elastic/apm-server/blob/79c4599ab9bd65e1cc688eed1169505933f6f405/systemtest/ingest_test.go#L177

It is only non-nil when outcome is success or failure, in which case, non-0 and 0 respectively.

I assume it will be used by APM UI for getting a transaction success rate.

- set:
if: ctx.event?.outcome == 'failure'
field: event.success_count
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,20 @@ setup:
- '{"@timestamp": "2017-06-22", "event": {"outcome": "unknown"}}'

- create: {}
- '{"@timestamp": "2017-06-22", "event": {"outcome": "success"}}'
- '{
rubvs marked this conversation as resolved.
Show resolved Hide resolved
"@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", "event": {"outcome": "failure"}}'
Expand All @@ -92,8 +105,9 @@ setup:
index: traces-apm-testing
body:
fields: ["event.success_count"]
- length: { hits.hits: 4 }
- length: { hits.hits: 5 }
- 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": [0]} }
Loading