From d979f84c44477dfc4f89d635c8aa6a0e57264347 Mon Sep 17 00:00:00 2001 From: Nazarii Gudzovatyi Date: Tue, 14 Jan 2025 20:01:35 +0100 Subject: [PATCH] Add support for filtering by client tags in Web UI --- .../java/io/trino/server/ui/TrimmedBasicQueryInfo.java | 9 +++++++++ .../main/resources/webapp/src/components/QueryList.jsx | 6 +++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/core/trino-main/src/main/java/io/trino/server/ui/TrimmedBasicQueryInfo.java b/core/trino-main/src/main/java/io/trino/server/ui/TrimmedBasicQueryInfo.java index ab2cff5e9300..ad616d45842a 100644 --- a/core/trino-main/src/main/java/io/trino/server/ui/TrimmedBasicQueryInfo.java +++ b/core/trino-main/src/main/java/io/trino/server/ui/TrimmedBasicQueryInfo.java @@ -27,6 +27,7 @@ import java.net.URI; import java.util.Optional; +import java.util.Set; import static com.google.common.base.MoreObjects.toStringHelper; import static java.util.Objects.requireNonNull; @@ -53,6 +54,7 @@ public class TrimmedBasicQueryInfo private final Optional errorCode; private final Optional queryType; private final RetryPolicy retryPolicy; + private final Optional> clientTags; public TrimmedBasicQueryInfo(BasicQueryInfo queryInfo) { @@ -79,6 +81,7 @@ public TrimmedBasicQueryInfo(BasicQueryInfo queryInfo) this.queryStats = requireNonNull(queryInfo.getQueryStats(), "queryStats is null"); this.queryType = requireNonNull(queryInfo.getQueryType(), "queryType is null"); this.retryPolicy = requireNonNull(queryInfo.getRetryPolicy(), "retryPolicy is null"); + this.clientTags = Optional.ofNullable(queryInfo.getSession().getClientTags()); } @JsonProperty @@ -183,6 +186,12 @@ public RetryPolicy getRetryPolicy() return retryPolicy; } + @JsonProperty + public Optional> getClientTags() + { + return clientTags; + } + @Override public String toString() { diff --git a/core/trino-web-ui/src/main/resources/webapp/src/components/QueryList.jsx b/core/trino-web-ui/src/main/resources/webapp/src/components/QueryList.jsx index 415490512d99..de0ed26f5de2 100644 --- a/core/trino-web-ui/src/main/resources/webapp/src/components/QueryList.jsx +++ b/core/trino-web-ui/src/main/resources/webapp/src/components/QueryList.jsx @@ -470,6 +470,10 @@ export class QueryList extends React.Component { ) { return true } + + if (query.clientTags && query.clientTags.some((clientTag) => clientTag.toLowerCase().indexOf(term) !== -1)) { + return true; + } }, this) } } @@ -810,7 +814,7 @@ export class QueryList extends React.Component {