Repository navigation
feat(app): exemplar overlay for metric and PromQL time charts - #2808
jordan-simonovski wants to merge 18 commits into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
🦋 Changeset detectedLatest commit: 5328079 The changes in this PR will be included in the next version bump. This PR includes changesets to release 4 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
|
<!-- deep-review --> Deep Review
✅ No critical issues found in the code I was able to read — this is not a clean bill of health for the PR, since coverage was partial. 🟡 P2 -- recommended
🔵 P3 nitpicks (2)
Notes on what I did verifyThree things I checked that are correct, recorded so they are not re-flagged on a future pass:
Reviewers (1 of 13 reported): learnings-researcher. Dispatched but no results returned — none of their analysis is in this report: correctness, adversarial, security, testing, maintainability, project-standards, kieran-typescript, julik-frontend-races, performance, reliability, api-contract, agent-native. Coverage limitations:
Recommendation: re-run this review in an environment with working |
186c54f to
082981c
Compare
🔴 Tier 4 — CriticalTouches authentication, tenancy data models, the public API or shipped database config — or substantially changes the query rendering engine, background tasks, the OTel pipeline, image build, or release CI. Why this tier:
Review process: Deep review from a domain expert. Synchronous walkthrough may be required. Stats
|
E2E Test Results✅ All tests passed • 476 passed • 1 skipped • 1149s
Tests ran across 4 shards in parallel. |
9e57b96 to
240df2b
Compare
240df2b to
28ac9fb
Compare
|
<!-- deep-review --> Deep Review
✅ No critical issues found by the one reviewer that completed. 🟡 P2 — recommended
🔵 P3 nitpicks (1)
Reviewers (1 of 12 completed): testing. Dispatched but not returned: correctness, adversarial, security, reliability, performance, api-contract, frontend-races, maintainability, kieran-typescript, project-standards, agent-native. Testing gaps:
Two unverified leads worth chasing before merge — surfaced during scope reconstruction, not confirmed by a reviewer, so deliberately left unscored:
|
Duplicate code analysisNo new duplicate code introduced by this PR. jscpd compared this branch against |
Comments Outside DiffThese findings could not be posted inline.
|
| // Trace source that an exemplar's trace id resolves against — used to fetch | ||
| // hover metadata and to deep-link straight to the trace. When unset, the | ||
| // chart source's linked `traceSourceId` is used as a fallback. | ||
| exemplarTraceSourceId: z.string().optional(), |
There was a problem hiding this comment.
🟠 major — exemplarTraceSourceId is a raw source id, but dashboard export/import doesn't remap it
convertToDashboardTemplate in packages/common-utils/src/core/utils.ts (around line 788) swaps config.source and onClick.target.id for names so templates work on another instance. exemplarTraceSourceId lives in SharedChartSettingsSchema, so it survives TileTemplateSchema.strip() still holding the raw id. After an import it points at nothing. Because useExemplarCard takes exemplarTraceSourceId || source.traceSourceId, the dangling id also blocks the fallback to the linked trace source. The card then says no trace source is set, and Inspect opens /search?source=<bad id>. Fix: remap it to a name on export and back to an id on import, the same way source is handled.
Nothing blocks merge automatically, but a maintainer will expect this fixed if it is a real defect in code this PR changes. If it is about surrounding code, reply and say so instead of patching. Do not widen the PR. How to respond
| // Markers dropped by the render-layer clamps. Reported up from MemoChart because | ||
| // the drop happens after the fetch, so the fetch-layer `dropped` reason cannot | ||
| // see it and the overlay would otherwise thin out with no explanation. | ||
| const [clampDroppedCount, setClampDroppedCount] = useState(0); |
There was a problem hiding this comment.
🔵 minor — Clamp-dropped count goes stale once the plot unmounts
clampDroppedCount is only written from MemoChart's effect. When the chart switches to its loading, error or 'No data found' state, MemoChart unmounts without reporting 0. The toolbar then keeps showing 'N exemplar markers fall outside the chart's plotted range' over an empty chart. Fix: reset setClampDroppedCount(0) in the existing !isPlotRendered effect.
Advisory. Fix if it is a small defect in code this PR changes; otherwise reply in the thread. Do not widen the PR or touch files it did not already change. How to respond
| params.set('to', String(to)); | ||
| Router.push(`/search?${params.toString()}`); | ||
| } else { | ||
| Router.push(`/trace/${encodeURIComponent(exemplar.traceId)}`); |
There was a problem hiding this comment.
🔵 minor — Inspect link without a trace source has no time window, so it falls back to the last 14 days
The trace-source branch adds from/to from exemplarTraceWindow precisely so the link doesn't fall back to getDefaultDirectTraceDateRange (14 days). The /trace/<id> branch omits them. pages/trace/[traceId].tsx → buildTraceRedirectUrl forwards the query string unchanged, so a marker on an older dashboard range still opens an empty view. Fix: append the same from/to params in both branches, or build one /search URL and set source only when it is known.
Advisory. Fix if it is a small defect in code this PR changes; otherwise reply in the thread. Do not widen the PR or touch files it did not already change. How to respond
| (exemplar: Exemplar, cx: number, cy: number) => { | ||
| // Mid-drag: see brushOriginRef. | ||
| if (brushOriginRef.current != null) return; | ||
| setHoveredExemplarKey( |
There was a problem hiding this comment.
🔵 minor — Marker key format is defined in three places that must stay in sync by hand
exemplar-${traceId}-${timestamp} is built separately in computeExemplarPoints (exemplarPoints.ts), in handleExemplarHoverStart here, and for pinnedExemplarKey in useExemplarCard.ts:152. The reset guards compare these strings. If one copy drifts, a pinned or hovered card closes immediately or never closes. Fix: export one exemplarKey(exemplar) helper from exemplarPoints.ts and use it in all three places.
Advisory. Fix if it is a small defect in code this PR changes; otherwise reply in the thread. Do not widen the PR or touch files it did not already change. How to respond
|
|
||
| return { | ||
| activeExemplarKey, | ||
| onActiveExemplarMoved, |
There was a problem hiding this comment.
🔵 minor — Unused return values: onActiveExemplarMoved and exemplarTraceSourceId
useExemplarMarkers returns onActiveExemplarMoved, but MemoChart never destructures it and passes the prop straight to ExemplarDot. Likewise useExemplarCard returns exemplarTraceSourceId (useExemplarCard.ts:268), which DBTimeChart never reads. Fix: drop both from the return objects.
Advisory. Fix if it is a small defect in code this PR changes; otherwise reply in the thread. Do not widen the PR or touch files it did not already change. How to respond
|
|
||
| return { | ||
| exemplars: | ||
| enabled && !tooManySeries |
There was a problem hiding this comment.
🔵 minor — Redundant !tooManySeries check
enabled is already wantsExemplars && !tooManySeries, so enabled && !tooManySeries re-tests the same condition. Fix: use enabled ? (query.data?.exemplars ?? NO_EXEMPLARS) : NO_EXEMPLARS.
Advisory. Fix if it is a small defect in code this PR changes; otherwise reply in the thread. Do not widen the PR or touch files it did not already change. How to respond
| ? `exemplar-${pinnedExemplar.exemplar.traceId}-${pinnedExemplar.exemplar.timestamp}` | ||
| : null; | ||
|
|
||
| // Closing both cards when the markers move lives in useExemplarMarkers, keyed |
There was a problem hiding this comment.
🔵 minor — Comment describes card-closing logic that no longer exists
The comment says closing both cards when markers move happens in useExemplarMarkers, keyed on the x-domain. In fact useExemplarMarkers never closes cards on movement: the active ExemplarDot reports its new position and moveExemplarCard re-anchors the card. Fix: delete this comment or rewrite it to describe the re-anchoring through onPositionChange.
Advisory. Fix if it is a small defect in code this PR changes; otherwise reply in the thread. Do not widen the PR or touch files it did not already change. How to respond
| multiline | ||
| w={280} | ||
| > | ||
| <Text component="span" c="dimmed" data-testid="exemplar-notice"> |
There was a problem hiding this comment.
🔵 minor — Icon-only warning notice has no accessible name and uses a raw dimmed colour
The notice is just an IconAlertTriangle inside a Text c="dimmed" span. The Tooltip label doesn't give it an accessible name, so screen readers announce nothing. It also breaks the 'Semantic component variants' convention, which asks for Text variant="warning" on status text instead of raw palette colours. Fix: add aria-label={exemplarNotice} (or role="img" plus a label) and use variant="warning".
Advisory. Fix if it is a small defect in code this PR changes; otherwise reply in the thread. Do not widen the PR or touch files it did not already change. How to respond
| </Text> | ||
| <Group gap={4} wrap="nowrap"> | ||
| <Text size="xs" ff="monospace" truncate> | ||
| {exemplar.traceId.slice(0, 16)}… |
There was a problem hiding this comment.
🔵 minor — Trace id always gets an ellipsis, even when nothing was cut
{exemplar.traceId.slice(0, 16)}… appends '…' unconditionally, so a short trace id appears truncated when it isn't. The truncate prop already handles overflow. Fix: render exemplar.traceId with truncate (and a title attribute), or add the ellipsis only when traceId.length > 16.
Advisory. Fix if it is a small defect in code this PR changes; otherwise reply in the thread. Do not widen the PR or touch files it did not already change. How to respond
…es' into jordansimonovski/exemplars-overlay # Conflicts: # packages/app/src/components/DBEditTimeChartForm/EditTimeChartForm.tsx
| // domain the y-axis actually renders — see computeExemplarYBounds for why an | ||
| // unclamped marker can silently vanish. | ||
| const exemplarYBounds = useMemo( | ||
| () => computeExemplarYBounds(yAxisBounds.domain, visibleSeriesMax), |
There was a problem hiding this comment.
🟠 major — With a reference line, markers are pinned to the series max even though the axis extends higher, so they plot at a wrong value inside the axis
computeYAxisBounds returns an 'auto' upper bound whenever referenceLineValues is non-empty, and those reference lines extend the domain (see the extendDomain comment around useChartScales.ts:168). computeExemplarYBounds then falls back to visibleSeriesMax. Example: series max 40, alert threshold at 100. A trace measured at 80 is drawn at 40, on an axis that visibly runs to 100, so it reads as a real 40 rather than "at least this high". The new test at useChartScales.test.ts:358 expects this behaviour. Fix: when the upper bound is not numeric, clamp to Math.max(visibleSeriesMax, ...referenceLineValues). Better still, have computeYAxisBounds return the numeric domain it actually renders.
Nothing blocks merge automatically, but a maintainer will expect this fixed if it is a real defect in code this PR changes. If it is about surrounding code, reply and say so instead of patching. Do not widen the PR. How to respond
| const query = useQuery<NormalizedExemplars>({ | ||
| // The raw dateRange is replaced by its quantized form so a live-tail tick | ||
| // doesn't invalidate the overlay every second. | ||
| queryKey: ['exemplars', keyConfig, fetchRange?.map(d => d.getTime())], |
There was a problem hiding this comment.
🔵 minor — Exemplar query key includes cosmetic display settings, so editing them refetches and blanks the overlay
keyConfig is the whole config minus dateRange, so numberFormat, color, legendTemplate and exemplarTraceSourceId are all part of the key. Changing any of them misses the cache, and placeholderData deliberately returns undefined because isEqual(prevQuery.queryKey[1], keyConfig) now fails. The markers vanish and the scan re-runs even though the result is unchanged. Key only on the query-relevant fields (source/connection/from, select, where/filters, granularity, promqlExpression).
Advisory. Fix if it is a small defect in code this PR changes; otherwise reply in the thread. Do not widen the PR or touch files it did not already change. How to respond
| // Key of the pinned marker, so the chart can close the card when a refetch or | ||
| // re-thinning drops that marker from the rendered set. | ||
| const pinnedExemplarKey = pinnedExemplar | ||
| ? `exemplar-${pinnedExemplar.exemplar.traceId}-${pinnedExemplar.exemplar.timestamp}` |
There was a problem hiding this comment.
🔵 minor — Marker key format is spelled out by hand in three places that must stay in sync
exemplar-${traceId}-${timestamp} is built separately in exemplarPoints.ts:77 (the rendered key), useExemplarMarkers.ts:104 (hover key) and here (pin key). The pin/hover reset effects compare these strings, so if one changes, every pinned card closes immediately. Export an exemplarKey(exemplar) helper from exemplarPoints.ts and use it at all three sites and in the tests.
Advisory. Fix if it is a small defect in code this PR changes; otherwise reply in the thread. Do not widen the PR or touch files it did not already change. How to respond
|
|
||
| return { | ||
| activeExemplarKey, | ||
| onActiveExemplarMoved, |
There was a problem hiding this comment.
🔵 minor — Hook returns onActiveExemplarMoved, which nothing reads, and its test passes a nonexistent arg
MemoChart destructures the hook's result without onActiveExemplarMoved and passes its own prop straight to ExemplarDot, so neither the pass-through return nor the hook arg does anything. Remove both. Also drop onExemplarPositionsChanged from useExemplarMarkers.test.ts:33. It is not a hook parameter, and the Record<string, unknown> overrides type hides the mismatch.
Advisory. Fix if it is a small defect in code this PR changes; otherwise reply in the thread. Do not widen the PR or touch files it did not already change. How to respond
| const [from, to] = exemplarTraceWindow(exemplar.timestamp); | ||
| params.set('from', String(from)); | ||
| params.set('to', String(to)); | ||
| Router.push(`/search?${params.toString()}`); |
There was a problem hiding this comment.
🔵 minor — Trace deep link is built by hand even though utils/directTrace.ts already has a helper for it
buildTraceRedirectUrl in packages/app/src/utils/directTrace.ts already builds /search?...&traceId= from a params string. Build the source/from/to params, then call buildTraceRedirectUrl({ traceId, search: params.toString() }), so the trace-link format has one owner.
Advisory. Fix if it is a small defect in code this PR changes; otherwise reply in the thread. Do not widen the PR or touch files it did not already change. How to respond
| dateRangeEndInclusive = true, | ||
| fitYAxisToData = false, | ||
| exemplars, | ||
| maxExemplars = 12, |
There was a problem hiding this comment.
🔵 minor — Default maxExemplars = 12 duplicates DEFAULT_MAX_EXEMPLARS
Use maxExemplars = DEFAULT_MAX_EXEMPLARS from @/defaults, so changing the team default in defaults.ts also changes MemoChart's fallback.
Advisory. Fix if it is a small defect in code this PR changes; otherwise reply in the thread. Do not widen the PR or touch files it did not already change. How to respond
| multiline | ||
| w={280} | ||
| > | ||
| <Text component="span" c="dimmed" data-testid="exemplar-notice"> |
There was a problem hiding this comment.
🔵 minor — Exemplar notice is an icon-only, non-focusable tooltip trigger with no accessible label
The only explanation for missing or dropped markers lives in a hover tooltip on a bare <Text component="span"> icon. Keyboard users cannot focus it, and screen readers get no label. Make it focusable and labelled, for example add tabIndex={0}, role="img" and aria-label={exemplarNotice}, or use an ActionIcon variant="subtle" with aria-label.
Advisory. Fix if it is a small defect in code this PR changes; otherwise reply in the thread. Do not widen the PR or touch files it did not already change. How to respond
…mplars-overlay # Conflicts: # packages/app/src/HDXMultiSeriesTimeChart/MemoChart.tsx # packages/app/src/HDXMultiSeriesTimeChart/__tests__/useChartScales.test.ts # packages/app/src/HDXMultiSeriesTimeChart/useChartScales.ts # packages/app/src/api.ts # packages/app/src/components/ChartDisplaySettingsDrawer.tsx # packages/app/src/components/ChartEditor/utils.ts # packages/app/src/components/DBEditTimeChartForm/EditTimeChartForm.tsx # packages/app/src/components/DBTimeChart/DBTimeChart.tsx # packages/app/src/components/DBTimeChart/useChartToolbarItems.tsx # packages/app/src/components/__tests__/ChartDisplaySettingsDrawer.test.tsx # packages/common-utils/package.json # scripts/ci/ratchet-baseline.json
| : [undefined, undefined]; | ||
| return { | ||
| min: typeof lower === 'number' ? lower : 0, | ||
| max: typeof upper === 'number' ? upper : visibleSeriesMax, |
There was a problem hiding this comment.
🟠 major — Ceiling falls back to series max while the drawn axis is taller, so in-range markers draw too low
When the y-domain top is 'auto', recharts extends the axis past the series max. Alert thresholds use ifOverflow="extendDomain" (Alerts.tsx), and recharts also nice-rounds. computeYAxisBounds returns [0,'auto'] whenever reference lines exist (useChartScales.ts:134). So with series max 40 and a threshold at 100, a 90 ms exemplar sits inside the visible axis but is pinned to 40, a height the hover card contradicts. useChartScales.test.ts asserts exactly this ({min:0,max:40} with a reference line at 100). Fix: when the top is 'auto', include max(...referenceLineValues) in the ceiling, or resolve the ceiling from the axis recharts actually renders.
Nothing blocks merge automatically, but a maintainer will expect this fixed if it is a real defect in code this PR changes. If it is about surrounding code, reply and say so instead of patching. Do not widen the PR. How to respond
| const tolerance = Number.isFinite(bucketSeconds) | ||
| ? Math.max(0, bucketSeconds) | ||
| : 0; | ||
| if (x < min - tolerance || x > max + tolerance) return null; |
There was a problem hiding this comment.
🔵 minor — 30s fetch padding exceeds the one-bucket x tolerance at 15s granularity, so the 'markers dropped' notice fires falsely
quantize.ts pads the fetched window by up to 30s at each end, and both backends return exemplars from that padding. clampExemplarX only tolerates one bucket, which is 15s at the minimum auto granularity. On short-range charts, exemplars in the 15–30s padding are dropped and counted, and the toolbar warns that markers fall below a fitted floor or belong to a different window, when neither is true. Fix: make the tolerance at least the 30s fetch quantum, or exclude exemplars outside the unquantised dateRange before counting drops.
Advisory. Fix if it is a small defect in code this PR changes; otherwise reply in the thread. Do not widen the PR or touch files it did not already change. How to respond
| // can be 100x the p99 line) can't stretch the axis and crush the series flat — | ||
| // the marker pins to the top of the series range while its hover card still | ||
| // shows the true duration. See computeExemplarYBounds. | ||
| const visibleSeriesMax = useMemo(() => { |
There was a problem hiding this comment.
🔵 minor — visibleSeriesMax re-implements scanYAxisValueRange
This memo is the same O(rows×series) loop as scanYAxisValueRange(graphResults, lineData) in this file (line 63), with the legend selection applied by hand. useChartScales already receives visibleLineData, so use hasExemplars ? scanYAxisValueRange(graphResults, visibleLineData).max : 0 and drop the copy.
Advisory. Fix if it is a small defect in code this PR changes; otherwise reply in the thread. Do not widen the PR or touch files it did not already change. How to respond
| // Key of the pinned marker, so the chart can close the card when a refetch or | ||
| // re-thinning drops that marker from the rendered set. | ||
| const pinnedExemplarKey = pinnedExemplar | ||
| ? `exemplar-${pinnedExemplar.exemplar.traceId}-${pinnedExemplar.exemplar.timestamp}` |
There was a problem hiding this comment.
🔵 minor — Marker key format is built by hand in three places
exemplar-${traceId}-${timestamp} is built separately in exemplarPoints.ts:77 (rendered keys), useExemplarMarkers.ts:104 (hover key) and here (pin key). The reset effects close cards whenever these strings disagree, so a change to one copy silently closes every pinned or hovered card. Export a single exemplarKey(exemplar) from exemplarPoints.ts and use it at all three sites.
Advisory. Fix if it is a small defect in code this PR changes; otherwise reply in the thread. Do not widen the PR or touch files it did not already change. How to respond
|
|
||
| return { | ||
| activeExemplarKey, | ||
| onActiveExemplarMoved, |
There was a problem hiding this comment.
🔵 minor — Hook returns values no caller reads
useExemplarMarkers returns onActiveExemplarMoved (just echoing its input), but MemoChart doesn't destructure it and passes its own prop to ExemplarDot instead. useExemplarCard likewise returns exemplarTraceSourceId (useExemplarCard.ts:268), which DBTimeChart never reads. Remove both from the return objects.
Advisory. Fix if it is a small defect in code this PR changes; otherwise reply in the thread. Do not widen the PR or touch files it did not already change. How to respond
| // Matches the series the exemplar belongs to (LineData.displayName) so the | ||
| // overlay can attach markers to the right line. Undefined => applies to all. | ||
| groupKey: z.string().optional(), | ||
| attributes: z.record(z.string()).optional(), |
There was a problem hiding this comment.
🔵 minor — ExemplarSchema has a dead attributes field and comments that describe behaviour not in this PR
Nothing sets or reads attributes. The groupKey comment says it matches LineData.displayName and attaches markers to a line, but it actually holds a Prometheus label key used only for bucketing. The comments also mention trace-source exemplars generated per bucket, which this PR doesn't add. Drop attributes and correct the comments on groupKey, value and enableExemplars.
Advisory. Fix if it is a small defect in code this PR changes; otherwise reply in the thread. Do not widen the PR or touch files it did not already change. How to respond
| // Outline that contrasts with the background (dark in light mode, light | ||
| // in dark mode) rather than matching it — the amber fill alone is | ||
| // low-contrast on a white background, so the marker needs a defined edge. | ||
| stroke="var(--color-text-default, #1a1a1a)" |
There was a problem hiding this comment.
🔵 minor — Chart marker strokes with a text token, against the data-viz color contract
The conventions say not to reuse --color-text-* for charts: chart colors go through the data_viz_colors.md palettes via the utils.ts helpers. The hardcoded #1a1a1a/#f5a623 fallbacks also bypass themes. Use a chart or border token for the outline, as CartesianGrid does with var(--color-border), and drop the hex fallbacks.
Advisory. Fix if it is a small defect in code this PR changes; otherwise reply in the thread. Do not widen the PR or touch files it did not already change. How to respond
| multiline | ||
| w={280} | ||
| > | ||
| <Text component="span" c="dimmed" data-testid="exemplar-notice"> |
There was a problem hiding this comment.
🔵 minor — Exemplar warning is an icon-only span with no accessible name and no keyboard access
The only explanation of a suppressed or failed overlay sits in a Tooltip on a non-focusable <span> that contains just an SVG. Screen readers announce nothing, and keyboard users can't open the tooltip. Add aria-label={exemplarNotice} and tabIndex={0}, or use a focusable element.
Advisory. Fix if it is a small defect in code this PR changes; otherwise reply in the thread. Do not widen the PR or touch files it did not already change. How to respond
| // Trace source an exemplar resolves against: the chart's explicit | ||
| // `exemplarTraceSourceId`, else the chart source's linked trace source. | ||
| const exemplarTraceSourceId = | ||
| queriedConfig.exemplarTraceSourceId || |
There was a problem hiding this comment.
🟡 P2 — Fallback to the chart source's linked trace source can never fire for metric or PromQL sources
Only Metric and Promql sources can show exemplars (EXEMPLAR_SUPPORTED_KINDS), and neither MetricSourceSchema nor PromqlSourceSchema in common-utils/src/types.ts has a traceSourceId (only Log and Session sources do). So the 'traceSourceId' in source branch is always false, and so is the drawer copy "Leave empty to use the chart source's linked trace source". An empty picker always shows "Set an exemplar trace source" and opens /trace/<id> with no source. DBTimeChartExemplarTrace.test.tsx only passes because it mocks a metric source with traceSourceId, which the schema doesn't allow. Fix: either remove the fallback and change the drawer description, or add a linked trace-source field to the metric and PromQL source schemas and fall back to that.
Advisory. Fix if it is a small defect in code this PR changes; otherwise reply in the thread. Do not widen the PR or touch files it did not already change. How to respond
| // Markers dropped by the render-layer clamps. Reported up from MemoChart because | ||
| // the drop happens after the fetch, so the fetch-layer `dropped` reason cannot | ||
| // see it and the overlay would otherwise thin out with no explanation. | ||
| const [clampDroppedCount, setClampDroppedCount] = useState(0); |
There was a problem hiding this comment.
🟡 P2 — Clamp-drop notice stays up after the plot unmounts
clampDroppedCount is only updated by MemoChart's effect. When the chart switches to its loading, error, or "No data found" state, MemoChart unmounts and the last count stays. The toolbar (rendered in every state by ChartContainer) keeps saying "N exemplar markers fall outside the chart's plotted range" over an empty chart. Fix: reset it with setClampDroppedCount(0) in the existing !isPlotRendered effect.
Advisory. Fix if it is a small defect in code this PR changes; otherwise reply in the thread. Do not widen the PR or touch files it did not already change. How to respond
| return null; | ||
| } | ||
| const s = traceSource; | ||
| const from = s.from.databaseName |
There was a problem hiding this comment.
🟡 P2 — Table identifier built by hand with backticks instead of the existing tableExpr helper
tableExpr in packages/common-utils/src/clickhouse/index.ts:849 already binds {database}.{table} as Identifier parameters. Hand-quoting with backticks breaks on any name that contains a backtick, and it repeats an operation that already exists. Use tableExpr (or renderFrom) and chSql for this query.
Advisory. Fix if it is a small defect in code this PR changes; otherwise reply in the thread. Do not widen the PR or touch files it did not already change. How to respond
…es' into jordansimonovski/exemplars-overlay # Conflicts: # packages/api/src/models/team.ts # packages/app/package.json # packages/app/src/HDXMultiSeriesTimeChart/MemoChart.tsx # packages/app/src/HDXMultiSeriesTimeChart/__tests__/useChartScales.test.ts # packages/app/src/HDXMultiSeriesTimeChart/useChartScales.ts # packages/app/src/components/DBTimeChart/DBTimeChart.tsx # packages/common-utils/package.json # packages/common-utils/src/core/renderChartConfig.ts # packages/common-utils/src/types.ts
…es' into jordansimonovski/exemplars-overlay # Conflicts: # packages/app/package.json # packages/app/src/HDXMultiSeriesTimeChart/MemoChart.tsx
| * | ||
| * The chart-editor toggle and the SQL renderer both delegate here so they can't | ||
| * drift apart. | ||
| */ |
There was a problem hiding this comment.
🔴 P1 — Exemplar-eligible aggFns include ones histogram charts cannot render
translateHistogram and translateExponentialHistogram (packages/common-utils/src/core/histogram.ts:75-86, 263-276) only support quantile and count, and throw for anything else. So avg/min/max/last_value/any/none in EXEMPLAR_COMPATIBLE_AGG_FNS can never apply, and METRIC_INELIGIBLE in exemplarToggle.ts tells users to pick avg/min/max/last value, which breaks the main chart query. Reduce the set to quantile and change the copy to say a quantile is required.
Nothing blocks merge automatically, but a maintainer will expect this fixed if it is a real defect in code this PR changes. If it is about surrounding code, reply and say so instead of patching. Do not widen the PR. How to respond
| else if (c === quote) quote = null; | ||
| continue; | ||
| } | ||
| if (c === '"' || c === "'") quote = c; |
There was a problem hiding this comment.
🟡 P2 — Paren walk ignores PromQL backtick raw strings
The quote tracker only recognises " and '. A ) inside a backtick matcher (e.g. histogram_quantile(0.9, x{path=`/a)`})) closes the call early and marks a valid expression ineligible. promqlSeriesLabels.ts already handles backticks, so add the backtick to the quote check here too: c === '"' || c === "'" || c === ''`.
Advisory. Fix if it is a small defect in code this PR changes; otherwise reply in the thread. Do not widen the PR or touch files it did not already change. How to respond
The feature itself. Stacked on #2807 (the chart-file refactor) — review that first; this diff is the feature only.
Fourth of the PRs replacing #2536.
What it does
Time charts on metric and PromQL sources can overlay exemplars — individual trace-linked points. Hovering a marker shows the exemplar's own value and time plus trace metadata, with a button to open the trace.
Off by default for the whole deployment behind
NEXT_PUBLIC_ENABLE_EXEMPLARS, and per-chart behindenableExemplars.The rule the whole feature turns on
A marker sits at the trace's own measurement on the chart's shared axis. So it is only honest when the chart draws one line, in the same unit. That is enforced in four places, and most of the review findings on the original PR were cases where one of them leaked:
histogram_quantile(...) * 1000renders a different unit than its exemplars carry).Where a marker cannot be drawn honestly, it is dropped
Not moved. Outside the rendered window by more than one bucket, or below a fitted y-axis floor, and it does not render — with the count surfaced on the chart, because an overlay that silently thins out is worse than one that explains itself. The exception is above the ceiling, where pinning reads as "at least this high" and the hover card carries the real number.
Note on
common-utilsThose primitives ship in this PR rather than their own. Every one of the exemplar exports is consumed only by the app — landing them alone would fail the unused-export check with no consumer.
Included from the original PR's review rounds
Four rounds, roughly 1 P0/P1 and 15 P2s each. The substantive ones: the hover card now shows value and time (both clamps cite it as their justification and it showed neither); the PromQL aggregation parsing that decides series identity, including label matchers and quoted label names; the ClickHouse scan's
ex_TimeUnixbound, which was previously filtering on the row time while projecting the exemplar time; the query-key quantisation, which now fetches the window it keys; and the card lifecycle across zoom, live tail and display-type switches.Remaining P2/P3s are tracked in #2804 rather than blocking this.
Verification
make ci-lint,make ci-unit(5,350 tests), dashboard E2E 80 passed / 0 failed (2 flakes on listing-page specs that draw no chart).