Skip to content
This repository has been archived by the owner on Apr 27, 2023. It is now read-only.

Commit

Permalink
support Grafana 8
Browse files Browse the repository at this point in the history
  • Loading branch information
Loggy committed Jun 30, 2021
1 parent 8393405 commit 274de3b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "pyroscope-pyroscope-grafana",
"version": "1.0.0",
"version": "1.0.1",
"description": "Pyroscope plugin for grafana",
"scripts": {
"build": "grafana-toolkit plugin:build",
Expand Down
20 changes: 12 additions & 8 deletions src/components/FlameGraphRenderer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,9 @@ class FlameGraphRenderer extends React.Component {
this.rangeMin = 0;
this.rangeMax = 1;
this.query = '';
this.panelContainer = document.querySelector('.flamegraph-wrapper')?.closest('.panel-wrapper');
this.panelContainer =
document.querySelector('.flamegraph-wrapper')?.closest('.panel-container') ||
document.querySelector('.flamegraph-wrapper')?.closest('.panel-wrapper');
window.addEventListener('focus', this.focusHandler);

if (this.props.shortcut) {
Expand All @@ -81,13 +83,15 @@ class FlameGraphRenderer extends React.Component {
}

componentDidUpdate(prevProps, prevState) {
if (this.props.data.series && this.props.data.series.length) {
const name = this.props.data.series[this.props.data.series.length - 1].name;
const from = this.props.data?.timeRange?.raw.from.valueOf();
const until = this.props.data?.timeRange?.raw.to.valueOf();
const prevName = prevProps.data.series[prevProps.data.series.length - 1].name;
const prevFrom = prevProps.data?.timeRange?.raw.from.valueOf();
const prevUntil = prevProps.data?.timeRange?.raw.to.valueOf();
const prevData = prevProps.data ? prevProps.data : prevProps;
const currentData = this.props.data ? this.props.data : this.props;
if (currentData.series && currentData.series.length) {
const name = currentData.series[currentData.series.length - 1].name;
const from = currentData?.timeRange?.raw.from.valueOf();
const until = currentData?.timeRange?.raw.to.valueOf();
const prevName = prevData.series[prevData.series.length - 1].name;
const prevFrom = prevData?.timeRange?.raw.from.valueOf();
const prevUntil = prevData?.timeRange?.raw.to.valueOf();
if (from !== prevFrom || until !== prevUntil || name !== prevName) {
this.updateFlameBearerData();
}
Expand Down

0 comments on commit 274de3b

Please sign in to comment.