8000 [BUGFIX] Fix tree view broken when using prometheus built-in vars by AntoineThebaud · Pull Request #2405 · perses/perses · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

[BUGFIX] Fix tree view broken when using prometheus built-in vars #2405

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Nov 27, 2024

Conversation

AntoineThebaud
Copy link
Contributor
@AntoineThebaud AntoineThebaud commented Nov 7, 2024

Description

With #2344 I missed the fact that prometheus-specific builtin variables ($__interval, $__rate_interval..) aren't getting replaced by proper values with the current logic.. Thus any query containing such variable is producing an error (prometheus cannot parse this perses-specific syntax). This PR aims to fix that.

Checklist

  • Pull request has a descriptive title and context useful to a reviewer.
  • Pull request title follows the [<catalog_entry>] <commit message> naming convention using one of the
    following catalog_entry values: FEATURE, ENHANCEMENT, BUGFIX, BREAKINGCHANGE, DOC,IGNORE.
  • All commits have DCO signoffs.

UI Changes

  • Changes that impact the UI include screenshots and/or screencasts of the relevant changes.
  • Code follows the UI guidelines.
  • Visual tests are stable and unlikely to be flaky.
    See Storybook
    and e2e docs for more details. Common issues
    include:
    • Is the data inconsistent? You need to mock API requests.
    • Does the time change? You need to use consistent time values or mock time utilities.
    • Does it have loading states? You need to wait for loading to complete.

const queryExpr = useReplaceVariablesInString(rest.value);
let queryExpr = useReplaceVariablesInString(rest.value);
if (queryExpr) {
queryExpr = replacePromBuiltinVariables(queryExpr, 12345, 12345); // TODO placeholder values to replace
Copy link
Contributor Author
@AntoineThebaud AntoineThebaud Nov 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like providing proper values for the step parameters here involves some refactoring: currently I'd need to rely on the timeseries query context, but actually these step values are computed independently / before the queries are getting fired, so maybe we should extract them to independant hooks to be reused here? Need to think about it...

@AntoineThebaud AntoineThebaud marked this pull request as ready for review November 20, 2024 14:05
Signed-off-by: Antoine THEBAUD <antoine.thebaud@yahoo.fr>
Signed-off-by: Antoine THEBAUD <antoine.thebaud@yahoo.fr>
@AntoineThebaud AntoineThebaud force-pushed the antoinethebaud/fix-tree-view-prom-vars branch from 66cc498 to 1183060 Compare November 21, 2024 13:29
… issue..

Signed-off-by: Antoine THEBAUD <antoine.thebaud@yahoo.fr>
@AntoineThebaud AntoineThebaud force-pushed the antoinethebaud/fix-tree-view-prom-vars branch from 1183060 to 26e3b29 Compare November 21, 2024 14:03
@@ -11,8 +11,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.

import { replaceVariable } from '@perses-dev/plugin-system';
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This import was causing an issue with Jest:

FAIL src/utils/utils.test.ts
  ● Test suite failed to run

    TypeError: Cannot read properties of undefined (reading 'install')

      24 | import { getFormattedAxis } from '../utils';
      25 |
    > 26 | use([EChartsBarChart, GridComponent, DatasetComponent, TitleComponent, TooltipComponent, CanvasRenderer]);
         |    ^
      27 |
      28 | const BAR_WIN_WIDTH = 14;
      29 | const BAR_GAP = 6;

      at use (../node_modules/echarts/lib/extension.js:109:7)
      at ../node_modules/echarts/lib/extension.js:96:7
          at Array.forEach (<anonymous>)
      at each (../node_modules/echarts/node_modules/zrender/lib/core/util.js:205:13)
      at use (../node_modules/echarts/lib/extension.js:95:5)
      at Object.<anonymous> (../components/src/BarChart/BarChart.tsx:26:4)
      at Object.<anonymous> (../components/src/BarChart/index.ts:17:14)
      at Object.<anonymous> (../components/src/index.ts:18:14)
      at Object.<anonymous> (../plugin-system/src/components/CalculationSelector/CalculationSelector.tsx:24:21)
      at Object.<anonymous> (../plugin-system/src/components/CalculationSelector/index.ts:17:14)
      at Object.<anonymous> (../plugin-system/src/components/index.ts:17:14)
      at Object.<anonymous> (../plugin-system/src/index.ts:17:14)
      at Object.<anonymous> (src/utils/utils.ts:37:23)
      at Object.<anonymous> (src/utils/utils.test.ts:17:16)

This was due to the fact that Jest doesn't support tree shaking, about that see

The location change here is just a way to work around the issue, it's actually surprising that we didnt face it earlier already..

@Nexucis Nexucis added this pull request to the merge queue Nov 27, 2024
Merged via the queue into main with commit d9645a2 Nov 27, 2024
18 checks passed
@Nexucis Nexucis deleted the antoinethebaud/fix-tree-view-prom-vars branch November 27, 2024 10:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0