-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ObsUX] Span flyout show Otel plaintext stack trace (#172489)
closes #169769 ## Summary This PR adapts the Stack Trace tab to also display plaintext stacktraces generated by Otel agents <img width="1201" alt="image" src="https://github.com/elastic/kibana/assets/2767137/d0dafc6a-f251-4cd7-b50f-1e00d5e76e76"> <img width="1201" alt="image" src="https://github.com/elastic/kibana/assets/2767137/a8ed7847-2d82-4716-9c27-41dae2375d7f"> <img width="1201" alt="image" src="https://github.com/elastic/kibana/assets/2767137/118b61c2-c646-4cf1-b6c9-4aadc8e836ec"> ### How to test The easiest way to test: ```bash node x-pack/plugins/apm/scripts/test/e2e.js --spec span_stacktrace.cy.ts ``` --------- Co-authored-by: Kibana Machine <[email protected]>
- Loading branch information
1 parent
3419469
commit 4ee1b1f
Showing
6 changed files
with
220 additions
and
5 deletions.
There are no files selected for viewing
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
106 changes: 106 additions & 0 deletions
106
x-pack/plugins/apm/ftr_e2e/cypress/e2e/transaction_details/generate_span_stacktrace_data.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,106 @@ | ||
/* | ||
* 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 { apm, timerange } from '@kbn/apm-synthtrace-client'; | ||
import { synthtrace } from '../../../synthtrace'; | ||
|
||
function getAPMGeneratedStacktrace() { | ||
const apmGeneratedStacktrace = apm | ||
.service({ | ||
name: 'apm-generated', | ||
environment: 'production', | ||
agentName: 'java', | ||
}) | ||
.instance('instance a'); | ||
|
||
return Array.from( | ||
timerange( | ||
new Date('2022-01-01T00:00:00.000Z'), | ||
new Date('2022-01-01T00:01:00.000Z') | ||
) | ||
.interval('1m') | ||
.rate(1) | ||
.generator((timestamp) => { | ||
return apmGeneratedStacktrace | ||
.transaction({ transactionName: `Transaction A` }) | ||
.defaults({ | ||
'service.language.name': 'java', | ||
}) | ||
.timestamp(timestamp) | ||
.duration(1000) | ||
.success() | ||
.children( | ||
apmGeneratedStacktrace | ||
.span({ | ||
spanName: `Span A`, | ||
spanType: 'internal', | ||
'span.stacktrace': [ | ||
{ | ||
library_frame: false, | ||
exclude_from_grouping: false, | ||
filename: 'OutputBuffer.java', | ||
classname: 'org.apache.catalina.connector.OutputBuffer', | ||
line: { number: 825 }, | ||
module: 'org.apache.catalina.connector', | ||
function: 'flushByteBuffer', | ||
}, | ||
], | ||
}) | ||
.timestamp(timestamp + 50) | ||
.duration(100) | ||
.failure() | ||
); | ||
}) | ||
); | ||
} | ||
|
||
function getOtelGeneratedStacktrace() { | ||
const apmGeneratedStacktrace = apm | ||
.service({ | ||
name: 'otel-generated', | ||
environment: 'production', | ||
agentName: 'java', | ||
}) | ||
.instance('instance a'); | ||
|
||
return Array.from( | ||
timerange( | ||
new Date('2022-01-01T00:00:00.000Z'), | ||
new Date('2022-01-01T00:01:00.000Z') | ||
) | ||
.interval('1m') | ||
.rate(1) | ||
.generator((timestamp) => { | ||
return apmGeneratedStacktrace | ||
.transaction({ transactionName: `Transaction A` }) | ||
.timestamp(timestamp) | ||
.duration(1000) | ||
.defaults({ | ||
'service.language.name': 'java', | ||
}) | ||
.success() | ||
.children( | ||
apmGeneratedStacktrace | ||
.span({ | ||
spanName: `Span A`, | ||
spanType: 'internal', | ||
'code.stacktrace': | ||
'java.lang.Throwable\n\tat co.elastic.otel.ElasticSpanProcessor.captureStackTrace(ElasticSpanProcessor.java:81)', | ||
}) | ||
.timestamp(timestamp + 50) | ||
.duration(100) | ||
.failure() | ||
); | ||
}) | ||
); | ||
} | ||
|
||
export function generateSpanStacktraceData() { | ||
const apmGeneratedStacktrace = getAPMGeneratedStacktrace(); | ||
const otelGeneratedStacktrace = getOtelGeneratedStacktrace(); | ||
|
||
synthtrace.index([...apmGeneratedStacktrace, ...otelGeneratedStacktrace]); | ||
} |
63 changes: 63 additions & 0 deletions
63
x-pack/plugins/apm/ftr_e2e/cypress/e2e/transaction_details/span_stacktrace.cy.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,63 @@ | ||
/* | ||
* 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 url from 'url'; | ||
import { synthtrace } from '../../../synthtrace'; | ||
import { generateSpanStacktraceData } from './generate_span_stacktrace_data'; | ||
|
||
const start = '2022-01-01T00:00:00.000Z'; | ||
const end = '2022-01-01T00:15:00.000Z'; | ||
|
||
function getServiceInventoryUrl({ serviceName }: { serviceName: string }) { | ||
return url.format({ | ||
pathname: `/app/apm/services/${serviceName}`, | ||
query: { | ||
rangeFrom: start, | ||
rangeTo: end, | ||
environment: 'ENVIRONMENT_ALL', | ||
kuery: '', | ||
serviceGroup: '', | ||
transactionType: 'request', | ||
comparisonEnabled: true, | ||
offset: '1d', | ||
}, | ||
}); | ||
} | ||
|
||
describe('Span stacktrace', () => { | ||
beforeEach(() => { | ||
cy.loginAsViewerUser(); | ||
}); | ||
describe('span flyout', () => { | ||
before(() => { | ||
generateSpanStacktraceData(); | ||
}); | ||
|
||
after(() => { | ||
synthtrace.clean(); | ||
}); | ||
it('Shows APM agent generated stacktrace', () => { | ||
cy.visitKibana(getServiceInventoryUrl({ serviceName: 'apm-generated' })); | ||
cy.contains('Transaction A').click(); | ||
cy.contains('Span A').click(); | ||
cy.getByTestSubj('spanStacktraceTab').click(); | ||
cy.contains( | ||
'at org.apache.catalina.connector.OutputBuffer.flushByteBuffer(OutputBuffer.java:825)' | ||
); | ||
}); | ||
|
||
it('Shows Otel generated stacktrace', () => { | ||
cy.visitKibana(getServiceInventoryUrl({ serviceName: 'otel-generated' })); | ||
cy.contains('Transaction A').click(); | ||
cy.contains('Span A').click(); | ||
cy.getByTestSubj('spanStacktraceTab').click(); | ||
cy.contains( | ||
`java.lang.Throwable at co.elastic.otel.ElasticSpanProcessor.captureStackTrace(ElasticSpanProcessor.java:81)` | ||
); | ||
}); | ||
}); | ||
}); |
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
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