mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 17:59:23 -04:00
[Profiling] Add span for decoding stacktraces (#143054)
This commit is contained in:
parent
9fce7b599d
commit
7ed94ad679
1 changed files with 27 additions and 23 deletions
|
@ -283,34 +283,38 @@ export async function mgetStackTraces({
|
|||
const executableDocIDs = new Set<string>();
|
||||
|
||||
const t0 = Date.now();
|
||||
// flatMap() is significantly slower than an explicit for loop
|
||||
for (const res of stackResponses) {
|
||||
for (const trace of res.docs) {
|
||||
if ('error' in trace) {
|
||||
continue;
|
||||
}
|
||||
// Sometimes we don't find the trace.
|
||||
// This is due to ES delays writing (data is not immediately seen after write).
|
||||
// Also, ES doesn't know about transactions.
|
||||
if (trace.found) {
|
||||
const traceid = trace._id as StackTraceID;
|
||||
let stackTrace = traceLRU.get(traceid) as StackTrace;
|
||||
if (!stackTrace) {
|
||||
stackTrace = decodeStackTrace(trace._source as EncodedStackTrace);
|
||||
traceLRU.set(traceid, stackTrace);
|
||||
}
|
||||
|
||||
totalFrames += stackTrace.FrameIDs.length;
|
||||
stackTraces.set(traceid, stackTrace);
|
||||
for (const frameID of stackTrace.FrameIDs) {
|
||||
stackFrameDocIDs.add(frameID);
|
||||
await withProfilingSpan('decode_stacktraces', async () => {
|
||||
// flatMap() is significantly slower than an explicit for loop
|
||||
for (const res of stackResponses) {
|
||||
for (const trace of res.docs) {
|
||||
if ('error' in trace) {
|
||||
continue;
|
||||
}
|
||||
for (const fileID of stackTrace.FileIDs) {
|
||||
executableDocIDs.add(fileID);
|
||||
// Sometimes we don't find the trace.
|
||||
// This is due to ES delays writing (data is not immediately seen after write).
|
||||
// Also, ES doesn't know about transactions.
|
||||
if (trace.found) {
|
||||
const traceid = trace._id as StackTraceID;
|
||||
let stackTrace = traceLRU.get(traceid) as StackTrace;
|
||||
if (!stackTrace) {
|
||||
stackTrace = decodeStackTrace(trace._source as EncodedStackTrace);
|
||||
traceLRU.set(traceid, stackTrace);
|
||||
}
|
||||
|
||||
totalFrames += stackTrace.FrameIDs.length;
|
||||
stackTraces.set(traceid, stackTrace);
|
||||
for (const frameID of stackTrace.FrameIDs) {
|
||||
stackFrameDocIDs.add(frameID);
|
||||
}
|
||||
for (const fileID of stackTrace.FileIDs) {
|
||||
executableDocIDs.add(fileID);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
logger.info(`processing data took ${Date.now() - t0} ms`);
|
||||
|
||||
if (stackTraces.size !== 0) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue