Skip to content

fix: Reliably show service and level in pattern sample drawer - #3062

Open
pulpdrew wants to merge 2 commits into
mainfrom
cursor/fix-pattern-flyout-servicename-befe
Open

fix: Reliably show service and level in pattern sample drawer#3062
pulpdrew wants to merge 2 commits into
mainfrom
cursor/fix-pattern-flyout-servicename-befe

Conversation

@pulpdrew

@pulpdrew pulpdrew commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Summary

This PR fixes two issues with the event patterns sample table:

  1. The table rendered an empty/undefined service for sources where the serviceNameExpression is not in the Primary Key (or where the Primary Key could not be accurately read by HyperDX due to distributed/merge table topologies).
  2. The table rendered an empty/undefined level for trace sources

Root causes:

  • For ServiceName: usePatterns never explicitly selected ServiceName in the first place, rather it just so happened that the ServiceName was added to the select by another optimization (appendSelectWithAdditionalKeys) which adds columns from the primary key.
  • For Trace sources: usePatterns queries StatusCode, but the table did not read it, it was hardcoded to read SeverityText instead.

This fix updates the usePatterns query to explicitly query the correct columns under known alias names that are then referenced by those aliases in the PatternTable. This PR also includes E2E covering these cases.

Screenshots

Before:

Trace source level undefined

Screenshot 2026-09-02 at 7 14 20 PM

Missing Service:

Screenshot 2026-09-02 at 7 18 21 PM

After:

Trace source level defined

Screenshot 2026-09-02 at 7 14 14 PM

Service shown

Screenshot 2026-09-02 at 7 18 12 PM

Testing

  • Open event patterns, test that the sample panel populates all columns for both log and trace sources.

If you'd like to test the service name case, use this as a source:

CREATE TABLE IF NOT EXISTS e2e_custom_service_name
(
  `Timestamp` DateTime64(9) CODEC(Delta(8), ZSTD(1)),
  `AppName` LowCardinality(String) CODEC(ZSTD(1)),
  `SeverityText` LowCardinality(String) CODEC(ZSTD(1)),
  `Body` String CODEC(ZSTD(1)),
  `LogAttributes` Map(LowCardinality(String), String) CODEC(ZSTD(1))
)
ENGINE = MergeTree
PARTITION BY toDate(Timestamp)
ORDER BY (toStartOfFiveMinutes(Timestamp), Timestamp)
TTL toDateTime(Timestamp) + toIntervalDay(30)
SETTINGS index_granularity = 8192, ttl_only_drop_parts = 1;

insert into e2e_custom_service_name values (now(), 'service!', 'info', 'hello', {});

References

Linear: Closes HDX-5274

@changeset-bot

changeset-bot Bot commented Sep 2, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 8c2e213

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@hyperdx/app Patch
@hyperdx/api Patch
@hyperdx/otel-collector Patch

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

@vercel

vercel Bot commented Sep 2, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
hyperdx-oss Ready Ready Preview Sep 2, 2026 11:18pm UTC
hyperdx-storybook Ready Ready Preview Sep 2, 2026 11:18pm UTC

Request Review

@greptile-apps

greptile-apps Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR explicitly selects service name and source-appropriate level values under stable aliases so event-pattern lists and sample drawers can display them reliably.

  • Adds shared aliases for pattern service and level fields.
  • Uses severity text for log levels and status code for trace levels.
  • Updates the pattern drawer, list, and AI summary inputs to consume the aliases.
  • Adds full-stack coverage and a log fixture whose service column is outside the primary key.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

Filename Overview
packages/app/src/hooks/usePatterns.tsx Explicitly projects service and source-appropriate level expressions under stable aliases and carries level into grouped pattern rows.
packages/app/src/components/PatternTable.tsx Supplies service and level expressions to pattern sampling and displays the normalized level field.
packages/app/src/components/PatternSidePanel.tsx Reads sample service and level values through stable aliases in the drawer table.
packages/app/src/components/AISummarizePatternButton.tsx Builds AI summary input from the same normalized service and level aliases.
packages/app/src/components/DBRowTable.tsx Uses the normalized pattern level for trend coloring and updates denoising queries to use the shared level-expression helper.
packages/app/src/source.ts Adds a helper selecting severity text for logs and status code for traces.
packages/app/tests/e2e/features/search/event-patterns.spec.ts Covers service-name rendering outside the primary key and trace status-code rendering as level.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  S[Selected log or trace source] --> E[getLevelExpression]
  S --> N[Service-name expression]
  E --> Q[Pattern sampling query]
  N --> Q
  Q --> A[Stable service and level aliases]
  A --> G[Grouped patterns]
  A --> D[Sample drawer]
  G --> T[Pattern list]
  A --> AI[AI summary input]
Loading

Reviews (4): Last reviewed commit: "fix: Show level for traces in pattern si..." | Re-trigger Greptile

@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

E2E Test Results

All tests passed • 334 passed • 1 skipped • 1206s

