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

Datasource: Query editor autocomplete #155

Merged
merged 7 commits into from
Sep 6, 2022
Merged

Conversation

aocenas
Copy link
Member

@aocenas aocenas commented Aug 18, 2022

Simple autocomplete for the query editor:

Screenshot from 2022-08-18 11-28-00

Future considerations:

  • Uses Series API to get all the series and builds a list of labels and its values which may not be the most efficient way to do this if there is lots of labels/values.
  • To figure out where is the cursor this uses simple regex matching. In the future, a dedicated parser may be useful if the matching language gets more complex.

Copy link

@adrapereira adrapereira left a comment

Choose a reason for hiding this comment

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

LGTM! Left a comment in case you also run into this issue in fire, if not disregard it 😄

}, [] as Label[]);

// Check if we are editing a label value right now. If so also get name of the label
const matchLabelValue = text.substring(0, offset).match(/(\w+)=("?)[^"]*$/);

Choose a reason for hiding this comment

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

This regex won't match labels that include dots .. Not sure if it's possible for them to have dots in fire but I ran into this issue for tempo.

For example http.status_code only matched status_code with this regex and it results in the autocomplete value being empty.

Same issue in line 179.

A quick fix is to replace (\w+) at the start with ([\w.]+).

Copy link
Member Author

Choose a reason for hiding this comment

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

hmm @cyriltovena can there be dots in the label names?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Copy link
Member Author

@aocenas aocenas Aug 22, 2022

Choose a reason for hiding this comment

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

Thanks. Yeah going to change the regex according to prom spec

@aocenas aocenas mentioned this pull request Aug 22, 2022
8 tasks
@aocenas aocenas merged commit a330f77 into main Sep 6, 2022
@aocenas aocenas deleted the aocenas/datasource/autocomplete branch September 6, 2022 13:32
simonswine pushed a commit to simonswine/pyroscope that referenced this pull request Jun 30, 2023
Datasource: Query editor autocomplete
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants