diff --git a/dbux-data/src/callGraph/CallGraph.js b/dbux-data/src/callGraph/CallGraph.js index a231a587e..cad671aa6 100644 --- a/dbux-data/src/callGraph/CallGraph.js +++ b/dbux-data/src/callGraph/CallGraph.js @@ -262,16 +262,14 @@ export default class CallGraph { const trace = this.dp.collections.traces.getById(traceId); const realContextId = this.dp.util.getRealContextIdOfTrace(traceId); const parentTraces = this.dp.indexes.traces.parentsByRealContext.get(realContextId) || EmptyArray; - const callerTraces = parentTraces.map(t => this.dp.util.getPreviousCallerTraceOfTrace(t.traceId)) - .sort((t1, t2) => t1.traceId - t2.traceId); - const lowerIndex = this._binarySearchLowerIndexByKey(callerTraces, trace, (t) => t.traceId); + const lowerIndex = this._binarySearchLowerIndexByKey(parentTraces, trace, (t) => t.traceId); if (lowerIndex === null) { return null; } else { - return this.dp.util.getBCETraceOfTrace(callerTraces[lowerIndex].traceId); + return this.dp.util.getBCETraceOfTrace(parentTraces[lowerIndex].traceId); } } @@ -279,16 +277,14 @@ export default class CallGraph { const realContextId = this.dp.util.getRealContextIdOfTrace(traceId); const trace = this.dp.collections.traces.getById(traceId); const parentTraces = this.dp.indexes.traces.parentsByRealContext.get(realContextId) || EmptyArray; - const callerTraces = parentTraces.map(t => this.dp.util.getPreviousCallerTraceOfTrace(t.traceId)) - .sort((t1, t2) => t1.traceId - t2.traceId); - const upperIndex = this._binarySearchUpperIndexByKey(callerTraces, trace, (t) => t.traceId); + const upperIndex = this._binarySearchUpperIndexByKey(parentTraces, trace, (t) => t.traceId); if (upperIndex === null) { return null; } else { - return this.dp.util.getBCETraceOfTrace(callerTraces[upperIndex].traceId); + return this.dp.util.getBCETraceOfTrace(parentTraces[upperIndex].traceId); } } diff --git a/dbux-data/src/impl/indexes/ParentTracesInRealContextIndex.js b/dbux-data/src/impl/indexes/ParentTracesInRealContextIndex.js index 84790a3d6..fffe1a006 100644 --- a/dbux-data/src/impl/indexes/ParentTracesInRealContextIndex.js +++ b/dbux-data/src/impl/indexes/ParentTracesInRealContextIndex.js @@ -1,5 +1,5 @@ import ExecutionContext from '@dbux/common/src/types/ExecutionContext'; -import { isVirtualContextType } from '@dbux/common/src/types/constants/ExecutionContextType'; +import ExecutionContextType from '@dbux/common/src/types/constants/ExecutionContextType'; import Trace from '@dbux/common/src/types/Trace'; import CollectionIndex, { CollectionIndexDependencies } from '../../indexes/CollectionIndex'; import RuntimeDataProvider from '../../RuntimeDataProvider'; @@ -38,10 +38,14 @@ export default class ParentTracesInRealContextIndex extends CollectionIndex { added: (contexts) => { for (const context of contexts) { const { parentTraceId, contextId } = context; - // skip empty contexts + // skip empty contexts, e.g. `Await`s if (this.dp.indexes.traces.byContext.getSize(contextId) === 0) { continue; } + + /** + * NOTE: this will filter out non-first virtual contexts, since they have no `parentTraceId` + */ if (parentTraceId && !this.addedTraces.has(parentTraceId)) { this.addEntryById(parentTraceId); this.addedTraces.add(parentTraceId);