mirror of
https://github.com/grafana/grafana.git
synced 2024-12-30 10:47:30 -06:00
Flamegraph: Remove feature flag and code to switch to pyroscope version (#72689)
This commit is contained in:
parent
29fef40f26
commit
58314e6414
@ -4781,9 +4781,6 @@ exports[`better eslint`] = {
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "1"]
|
||||
],
|
||||
"public/app/plugins/panel/flamegraph/components/FlameGraphTopWrapper.tsx:5381": [
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
|
||||
],
|
||||
"public/app/plugins/panel/gauge/GaugeMigrations.ts:5381": [
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
|
||||
],
|
||||
|
@ -105,7 +105,6 @@ Experimental features might be changed or removed without prior notice.
|
||||
| `alertStateHistoryLokiPrimary` | Enable a remote Loki instance as the primary source for state history reads. |
|
||||
| `alertStateHistoryLokiOnly` | Disable Grafana alerts from emitting annotations when a remote Loki instance is available. |
|
||||
| `unifiedRequestLog` | Writes error logs to the request logger |
|
||||
| `pyroscopeFlameGraph` | Changes flame graph to pyroscope one |
|
||||
| `extraThemes` | Enables extra themes |
|
||||
| `lokiPredefinedOperations` | Adds predefined query operations to Loki query editor |
|
||||
| `pluginsFrontendSandbox` | Enables the plugins frontend sandbox |
|
||||
|
@ -288,7 +288,6 @@
|
||||
"@opentelemetry/semantic-conventions": "1.15.0",
|
||||
"@popperjs/core": "2.11.8",
|
||||
"@prometheus-io/lezer-promql": "^0.37.0-rc.1",
|
||||
"@pyroscope/flamegraph": "^0.35.5",
|
||||
"@react-aria/button": "3.8.0",
|
||||
"@react-aria/dialog": "3.5.3",
|
||||
"@react-aria/focus": "3.13.0",
|
||||
|
@ -81,7 +81,6 @@ export interface FeatureToggles {
|
||||
alertStateHistoryLokiOnly?: boolean;
|
||||
unifiedRequestLog?: boolean;
|
||||
renderAuthJWT?: boolean;
|
||||
pyroscopeFlameGraph?: boolean;
|
||||
externalServiceAuth?: boolean;
|
||||
refactorVariablesTimeRange?: boolean;
|
||||
useCachingService?: boolean;
|
||||
|
@ -432,12 +432,6 @@ var (
|
||||
Stage: FeatureStagePublicPreview,
|
||||
Owner: grafanaAsCodeSquad,
|
||||
},
|
||||
{
|
||||
Name: "pyroscopeFlameGraph",
|
||||
Description: "Changes flame graph to pyroscope one",
|
||||
Stage: FeatureStageExperimental,
|
||||
Owner: grafanaObservabilityTracesAndProfilingSquad,
|
||||
},
|
||||
{
|
||||
Name: "externalServiceAuth",
|
||||
Description: "Starts an OAuth2 authentication provider for external services",
|
||||
|
@ -62,7 +62,6 @@ alertStateHistoryLokiPrimary,experimental,@grafana/alerting-squad,false,false,fa
|
||||
alertStateHistoryLokiOnly,experimental,@grafana/alerting-squad,false,false,false,false
|
||||
unifiedRequestLog,experimental,@grafana/backend-platform,false,false,false,false
|
||||
renderAuthJWT,preview,@grafana/grafana-as-code,false,false,false,false
|
||||
pyroscopeFlameGraph,experimental,@grafana/observability-traces-and-profiling,false,false,false,false
|
||||
externalServiceAuth,experimental,@grafana/grafana-authnz-team,true,false,false,false
|
||||
refactorVariablesTimeRange,preview,@grafana/dashboards-squad,false,false,false,false
|
||||
useCachingService,GA,@grafana/grafana-operator-experience-squad,false,false,true,false
|
||||
|
|
@ -259,10 +259,6 @@ const (
|
||||
// Uses JWT-based auth for rendering instead of relying on remote cache
|
||||
FlagRenderAuthJWT = "renderAuthJWT"
|
||||
|
||||
// FlagPyroscopeFlameGraph
|
||||
// Changes flame graph to pyroscope one
|
||||
FlagPyroscopeFlameGraph = "pyroscopeFlameGraph"
|
||||
|
||||
// FlagExternalServiceAuth
|
||||
// Starts an OAuth2 authentication provider for external services
|
||||
FlagExternalServiceAuth = "externalServiceAuth"
|
||||
|
@ -3,7 +3,7 @@ import React from 'react';
|
||||
|
||||
import { DataFrame, GrafanaTheme2, CoreApp } from '@grafana/data';
|
||||
import { useStyles2 } from '@grafana/ui';
|
||||
import { FlameGraphTopWrapper } from 'app/plugins/panel/flamegraph/components/FlameGraphTopWrapper';
|
||||
import FlameGraphContainer from 'app/plugins/panel/flamegraph/components/FlameGraphContainer';
|
||||
|
||||
interface Props {
|
||||
dataFrames: DataFrame[];
|
||||
@ -14,7 +14,7 @@ export const FlameGraphExploreContainer = (props: Props) => {
|
||||
|
||||
return (
|
||||
<div className={styles.container}>
|
||||
<FlameGraphTopWrapper data={props.dataFrames[0]} app={CoreApp.Explore} />
|
||||
<FlameGraphContainer data={props.dataFrames[0]} app={CoreApp.Explore} />
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
@ -1,126 +0,0 @@
|
||||
import { FlamegraphRenderer } from '@pyroscope/flamegraph';
|
||||
import React from 'react';
|
||||
import '@pyroscope/flamegraph/dist/index.css';
|
||||
|
||||
import { CoreApp, DataFrame, DataFrameView } from '@grafana/data';
|
||||
import { config } from '@grafana/runtime';
|
||||
|
||||
import FlameGraphContainer from './FlameGraphContainer';
|
||||
|
||||
type Props = {
|
||||
data?: DataFrame;
|
||||
app: CoreApp;
|
||||
// Height for flame graph when not used in explore.
|
||||
// This needs to be different to explore flame graph height as we
|
||||
// use panels with user adjustable heights in dashboards etc.
|
||||
flameGraphHeight?: number;
|
||||
};
|
||||
|
||||
export const FlameGraphTopWrapper = (props: Props) => {
|
||||
if (config.featureToggles.pyroscopeFlameGraph) {
|
||||
const profile = props.data ? dataFrameToFlameBearer(props.data) : undefined;
|
||||
return <FlamegraphRenderer profile={profile} />;
|
||||
}
|
||||
|
||||
return <FlameGraphContainer data={props.data} app={props.app} />;
|
||||
};
|
||||
|
||||
type Row = {
|
||||
level: number;
|
||||
label: string;
|
||||
value: number;
|
||||
self: number;
|
||||
};
|
||||
|
||||
/**
|
||||
* Converts a nested set format from a DataFrame to a Flamebearer format needed by the pyroscope flamegraph.
|
||||
* @param data
|
||||
*/
|
||||
function dataFrameToFlameBearer(data: DataFrame) {
|
||||
// Unfortunately we cannot use @pyroscope/models for now as they publish ts files which then get type checked and
|
||||
// they do not pass our with our tsconfig
|
||||
const profile: any = {
|
||||
version: 1,
|
||||
flamebearer: {
|
||||
names: [],
|
||||
levels: [],
|
||||
numTicks: 0,
|
||||
maxSelf: 0,
|
||||
},
|
||||
metadata: {
|
||||
format: 'single' as const,
|
||||
sampleRate: 100,
|
||||
spyName: 'gospy' as const,
|
||||
units: 'samples' as const,
|
||||
},
|
||||
};
|
||||
const view = new DataFrameView<Row>(data);
|
||||
const labelField = data.fields.find((f) => f.name === 'label');
|
||||
|
||||
if (labelField?.config?.type?.enum?.text) {
|
||||
profile.flamebearer.names = labelField.config.type.enum.text;
|
||||
}
|
||||
|
||||
const labelMap: Record<string, number> = {};
|
||||
|
||||
// Handle both cases where label is a string or a number pointing to enum config text array.
|
||||
const getLabel = (label: string | number) => {
|
||||
if (typeof label === 'number') {
|
||||
return label;
|
||||
} else {
|
||||
if (labelMap[label] === undefined) {
|
||||
labelMap[label] = profile.flamebearer.names.length;
|
||||
profile.flamebearer.names.push(label);
|
||||
}
|
||||
|
||||
return labelMap[label];
|
||||
}
|
||||
};
|
||||
|
||||
// Absolute offset where we are currently at.
|
||||
let offset = 0;
|
||||
|
||||
for (let i = 0; i < data.length; i++) {
|
||||
// view.get() changes the underlying object, so we have to call this first get the value and then call get() for
|
||||
// current row.
|
||||
const prevLevel = i > 0 ? view.get(i - 1).level : undefined;
|
||||
const row = view.get(i);
|
||||
const currentLevel = row.level;
|
||||
const level = profile.flamebearer.levels[currentLevel];
|
||||
|
||||
// First row is the root and always the total number of ticks.
|
||||
if (i === 0) {
|
||||
profile.flamebearer.numTicks = row.value;
|
||||
}
|
||||
profile.flamebearer.maxSelf = Math.max(profile.flamebearer.maxSelf, row.self);
|
||||
|
||||
if (prevLevel && prevLevel >= currentLevel) {
|
||||
// we are going back to the previous level and adding sibling we have to figure out new offset
|
||||
offset = levelWidth(level);
|
||||
}
|
||||
|
||||
if (!level) {
|
||||
// Starting a new level. Offset is what ever current absolute offset is as there are no siblings yet.
|
||||
profile.flamebearer.levels[row.level] = [offset, row.value, row.self, getLabel(row.label)];
|
||||
} else {
|
||||
// We actually need offset relative to sibling while offset variable contains absolute offset.
|
||||
const width = levelWidth(level);
|
||||
level.push(offset - width, row.value, row.self, getLabel(row.label));
|
||||
}
|
||||
}
|
||||
return profile;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a width of a level. As offsets are relative to siblings we need to sum all the offsets and values in a level.
|
||||
* @param level
|
||||
*/
|
||||
function levelWidth(level: number[]) {
|
||||
let length = 0;
|
||||
for (let i = 0; i < level.length; i += 4) {
|
||||
const start = level[i];
|
||||
const value = level[i + 1];
|
||||
length += start + value;
|
||||
}
|
||||
return length;
|
||||
}
|
13
yarn.lock
13
yarn.lock
@ -6599,18 +6599,6 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@pyroscope/flamegraph@npm:^0.35.5":
|
||||
version: 0.35.6
|
||||
resolution: "@pyroscope/flamegraph@npm:0.35.6"
|
||||
peerDependencies:
|
||||
graphviz-react: ^1.2.5
|
||||
react: ">=16.14.0"
|
||||
react-dom: ">=16.14.0"
|
||||
true-myth: ^5.1.2
|
||||
checksum: 7744b6af4ba9f94c33cdc088167db11074783818c1f325c495cd6762af1f16559a48040f251af9920fd0e9bb85bc55d70a1cffdfc38b3b0d0b7af943b057cb88
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@radix-ui/react-compose-refs@npm:1.0.0":
|
||||
version: 1.0.0
|
||||
resolution: "@radix-ui/react-compose-refs@npm:1.0.0"
|
||||
@ -19313,7 +19301,6 @@ __metadata:
|
||||
"@pmmmwh/react-refresh-webpack-plugin": 0.5.10
|
||||
"@popperjs/core": 2.11.8
|
||||
"@prometheus-io/lezer-promql": ^0.37.0-rc.1
|
||||
"@pyroscope/flamegraph": ^0.35.5
|
||||
"@react-aria/button": 3.8.0
|
||||
"@react-aria/dialog": 3.5.3
|
||||
"@react-aria/focus": 3.13.0
|
||||
|
Loading…
Reference in New Issue
Block a user