From ff4beb0dac20a15c430fb2305360925b5301065e Mon Sep 17 00:00:00 2001 From: Guillaume LADORME Date: Mon, 15 Jun 2026 15:16:40 +0200 Subject: [PATCH] [BUGFIX] Align definitions for all explorers Signed-off-by: Guillaume LADORME --- .../src/explore/log-explorer/LogExplorer.tsx | 28 ++--------- prometheus/src/explore/PrometheusExplorer.tsx | 22 +------- .../overview/MetricOverview.tsx | 50 ++++++++----------- pyroscope/src/explore/PyroscopeExplorer.tsx | 12 +---- tempo/src/explore/TempoExplorer.tsx | 12 +---- 5 files changed, 27 insertions(+), 97 deletions(-) diff --git a/logexplorer/src/explore/log-explorer/LogExplorer.tsx b/logexplorer/src/explore/log-explorer/LogExplorer.tsx index 83938b4e..dee7c257 100644 --- a/logexplorer/src/explore/log-explorer/LogExplorer.tsx +++ b/logexplorer/src/explore/log-explorer/LogExplorer.tsx @@ -22,7 +22,7 @@ import { usePluginRegistry, useTimeRange, } from '@perses-dev/plugin-system'; -import { ReactElement, useMemo, useState } from 'react'; +import { ReactElement, useState } from 'react'; import { QueryDefinition } from '@perses-dev/spec'; import { Panel } from '@perses-dev/dashboards'; import { useExplorerManagerContext } from '@perses-dev/explore'; @@ -39,20 +39,9 @@ const EMPTY_QUERIES: QueryDefinition[] = []; function LogsTablePanel({ queries }: { queries: QueryDefinition[] }): ReactElement { const height = PANEL_PREVIEW_HEIGHT; - const definitions = useMemo( - () => - queries.length - ? queries.map((query) => ({ - kind: query.spec.plugin.kind, - spec: query.spec.plugin.spec, - })) - : [], - [queries] - ); - return ( - + - queries.length - ? queries.map((query) => ({ - kind: query.spec.plugin.kind, - spec: query.spec.plugin.spec, - })) - : [], - [queries] - ); - return ( - + - const definitions = queries.length - ? queries.map((query) => { - return { - kind: query.spec.plugin.kind, - spec: query.spec.plugin.spec, - }; - }) - : []; - return ( - + - const definitions = queries.map((query) => { - return { - kind: query.spec.plugin.kind, - spec: query.spec.plugin.spec, - }; - }); - return ( - + > } = - useMemo(() => { - const expr = - type === 'counter' || (rateEnabled && (type === undefined || type === 'summary' || type === 'histogram')) - ? `rate({__name__="${metricName}", ${computeFilterExpr(filters)}}[5m])` - : `{__name__="${metricName}", ${computeFilterExpr(filters)}}`; - - const queries = [ - { - kind: 'TimeSeriesQuery', - spec: { - plugin: { - kind: 'PrometheusTimeSeriesQuery', - spec: { - datasource: datasource, - query: expr, - }, + const queries: QueryDefinition[] = useMemo(() => { + const expr = + type === 'counter' || (rateEnabled && (type === undefined || type === 'summary' || type === 'histogram')) + ? `rate({__name__="${metricName}", ${computeFilterExpr(filters)}}[5m])` + : `{__name__="${metricName}", ${computeFilterExpr(filters)}}`; + + return [ + { + kind: 'TimeSeriesQuery', + spec: { + plugin: { + kind: 'PrometheusTimeSeriesQuery', + spec: { + datasource: datasource, + query: expr, }, }, }, - ]; - - const definitions = queries.map((query) => { - return { - kind: query.spec.plugin.kind, - spec: query.spec.plugin.spec, - }; - }); - - return { queries, definitions }; - }, [datasource, filters, metricName, rateEnabled, type]); + }, + ]; + }, [datasource, filters, metricName, rateEnabled, type]); if (isLoading) { return ( @@ -96,7 +86,7 @@ export function OverviewPanel({ onChange={(_, checked) => setRateEnabled(checked)} /> )} - + (queries); - // map ProfileQueryDefinition to Definition - const definitions = queries.length - ? queries.map((query: QueryDefinition) => { - return { - kind: query.spec.plugin.kind, - spec: query.spec.plugin.spec, - }; - }) - : []; - return ( setData({ queries: queryDefinitions })} /> - + diff --git a/tempo/src/explore/TempoExplorer.tsx b/tempo/src/explore/TempoExplorer.tsx index c8ce0100..45e2a945 100644 --- a/tempo/src/explore/TempoExplorer.tsx +++ b/tempo/src/explore/TempoExplorer.tsx @@ -148,16 +148,6 @@ export function TempoExplorer(): ReactElement { const [queryDefinitions, setQueryDefinitions] = useState(queries); - // map TraceQueryDefinition to Definition - const definitions = queries.length - ? queries.map((query: QueryDefinition) => { - return { - kind: query.spec.plugin.kind, - spec: query.spec.plugin.spec, - }; - }) - : []; - const firstQuery = (queries[0]?.spec.plugin.spec as TempoTraceQuerySpec | undefined)?.query; const isSingleTrace = isValidTraceId(firstQuery ?? ''); @@ -171,7 +161,7 @@ export function TempoExplorer(): ReactElement { /> - + {isSingleTrace ? (