Skip to content

Conversation

@RotRotAl
Copy link

@RotRotAl RotRotAl commented Sep 25, 2025

Allows to override the client tags that were set in the data source addition , via the the query editor.
Based on pr #309 by @laserninja that allows setting the client tags in the data source addition .

@cla-bot
Copy link

cla-bot bot commented Sep 25, 2025

Thank you for your pull request and welcome to the Trino community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. Continue to work with us on the review and improvements in this PR, and submit the signed CLA to [email protected]. Photos, scans, or digitally-signed PDF files are all suitable. Processing may take a few days. The CLA needs to be on file before we merge your changes. For more information, see https://github.com/trinodb/cla

@RotRotAl
Copy link
Author

RotRotAl commented Oct 21, 2025

Cla was accepted waiting for #309 before i can publish this @laserninja @RoeyoOgen

@nineinchnick
Copy link
Member

Please squash all commits

@laserninja
Copy link
Contributor

@RotRotAl can you please create a PR with just your changes? We can get this approved #309 meanwhile

@RotRotAl
Copy link
Author

@laserninja sadly my code based on your changes, i will pull your changes after you finish the cr process

@cla-bot cla-bot bot added the cla-signed label Oct 28, 2025
@RotRotAl RotRotAl force-pushed the feature/ticketless-client-tags-in-query-editor branch 2 times, most recently from 904a534 to c699b9e Compare October 29, 2025 13:05
@RotRotAl RotRotAl requested a review from nineinchnick October 29, 2025 13:10
@RotRotAl
Copy link
Author

@nineinchnick done replying and fixing, thanks for the cr.

@RotRotAl RotRotAl force-pushed the feature/ticketless-client-tags-in-query-editor branch from 8bb3509 to 61c6a88 Compare October 29, 2025 13:25
@RotRotAl
Copy link
Author

RotRotAl commented Nov 2, 2025

Hi @nineinchnick stil needs second cr 🙏🏻

@RotRotAl
Copy link
Author

@nineinchnick still waits for cr

Copy link
Member

@nineinchnick nineinchnick left a comment

Choose a reason for hiding this comment

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

Can you update the PR description with some examples of when this is useful? I'm not sure why this is needed over creating multiple data sources with different client tags configured.

@RotRotAl
Copy link
Author

I need it in order to give my “clients” the ability to choose in which cluster there query should be running, i give them only the gateway link and they decide by client tag where will it run. @nineinchnick

@RotRotAl RotRotAl requested a review from nineinchnick December 3, 2025 14:52
@RotRotAl
Copy link
Author

@nineinchnick waiting for cr 😅

@RoeyoOgen
Copy link

@laserninja can you perhaps review?

}
if queryTags.ClientTags != "" {
contextWithTags = context.WithValue(contextWithTags, trinoClientTagsKey, queryTags.ClientTags)
return contextWithTags
Copy link
Member

Choose a reason for hiding this comment

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

This only uses client tags from the first query. Can other queries have different client tags set?

Copy link
Author

Choose a reason for hiding this comment

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

Right.
fixed so all client tags per request are now being joined together.

All clientTags are applied per request rather than per query.
because grafana executes all queries in a panel inside a single QueryData call with a shared context.

Copy link
Member

Choose a reason for hiding this comment

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

I'm concerned this can produce unexpected results for users when tags set on query A change the results returned by query B.

Copy link
Author

Choose a reason for hiding this comment

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

it's not possible to apply different tags per query without changing the architecture to send one request per query.

but I agree it can produce unexpected results if queries in the same panel expect different tags.
We could consider a future enhancement where each query executes in its own request context to fully respect per-query tags.
But currently the plugin doesn't support that.

Copy link
Member

Choose a reason for hiding this comment

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

This is a blocker then.

Copy link
Author

Choose a reason for hiding this comment

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

I understand the concern, and I agree it can produce unexpected results when queries in the same panel expect different tags.
However, I think this can be documented clearly. And that in most use cases, if multiple queries are in the same panel, they are expected to use the same client tags.

Copy link
Member

Choose a reason for hiding this comment

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

You could validate if the tags are the same and return an error if they're not, but then it would be confusing to users why they're able to configure different tags for every query in the first place.

I don't think documentation solves this.

Copy link
Author

Choose a reason for hiding this comment

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

One practical solution could be to update the placeholder text for the Client Tags input to clearly indicate that all queries in the panel share the same tags.
it would make the limitation obvious to users.

Copy link
Member

Choose a reason for hiding this comment

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

Can you try that and make a screenshot so we can see if it's visible enough? Combined with a strict validation, this would be acceptable.

Copy link
Author

Choose a reason for hiding this comment

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

image

@nineinchnick
Copy link
Member

Except for the one comment I left above, this looks good. Please squash commits and write good commit messages to prepare it for merging. Also rebase and fix the conflict in e2e tests.

@RotRotAl RotRotAl force-pushed the feature/ticketless-client-tags-in-query-editor branch from 4b74897 to 9ba5839 Compare January 12, 2026 13:38
for i := range req.Queries {
var queryTags queryClientTag
if err := json.Unmarshal(req.Queries[i].JSON, &queryTags); err != nil {
continue
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you add some logging here?

Copy link
Author

Choose a reason for hiding this comment

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

done

src/e2e.test.ts Outdated
async function runQueryAndReturnRequest(
page: Page,
clientTag: string
): Promise<import('@playwright/test').Request > {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you remove extra space here?

Copy link
Author

Choose a reason for hiding this comment

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

done

@laserninja
Copy link
Contributor

You are checking query-level tags first, then falling back to datasource settings. Consider documenting this behavior or potentially merging tags instead of replacing them entirely. What happens when both datasource-level and query-level tags are set?

@cla-bot
Copy link

cla-bot bot commented Jan 19, 2026

Thank you for your pull request and welcome to our community. We could not parse the GitHub identity of the following contributors: Jan Waś.
This is most likely caused by a git client misconfiguration; please make sure to:

  1. check if your git client is configured with an email to sign commits git config --list | grep email
  2. If not, set it up using git config --global user.email [email protected]
  3. Make sure that the git commit email is configured in your GitHub account settings, see https://github.com/settings/emails

@cla-bot cla-bot bot removed the cla-signed label Jan 19, 2026
@RotRotAl RotRotAl force-pushed the feature/ticketless-client-tags-in-query-editor branch from d4b271a to 165235a Compare January 19, 2026 14:46
@cla-bot cla-bot bot added the cla-signed label Jan 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

4 participants