Skip to content

Commit 14391a0

Browse files
committed
[Profiling] Add colors for new frame types (exe name, thread name, root)
1 parent d0166b6 commit 14391a0

File tree

3 files changed

+21
-2
lines changed

3 files changed

+21
-2
lines changed

src/platform/packages/shared/kbn-profiling-utils/common/profiling.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ export enum FrameType {
3737
DotNET,
3838
ErrorFlag = 0x80,
3939
Error = 0xff,
40+
41+
// Artificial frame types for grouping, set by the ES profiling plugin
42+
Root = 0x100,
43+
ExecutableName = 0x101,
44+
ThreadName = 0x102,
4045
}
4146

4247
const frameTypeDescriptions = {
@@ -53,6 +58,9 @@ const frameTypeDescriptions = {
5358
[FrameType.DotNET]: '.NET',
5459
[FrameType.ErrorFlag]: 'ErrorFlag',
5560
[FrameType.Error]: 'Error',
61+
[FrameType.Root]: 'Root',
62+
[FrameType.ExecutableName]: 'Process', // Due to OTEL semconv issues, "process name" is currently more correct than "executable name"
63+
[FrameType.ThreadName]: 'Thread',
5664
};
5765

5866
export function isErrorFrame(ft: FrameType): boolean {

x-pack/solutions/observability/plugins/profiling/common/frame_type_colors.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ import { FrameType, normalizeFrameType } from '@kbn/profiling-utils';
2828
*
2929
* Taken originally from prodfiler_ui/src/helpers/Pixi/frameTypeToColors.tsx
3030
*/
31+
const RED = 0xfd8484;
32+
const ORANGE = 0xffaa00;
33+
const YELLOW = 0xe1e100;
34+
3135
export const FRAME_TYPE_COLOR_MAP = {
3236
[FrameType.Unsymbolized]: [0xfd8484, 0xfd9d9d, 0xfeb5b5, 0xfecece],
3337
[FrameType.Python]: [0xfcae6b, 0xfdbe89, 0xfdcea6, 0xfedfc4],
@@ -42,6 +46,9 @@ export const FRAME_TYPE_COLOR_MAP = {
4246
[FrameType.DotNET]: [0x6c60e1, 0x8075e5, 0x948be9, 0xa8a0ed],
4347
[FrameType.ErrorFlag]: [0x0, 0x0, 0x0, 0x0], // This is a special case, it's not a real frame type
4448
[FrameType.Error]: [0xfd8484, 0xfd9d9d, 0xfeb5b5, 0xfecece],
49+
[FrameType.Root]: [RED, RED, RED, RED],
50+
[FrameType.ExecutableName]: [ORANGE, ORANGE, ORANGE, ORANGE],
51+
[FrameType.ThreadName]: [YELLOW, YELLOW, YELLOW, YELLOW],
4552
};
4653

4754
export function frameTypeToRGB(frameType: FrameType, x: number): number {

x-pack/solutions/observability/plugins/profiling/public/utils/get_flamegraph_model/index.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ import type { ColumnarViewModel } from '@elastic/charts';
88
import { i18n } from '@kbn/i18n';
99
import d3 from 'd3';
1010
import { compact, range, sum, uniqueId } from 'lodash';
11-
import { describeFrameType } from '@kbn/profiling-utils';
12-
import type { ElasticFlameGraph, FrameType } from '@kbn/profiling-utils';
11+
import { describeFrameType, FrameType } from '@kbn/profiling-utils';
12+
import type { ElasticFlameGraph } from '@kbn/profiling-utils';
1313
import { createColumnarViewModel } from '../../../common/columnar_view_model';
1414
import { FRAME_TYPE_COLOR_MAP, rgbToRGBA } from '../../../common/frame_type_colors';
1515
import { ComparisonMode } from '../../components/normalization_menu';
@@ -180,6 +180,10 @@ export function getFlamegraphModel({
180180
Object.entries(FRAME_TYPE_COLOR_MAP).map(([frameTypeKey, colors]) => {
181181
const frameType = Number(frameTypeKey) as FrameType;
182182

183+
if (frameType === FrameType.Root) {
184+
return undefined;
185+
}
186+
183187
return usedFrameTypes.has(frameType)
184188
? {
185189
color: `#${colors[0].toString(16)}`,

0 commit comments

Comments
 (0)