-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ObsUX] Add Missing transaction warning if there are Transactions or …
…Spans with a parent.id that doesn't exist in the trace (#171196) Closes #25117 ## Summary Add a missing transaction warning if there are Transactions or Spans with a `parent.id` that doesn't exist in the trace. ## Testing - Use the `trace_with_orphan_items.ts` scenario: `node scripts/synthtrace --clean trace_with_orphan_items.ts` - In APM -> Traces there are 2 traces: - <img width="1423" alt="image" src="https://github.com/elastic/kibana/assets/14139027/3548d1dd-d87f-4090-a028-d62cf8ec35c8"> - Check the traces: - Incomplete trace (with warning): - <img width="1401" alt="image" src="https://github.com/elastic/kibana/assets/14139027/a75a2112-a425-43d9-bdd1-b3724ccfe6e3"> - Complete trace (no warning): - <img width="1387" alt="image" src="https://github.com/elastic/kibana/assets/14139027/f33614ab-269b-447c-bd0b-bc00f9799092"> - Unit test in [waterfall_helpers.test.ts](https://github.com/elastic/kibana/pull/171196/files#diff-6cdeaa931c0085a16353ac34f937d442a39e1227621f11b3de0608a39e949fc6)
- Loading branch information
1 parent
b83b495
commit 3dbe1e4
Showing
5 changed files
with
273 additions
and
4 deletions.
There are no files selected for viewing
153 changes: 153 additions & 0 deletions
153
packages/kbn-apm-synthtrace/src/scenarios/trace_with_orphan_items.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,153 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
import { apm, ApmFields, httpExitSpan, Serializable } from '@kbn/apm-synthtrace-client'; | ||
import { Readable } from 'stream'; | ||
import { Scenario } from '../cli/scenario'; | ||
|
||
import { RunOptions } from '../cli/utils/parse_run_cli_flags'; | ||
import { getSynthtraceEnvironment } from '../lib/utils/get_synthtrace_environment'; | ||
import { withClient } from '../lib/utils/with_client'; | ||
|
||
const ENVIRONMENT = getSynthtraceEnvironment(__filename); | ||
|
||
const scenario: Scenario<ApmFields> = async (runOptions: RunOptions) => { | ||
return { | ||
generate: ({ range, clients: { apmEsClient } }) => { | ||
const transactionName = 'trace with orphans'; | ||
const successfulTimestamps = range.interval('1s').rate(3); | ||
|
||
const synthRum = apm | ||
.service({ name: 'synth-rum', environment: ENVIRONMENT, agentName: 'rum-js' }) | ||
.instance('my-instance'); | ||
const synthNode = apm | ||
.service({ name: 'synth-node', environment: ENVIRONMENT, agentName: 'nodejs' }) | ||
.instance('my-instance'); | ||
const synthGo = apm | ||
.service({ name: 'synth-go', environment: ENVIRONMENT, agentName: 'go' }) | ||
.instance('my-instance'); | ||
|
||
const traces = successfulTimestamps.generator((timestamp) => { | ||
// synth-rum | ||
return synthGo | ||
.transaction({ transactionName }) | ||
.duration(400) | ||
.timestamp(timestamp) | ||
.children( | ||
// synth-rum -> synth-node | ||
synthRum | ||
.span( | ||
httpExitSpan({ | ||
spanName: 'GET /api/products/top', | ||
destinationUrl: 'http://synth-node:3000', | ||
}) | ||
) | ||
.duration(300) | ||
.timestamp(timestamp) | ||
.children( | ||
synthRum | ||
.transaction({ transactionName: 'Child Transaction' }) | ||
.timestamp(timestamp) | ||
.duration(200) | ||
.children( | ||
synthGo | ||
.span({ spanName: 'custom_operation', spanType: 'custom' }) | ||
.timestamp(timestamp) | ||
.duration(100) | ||
.success() | ||
), | ||
// synth-node | ||
synthNode | ||
.transaction({ transactionName: 'Initial transaction in synth-node' }) | ||
.duration(300) | ||
.timestamp(timestamp) | ||
.children( | ||
synthNode | ||
// synth-node -> synth-go | ||
.span( | ||
httpExitSpan({ | ||
spanName: 'GET synth-go:3000', | ||
destinationUrl: 'http://synth-go:3000', | ||
}) | ||
) | ||
.timestamp(timestamp) | ||
.duration(400) | ||
|
||
.children( | ||
// synth-go | ||
synthGo | ||
.transaction({ transactionName: 'Child Transaction' }) | ||
.timestamp(timestamp) | ||
.duration(200) | ||
.children( | ||
synthGo | ||
.span({ spanName: 'custom_operation', spanType: 'custom' }) | ||
.timestamp(timestamp) | ||
.duration(100) | ||
.success(), | ||
synthGo | ||
.span({ spanName: 'custom_new_operation', spanType: 'custom' }) | ||
.timestamp(timestamp) | ||
.duration(100) | ||
.success() | ||
) | ||
) | ||
) | ||
) | ||
); | ||
}); | ||
|
||
const successfulTraceEvents = Array.from( | ||
successfulTimestamps.generator((timestamp) => | ||
synthNode | ||
.transaction({ transactionName: 'successful trace' }) | ||
.timestamp(timestamp) | ||
.duration(1000) | ||
.success() | ||
.children( | ||
synthNode | ||
.span({ | ||
spanName: 'GET apm-*/_search', | ||
spanType: 'db', | ||
spanSubtype: 'elasticsearch', | ||
}) | ||
.duration(1000) | ||
.success() | ||
.destination('elasticsearch') | ||
.timestamp(timestamp), | ||
synthNode | ||
.span({ spanName: 'custom_operation', spanType: 'custom' }) | ||
.duration(100) | ||
.success() | ||
.timestamp(timestamp) | ||
) | ||
) | ||
); | ||
|
||
const unserialized = Array.from(traces); | ||
|
||
const serialized = unserialized | ||
.flatMap((event) => event.serialize()) | ||
.filter((trace) => trace['transaction.name'] !== 'Child Transaction'); | ||
|
||
const unserializedChanged = serialized.map((event) => ({ | ||
fields: event, | ||
serialize: () => { | ||
return [event]; | ||
}, | ||
})) as Array<Serializable<ApmFields>>; | ||
|
||
return withClient( | ||
apmEsClient, | ||
Readable.from([...unserializedChanged, ...successfulTraceEvents]) | ||
); | ||
}, | ||
}; | ||
}; | ||
|
||
export default scenario; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
...ails/waterfall_with_summary/waterfall_container/waterfall/missing_transaction_warning.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import React from 'react'; | ||
import { EuiBadge, EuiToolTip } from '@elastic/eui'; | ||
import { i18n } from '@kbn/i18n'; | ||
|
||
export function MissingTransactionWarning() { | ||
return ( | ||
<EuiToolTip | ||
position="left" | ||
content={i18n.translate( | ||
'xpack.apm.transactionDetails.agentMissingTransactionMessage', | ||
{ | ||
defaultMessage: | ||
'This trace contains spans from missing transactions. As a result these spans are not displayed in the timeline.', | ||
} | ||
)} | ||
anchorClassName="eui-fullWidth" | ||
> | ||
<EuiBadge | ||
iconType="warning" | ||
color="hollow" | ||
data-test-id="apm-missing-transaction-badge" | ||
> | ||
{i18n.translate( | ||
'xpack.apm.transactionDetails.agentMissingTransactionLabel', | ||
{ | ||
defaultMessage: 'Incomplete trace', | ||
} | ||
)} | ||
</EuiBadge> | ||
</EuiToolTip> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters