diff --git a/.betterer.results b/.betterer.results index f4b623c3b11..25a5b2240f7 100644 --- a/.betterer.results +++ b/.betterer.results @@ -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"] ], diff --git a/docs/sources/setup-grafana/configure-grafana/feature-toggles/index.md b/docs/sources/setup-grafana/configure-grafana/feature-toggles/index.md index 387bd2738c2..60c573640cc 100644 --- a/docs/sources/setup-grafana/configure-grafana/feature-toggles/index.md +++ b/docs/sources/setup-grafana/configure-grafana/feature-toggles/index.md @@ -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 | diff --git a/package.json b/package.json index c9e0f197fa9..cb8b3cea0d3 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/packages/grafana-data/src/types/featureToggles.gen.ts b/packages/grafana-data/src/types/featureToggles.gen.ts index c95383fb657..9efe5ab8893 100644 --- a/packages/grafana-data/src/types/featureToggles.gen.ts +++ b/packages/grafana-data/src/types/featureToggles.gen.ts @@ -81,7 +81,6 @@ export interface FeatureToggles { alertStateHistoryLokiOnly?: boolean; unifiedRequestLog?: boolean; renderAuthJWT?: boolean; - pyroscopeFlameGraph?: boolean; externalServiceAuth?: boolean; refactorVariablesTimeRange?: boolean; useCachingService?: boolean; diff --git a/pkg/services/featuremgmt/registry.go b/pkg/services/featuremgmt/registry.go index e0e57f5f055..ebdc9b8e682 100644 --- a/pkg/services/featuremgmt/registry.go +++ b/pkg/services/featuremgmt/registry.go @@ -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", diff --git a/pkg/services/featuremgmt/toggles_gen.csv b/pkg/services/featuremgmt/toggles_gen.csv index 05e85aed297..f009af5dddc 100644 --- a/pkg/services/featuremgmt/toggles_gen.csv +++ b/pkg/services/featuremgmt/toggles_gen.csv @@ -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 diff --git a/pkg/services/featuremgmt/toggles_gen.go b/pkg/services/featuremgmt/toggles_gen.go index 72b4cbc6291..e379c57423d 100644 --- a/pkg/services/featuremgmt/toggles_gen.go +++ b/pkg/services/featuremgmt/toggles_gen.go @@ -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" diff --git a/public/app/features/explore/FlameGraph/FlameGraphExploreContainer.tsx b/public/app/features/explore/FlameGraph/FlameGraphExploreContainer.tsx index 05a27a90501..a7ace9b8794 100644 --- a/public/app/features/explore/FlameGraph/FlameGraphExploreContainer.tsx +++ b/public/app/features/explore/FlameGraph/FlameGraphExploreContainer.tsx @@ -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 (
- +
); }; diff --git a/public/app/plugins/panel/flamegraph/components/FlameGraphTopWrapper.tsx b/public/app/plugins/panel/flamegraph/components/FlameGraphTopWrapper.tsx deleted file mode 100644 index c52c882e704..00000000000 --- a/public/app/plugins/panel/flamegraph/components/FlameGraphTopWrapper.tsx +++ /dev/null @@ -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 ; - } - - return ; -}; - -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(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 = {}; - - // 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; -} diff --git a/yarn.lock b/yarn.lock index 61c4810a9cb..0d1bb5e1d62 100644 --- a/yarn.lock +++ b/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