Status Count
✅ Passed 334
❌ Failed 0
⚠️ Flaky 3
⏭️ Skipped 1

Tests ran across 4 shards in parallel.

View full report →

@pulpdrew
pulpdrew force-pushed the cursor/fix-pattern-flyout-servicename-befe branch from 2ebb466 to 01c04ce Compare September 2, 2026 22:15
@pulpdrew pulpdrew changed the title Fix empty Service column in event patterns flyout (HDX-5274) fix: Reliably show service name in pattern sample drawer Sep 2, 2026
@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

🔵 Tier 2 — Low Risk

Small, isolated change with no API route or data model modifications.

Why this tier:

  • Standard feature/fix — introduces new logic or modifies core functionality

Review process: AI review + quick human skim (target: 5–15 min). Reviewer validates AI assessment and checks for domain-specific concerns.
SLA: Resolve within 4 business hours.

Stats
  • Production files changed: 6
  • Production lines changed: 167 (+ 280 in test files, excluded from tier calculation)
  • Branch: cursor/fix-pattern-flyout-servicename-befe
  • Author: pulpdrew

To override this classification, remove the review/tier-2 label and apply a different review/tier-* label. Manual overrides are preserved on subsequent pushes.

@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Deep Review

✅ No critical issues found.

The rename from SEVERITY_TEXT_COLUMN_ALIAS/STATUS_CODE_COLUMN_ALIAS to SERVICE_NAME_COLUMN_ALIAS/LEVEL_COLUMN_ALIAS is clean: no dangling importers remain, the removed AISummarizePatternButton prop has its single call site updated, and the deleted ACCESSOR_MAP.severityText accessor (row.severityText ?? row.statusCode) is fully subsumed by getLevelExpression, which merges log severity and trace status code upstream so logLevelColor(row.original.level) preserves prior behavior. No other RawLogTable caller displays a severityText column. The trace-level fix is correct.

🟡 P2 -- recommended

  • packages/app/src/source.ts:711 -- New exported getLevelExpression() has three behavior-carrying branches (log → severityTextExpression, trace → statusCodeExpression, else → '') but no unit test, and the log severity → Level branch is not exercised by either new E2E spec.
    • Fix: Add unit cases in source.test.ts covering all three branches plus undefined/empty-expression sources, and assert the Level column for the custom log source in the E2E flow.
    • testing
🔵 P3 nitpicks (2)
  • packages/app/tests/e2e/components/PatternSidePanelComponent.ts:790 -- Sample and pattern-list cells are located by hard-coded sibling-div indices (td > button > div.nth(N)) in both PatternSidePanelComponent and SearchPage.patternListLevelCell, silently coupling assertions to displayedColumns order in two components; a reorder shifts assertions to the wrong cell.
    • Fix: Add a stable per-column data-testid/data-column attribute on the rendered cell and locate by column identity instead of position.
    • testing, maintainability
  • packages/app/tests/e2e/utils/constants.ts:1226 -- Duplicated word in a newly added comment: "Log source with a a non-standard service name".
    • Fix: Remove the duplicate a.
    • testing

Reviewers (4): testing, maintainability, kieran-typescript, previous-comments.

Testing gaps:

  • getLevelExpression() log/trace/else branches are only exercised end-to-end, and the log severity → Level branch not at all — no direct unit coverage.
  • No unit/integration test for the usePatterns SELECT alias rename; regression protection rests entirely on the two new E2E specs.
  • Prior PR comments were all automated (changeset, Vercel, Greptile summary, E2E results) — no human review feedback to verify as addressed.

Comment thread packages/app/src/components/PatternSidePanel.tsx
Comment thread packages/app/tests/e2e/seed-clickhouse.ts
Comment thread packages/app/src/components/DBRowTable.tsx
Comment thread packages/app/src/source.ts
@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

PR Review

5 finding(s): 🔴 0 critical · 🟠 0 major · 🔵 5 minor

4 posted as inline comment(s) on the changed lines. 1 listed below.

Findings outside the changed lines

1 minor
  • 🔵 packages/app/src/hooks/usePatterns.tsx:177Pattern query key omits the new level/service expressions, so the drawer can serve stale rowsqueryKey: ['patterns', config, bodyValueExpression] does not include levelExpression or serviceNameExpression, yet both change the columns present on every cached sample row. Edit a source's serviceNameExpression (or severityTextExpression) in the source modal while the Event Patterns tab is open: config is unchanged, so the sample query refetches with the new SELECT but this query returns its cached rows, and the drawer keeps showing "undefined" for Service until something else invalidates the key. Add both expressions to the query key.

Severity is the reviewer's own estimate and is used for ordering, not filtering.

@pulpdrew
pulpdrew requested a review from teeohhem September 2, 2026 23:37
@pulpdrew pulpdrew changed the title fix: Reliably show service name in pattern sample drawer fix: Reliably show service and level in pattern sample drawer Sep 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

review/tier-2 Low risk — AI review + quick human skim

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant