-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[ObsUX] Add Missing transaction warning if there are Transactions or Spans with a parent.id that doesn't exist in the trace #171196
Changes from all commits
a970d5a
47e4197
5281ca3
45317fa
5c027d6
f5f3973
39b0e7b
09e9a3e
71ee05c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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; |
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.', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The error message is not entirely correct afaict. Example: a (parent) span could be missing, meaning that any child spans (or transactions) will not be displayed. So it is not just about missing transactions. Suggestion for error message:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thank you, I remember I took the message from the issue description, and now that you mentioned that it makes sense. One question regarding the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I added a draft PR for those changes so we can better discuss there There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Yes, I was thinking it would be beneficial to at least show the number of (orphan) items that cannot be placed because a parent is missing. If it's difficult to calculate this, let's just skip it for now. |
||
} | ||
)} | ||
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> | ||
); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: I suggest naming this
OrphanTraceItemsWarning
to align withhasOrphanTraceItems