[Profiling] Strip leading subdirs for frame group ID (#147906)

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
Closes https://github.com/elastic/prodfiler/issues/2756
This commit is contained in:
Dario Gieselaar 2023-01-10 15:35:27 +01:00 committed by GitHub
parent aab8cf1302
commit 7bbf24acf6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 2 deletions

View file

@ -74,6 +74,16 @@ const symbolizedTests = [
},
expected: 'full;oom_reaper;crash();main()',
},
{
params: {
fileID: '',
addressOrLine: 75,
exeFilename: 'oom_reaper',
sourceFilename: '/code/functionsimsearch/learning/simhashweightslossfunctor.hpp',
functionName: 'crash()',
},
expected: 'full;oom_reaper;crash();learning/simhashweightslossfunctor.hpp',
},
];
describe('Frame group operations', () => {

View file

@ -4,11 +4,15 @@
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
import { takeRight } from 'lodash';
import { StackFrameMetadata } from './profiling';
export type FrameGroupID = string;
function stripLeadingSubdirs(sourceFileName: string) {
return takeRight(sourceFileName.split('/'), 2).join('/');
}
// createFrameGroupID is the "standard" way of grouping frames, by commonly
// shared group identifiers.
//
@ -30,5 +34,5 @@ export function createFrameGroupID(
return `elf;${exeFilename};${functionName}`;
}
return `full;${exeFilename};${functionName};${sourceFilename}`;
return `full;${exeFilename};${functionName};${stripLeadingSubdirs(sourceFilename || '')}`;
}