Skip to content

Tempo: Add time range to tags and tag value requests #107872

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 13 commits into from
Jul 21, 2025

Conversation

joey-grafana
Copy link
Contributor

What is this feature?

Adds time range to tags and tag value requests, which can be configured in the data source settings.

Why do we need this feature?

Users may have tags or tag values that existed at a time in the past, rather than the last 15 minutes.

Who is this feature for?

Tempo users.

Which issue(s) does this PR fix?:

Fixes #81916

@joey-grafana joey-grafana added this to the 12.1.x milestone Jul 9, 2025
@joey-grafana joey-grafana self-assigned this Jul 9, 2025
@github-actions github-actions bot added the type/docs Flags the technical writing team for documentation support; auto adds to org-wide docs project label Jul 9, 2025
Copy link
Contributor

github-actions bot commented Jul 9, 2025

💻 Deploy preview deleted.

@joey-grafana joey-grafana marked this pull request as ready for review July 9, 2025 11:47
@joey-grafana joey-grafana requested review from a team and lwandz13 as code owners July 9, 2025 11:47
The **Tags time range** modifies how tags queries are run.
When enabled, tags and tag values queries will include the time range.
This setting is disabled by default.
The start time is set to 15 minutes before end time to avoid searching over a long range of time while still allowing users to retrieve tags and tag values in the past.
Copy link
Contributor

Choose a reason for hiding this comment

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

Might be only me but my first impression was that start time is shifted but it seems like it's the other way round: "start time matches the start time in. the current time range and the end time is set to 15 minutes after the start".

Copy link
Contributor

Choose a reason for hiding this comment

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

Also it's used only with v2, not sure if need to mention it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Made some updates here but didn't actually mention anything about v1 / v2. It's been a long time since we made any changes to v1. We should really remove v1 as it's from a much older Tempo version.

@ifrost
Copy link
Contributor

ifrost commented Jul 10, 2025

I tried it in Explore and the range is applied nicely on load, but doesn't seem to be updated if the range changes:

Screen.Recording.2025-07-10.at.13.56.57.mov

Loki plugin is doing this but checking if time range provided to the component changed:

const refreshLabels = shouldRefreshLabels(range, prevProps.range);


| Name | Description |
| ----------------- | ---------------------------------------- |
| **Last 30 mins** | Last 30 mins of selected range. `1800` |

Check failure

Code scanning / Vale

Did you really mean 'mins'? The Grafana dictionary might not know of this word yet

Did you really mean 'mins'? The Grafana dictionary might not know of this word yet
@joey-grafana
Copy link
Contributor Author

@ifrost in terms of listening for changes and recalling the endpoint - initially I felt like this could be too much for the user to be calling the tags again when the time range is changed (and instead refresh) but it's just going to be more confusing to do that so I've pushed a commit to listen for changes!

Copy link
Contributor

@ifrost ifrost left a comment

Choose a reason for hiding this comment

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

Works as expected 👍

I wasn't sure about changing the signature of the abstract LanguageProvider.start(...). Also it's not "start" any more as can be called multiple times changing it's behavior. But it seems language providers live their own life anyway and that abstract class is pointless anyway.

// Check if we need to refetch tags due to range changes (minute-level granularity)
const shouldRefetch = this.shouldRefreshLabels(range, this.previousRange);

if (!this.startTask || shouldRefetch) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Could this cause issues if the previous request is still pending? Do we cancel ongoing requests?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Testing it out it does not seem to cause issue, just creates another request if the range changes before the other one returns. I don't think Tempo allows us to cancel requests.

Copy link
Contributor

@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.

Changes look good! Left a couple of comments to make the code slightly cleaner.

@alexbikfalvi
Copy link
Contributor

Just a nitpick: is there a reason for adding the Tags time range above rather than next to the Tag limit (above or below)? It feels that the 2 options should go together.

Screenshot 2025-07-18 at 10 12 16 AM

@joey-grafana joey-grafana merged commit 96429d7 into main Jul 21, 2025
110 of 113 checks passed
@joey-grafana joey-grafana deleted the joey/tags-time-range branch July 21, 2025 09:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
add to changelog area/datasource/frontend area/frontend datasource/Tempo no-backport Skip backport of PR type/docs Flags the technical writing team for documentation support; auto adds to org-wide docs project
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Use the start and end parameters of the search tags and search tag values APIs
4 participants