-
Notifications
You must be signed in to change notification settings - Fork 8.1k
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
[Reporting] APM integration for baseline performance measurements #59967
Merged
tsullivan
merged 27 commits into
elastic:master
from
tsullivan:reporting/performance-measurement
May 7, 2020
Merged
Changes from all commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
2521d76
fix cluster_client
tsullivan 912a4ad
apm stuff
tsullivan a865bcc
fix snapshot
tsullivan 0fc8813
tracker utility for generate_pdf
tsullivan cbd094b
call apm.startSpan instead of txn.startSpan
tsullivan c037d4d
Fix async call to end transaction
tsullivan 0aa13e6
fix typescript
tsullivan c5c80f5
Merge branch 'master' into reporting/performance-measurement
tsullivan 30af06e
remove captuureErrors
tsullivan b980ba2
Merge branch 'master' into reporting/performance-measurement
tsullivan 1e3c6cc
restore accidental removal
tsullivan 26bf57e
Merge branch 'master' into reporting/performance-measurement
tsullivan 33debce
add startTrace lib
tsullivan cc57a7a
fix import
tsullivan 498a629
Merge remote-tracking branch 'elastic/master' into reporting/performa…
tsullivan fd63584
fix imports
tsullivan 2b564ff
Merge branch 'master' into reporting/performance-measurement
tsullivan 890e5f2
Merge branch 'master' into reporting/performance-measurement
tsullivan 3db397f
ts fix
tsullivan e193ecf
Merge branch 'master' into reporting/performance-measurement
tsullivan e79e875
fix generate_png to not format base64 to buffer and back to base64
tsullivan 7618e42
Merge branch 'master' into reporting/performance-measurement
elasticmachine 0867800
Merge branch 'master' into reporting/performance-measurement
tsullivan 4ac5ce0
💅
tsullivan 6b5c392
revert change to cluster client
tsullivan dd9c55b
fix unused translation
tsullivan e4495c4
Merge branch 'master' into reporting/performance-measurement
tsullivan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ | |
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import apm from 'elastic-apm-node'; | ||
import * as Rx from 'rxjs'; | ||
import { catchError, map, mergeMap, takeUntil } from 'rxjs/operators'; | ||
import { PNG_JOB_TYPE } from '../../../../common/constants'; | ||
|
@@ -29,6 +30,10 @@ export const executeJobFactory: QueuedPngExecutorFactory = async function execut | |
const logger = parentLogger.clone([PNG_JOB_TYPE, 'execute']); | ||
|
||
return async function executeJob(jobId: string, job: JobDocPayloadPNG, cancellationToken: any) { | ||
const apmTrans = apm.startTransaction('reporting execute_job png', 'reporting'); | ||
const apmGetAssets = apmTrans?.startSpan('get_assets', 'setup'); | ||
let apmGeneratePng: { end: () => void } | null | undefined; | ||
|
||
const generatePngObservable = await generatePngObservableFactory(reporting); | ||
const jobLogger = logger.clone([jobId]); | ||
const process$: Rx.Observable<JobDocOutput> = Rx.of(1).pipe( | ||
|
@@ -38,6 +43,9 @@ export const executeJobFactory: QueuedPngExecutorFactory = async function execut | |
mergeMap(conditionalHeaders => { | ||
const urls = getFullUrls({ config, job }); | ||
const hashUrl = urls[0]; | ||
if (apmGetAssets) apmGetAssets.end(); | ||
|
||
apmGeneratePng = apmTrans?.startSpan('generate_png_pipeline', 'execute'); | ||
return generatePngObservable( | ||
jobLogger, | ||
hashUrl, | ||
|
@@ -46,11 +54,14 @@ export const executeJobFactory: QueuedPngExecutorFactory = async function execut | |
job.layout | ||
); | ||
}), | ||
map(({ buffer, warnings }) => { | ||
map(({ base64, warnings }) => { | ||
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 had to rename this - it was very unclear that the return payload actually is a |
||
if (apmGeneratePng) apmGeneratePng.end(); | ||
|
||
return { | ||
content_type: 'image/png', | ||
content: buffer.toString('base64'), | ||
size: buffer.byteLength, | ||
content: base64, | ||
size: (base64 && base64.length) || 0, | ||
|
||
warnings, | ||
}; | ||
}), | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
asyncDurationLogger
was hiding a type error, because we're resolving a string, not a BufferThere 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.
More context about this: since we'll have APM to measure the duration of all these modules, we no longer need this helper function. After having removed it, I noticed the surrounding code treated the helper function return value as a Buffer but it is actually a string of base64 content.