Skip to content

[Feature][Zeta] Add selectable live metrics chart for running jobs - #11898

Closed
zhang-arvin wants to merge 1 commit into
apache:devfrom
zhang-arvin:fix/issue-11666-realtime-metrics-chart
Closed

zhang-arvin wants to merge 1 commit into
apache:devfrom
zhang-arvin:fix/issue-11666-realtime-metrics-chart

Conversation

@zhang-arvin

Copy link
Copy Markdown
Contributor

Purpose

Add a live-updating metrics chart to the Zeta engine job detail page, replacing the raw time-series table in the node/edge drawer with an interactive line chart and allowing users to pin metrics for side-by-side comparison.

Closes #11666

Changes

  • Add Apache ECharts (Apache-2.0 license) as a charting library in seatunnel-engine-ui
  • Create LiveMetricsChart component with time-series line chart rendering (tooltip, legend, auto-resize)
  • Add usePinnedMetrics composable for session-scoped pin management (max 6 pins, deduplication, clear on unmount)
  • Add pin panel between DAG and summary table showing pinned series with a live chart
  • Enhance drawer with a live chart above the existing series table, keeping the key-field summary above the divider
  • Add Pin buttons in the drawer for each available metric
  • Reuse existing 2s polling of /metrics/realtime endpoints - no extra requests per pin
  • Update en_US and zh_CN locale files with pinned metrics translations

Design Decisions

  • Chart library: Apache ECharts (Apache-2.0, ASF-compatible)
  • Pin lifecycle: Session-scoped only (current Job Detail visit). Cleared on component unmount
  • Pin limit: 6 series max, with a clear message when the limit is reached
  • Polling: No additional polling - pinned series consume the same response data from the existing Overview 2s poll
  • Chart vs table: V1 adds the chart above the existing table in the drawer, keeping both views available

Add a live-updating metrics chart to the job detail page:

- Add Apache ECharts as a charting library (Apache-2.0) in seatunnel-engine-ui
- Create LiveMetricsChart component with time-series line chart rendering
- Add usePinnedMetrics composable for session-scoped pin management (max 6)
- Add pin panel between DAG and summary table showing pinned series
- Replace drawer series table with live chart, keeping summary above divider
- Add Pin buttons in drawer for each metric (source/transform/sink/edge)
- Reuse existing 2s polling of /metrics/realtime endpoints (no extra requests)
- Update en_US and zh_CN locale files with pinned metrics translations

Closes apache#11666
@github-actions github-actions Bot added the Zeta label Aug 20, 2026
@goutamadwant

Copy link
Copy Markdown
Collaborator

@zhang-arvin Is this implementation coordinated with @det101 and the current design discussion on #11666?

That issue records @det101’s claim, design proposal, and working local demo, and #11668 still lists the work as claimed by them. The latest collaborator feedback also asks for the layout to be reconsidered before implementation proceeds.

This PR was opened after a new assignment request but before any maintainer response, and it implements the same V1 scope. Please confirm the contributor handoff and agreed design direction before continuing. Otherwise, this is parallel duplicate work and should not close #11666.

@DanielLeens DanielLeens left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What Problem Does This PR Solve?

This PR implements a "selectable live metrics chart" for the Zeta job detail page: users can pin one or more vertex/edge metrics from the existing realtime drawer and see them rendered as a live-updating ECharts line chart (up to 6 pins), reusing the existing 2-second /metrics/realtime/jobs/{id}/vertices|edges polling.

Before any code discussion, there is a governance/coordination problem that needs to be resolved first, and it should drive the merge decision more than the code quality below.

0. Duplicate/Uncoordinated Work — Please Read First

Issue #11666 (which this PR's feature directly implements) already has an active claim and in-progress design cycle:

  • 2026-08-06/07: @det101 claimed #11666, opened design doc PR #11672, and I (Daniel) explicitly wrote on the issue: "I've assigned the issue to you so the ownership is clear while the design is under review."
  • 2026-08-07 through 2026-08-17: @det101 iterated the design with @nzw921rx and @SEZ9 (chart library = ECharts, session-scoped pins, max 6 series, reuse existing 2s polling — all matching this PR's implementation almost 1:1), posted local demo screenshots, and picked up a still-unresolved layout-scalability concern from @nzw921rx ("if new metric icons are added later, extending them backward seems somewhat difficult... may not be able to meet [needs]" — 2026-08-07) that had not yet been incorporated into a revised design as of @det101's last comment (2026-08-17).
  • 2026-08-20T03:52 (today, before this PR was opened): @zhang-arvin commented on #11666 asking to be assigned, with no maintainer response yet.
  • 2026-08-20T04:51 (same day): this PR (#11898) was opened, implementing the same V1 scope, without any visible coordination with @det101 or acknowledgment of the still-open layout feedback.
  • @goutamadwant already flagged this directly on the PR (2026-08-20T05:27): "This PR was opened after a new assignment request but before any maintainer response, and it implements the same V1 scope... Otherwise, this is parallel duplicate work and should not close #11666." — unanswered as of this review.

I independently re-verified this timeline against issue #11666 and PR #11672's own history rather than taking @goutamadwant's summary at face value, and it checks out exactly as described. Note this is not a formal GitHub "assignee" lock (the issue's assignees field is currently empty — my earlier "I've assigned the issue to you" was stated in a comment but doesn't appear to have been reflected in GitHub's structured assignee field), so this isn't a hard technical block, but it is a real, currently-unresolved community-process conflict: two contributors independently building the same feature, with one of them (@det101) having done substantially more design groundwork and having open feedback not yet folded in.

This should be resolved (either an explicit handoff from @det101, or a maintainer decision on which implementation to proceed with, incorporating @nzw921rx's layout feedback) before this PR is merged, regardless of the code quality of this specific implementation.

1. Code Change Review

1.1 Core Logic Analysis

Setting the coordination question aside, I did a full technical read of the diff (seatunnel-engine-ui, Vue 3 + JSX/TSX, no backend/Java changes):

  • usePinnedMetrics.ts: a clean Vue composable — bounded pin list (MAX_PINS = 6, matching @det101's design discussion), dedupe on (sourceType, sourceId, metricKey), pure derivation of chart series from the already-polled realtimeVertices/realtimeEdges snapshots. No new network requests are introduced per pin — confirmed by reading detail.tsx's pinnedSeriesData computed property, which only reads realtimeVertices.value/realtimeEdges.value (the existing 2s-polled refs), matching the "no extra requests per pin" principle from @det101's design doc.
  • components/live-metrics-chart/index.tsx: wraps echarts/core with only the needed modules (LineChart, Title/Tooltip/Legend/GridComponent, CanvasRenderer) rather than the full ECharts bundle — good for bundle size. Lifecycle is correct: onMounted initializes the chart and a ResizeObserver; onUnmounted disconnects the observer and calls chartInstance.dispose() before nulling the reference — no dangling ECharts instance or observer leak on unmount, which is the most common class of bug in this kind of wrapper.
  • detail.tsx: on onUnmounted, pinnedMetrics.clearPins() is added alongside the pre-existing clearInterval(timer) / clearTimeout(fetchTimer) / clearInterval(realtimeTimer) — consistent with the existing cleanup pattern in this component.

Key Findings:

  • Issue 1 (duplication): usePinnedMetrics.ts:98-104 reimplements the decodeTargetVertexId(queueId) helper (the "negative queueId → target vertex id" decoding trick) that already exists twice in detail.tsx (lines ~303-313 and ~340-349, both pre-existing before this PR). This PR adds a third, byte-for-byte identical copy instead of extracting a shared utility. Not a correctness bug today (all three copies are identical), but it's exactly the kind of duplication that silently diverges later if only one copy gets fixed.
  • Issue 2 (dead/unreachable labels): pinMetricLabel in detail.tsx defines label entries for transformRecordsIn, transformRecordsOut, and sinkRecordsIn, but no "Pin" button in the drawer wires up those metric keys (only transformBusyRatio/transformProcessNsPerRecord for transform, sinkBusyRatio/sinkWriteNsPerRecord for sink). Harmless (unreachable code, not a bug), likely leftover from an earlier iteration of the button list.

1.2 Compatibility Impact

Fully compatible — purely additive UI, no API/config changes, no impact on backend or persisted state.

1.3 Performance / Side-Effect Analysis

  • New dependency echarts@^6.1.0 is added via tree-shaken echarts/core imports, not the full bundle — reasonable choice for bundle size.
  • LiveMetricsChart watches props.series with { deep: true } (index.tsx:139-143). With up to 6 pinned series × up to ~300 points each (10-minute window at typical sample density) refreshed every 2s, Vue must deep-diff that whole nested array every poll cycle purely to decide whether to call setOption. This is bounded and should be fine at the documented scale, but it's worth being aware it doesn't scale gracefully if the pin limit or window is ever raised — a shallow trigger (e.g. bump a version counter alongside the data instead of deep-watching the array) would be cheaper. Not a blocker at the current bounds.
  • No new per-pin HTTP requests (confirmed above) — good, avoids the "N pins = N pollers" trap this kind of feature can easily fall into.

1.4 Error Handling and Logging

N/A — pure frontend rendering logic over already-validated data; existing realtimeError handling in detail.tsx is untouched.

Issue 3

  • Location: seatunnel-engine/seatunnel-engine-ui/src/views/jobs/detail.tsx (end of file), src/locales/en_US/detail.ts, src/locales/zh_CN/detail.ts
  • Problem description: all three files end without a trailing newline (\ No newline at end of file), and an unrelated tab→space reindentation of the top <div class="font-bold text-xl"> block is mixed into this feature diff.
  • Potential risk: none functionally; likely to trip a repo lint/format check (Prettier/ESLint) if one is configured for this frontend, and the reindentation is unrelated scope creep in an otherwise-clean diff.
  • Best improvement: restore trailing newlines, keep unrelated formatting changes out of feature PRs.
  • Severity: Low
  • Raised by another reviewer: No

2. Code Quality Assessment

2.1 Coding Standards

New component/composable both carry the ASF license header and reasonable interface-level doc comments (PinnedMetric fields are individually commented). No missing-doc concerns for the public surface added here.

2.2 Test Coverage and Test Stability

No test files were added or modified for usePinnedMetrics.ts or live-metrics-chart/index.tsx. Given seatunnel-engine-ui already has a vitest dev-dependency in package.json, a unit test for usePinnedMetrics (pin/dedupe/limit/clear behavior, and getPinnedSeriesData's edge queueId decoding) would be straightforward and valuable, especially since getPinnedSeriesData's edge-matching logic is non-trivial (negative-queueId decoding) and untested. Rating: Risk present — not because anything is flaky, but because a non-trivial pure-logic module (dedupe, limit enforcement, ID decoding) shipped with zero test coverage.

2.3 Documentation Updates

No docs/en/docs/zh user-facing documentation update accompanies this feature (e.g. web-ui.md or the Zeta user guide). Per @det101's design discussion on #11666, the plan was for user docs to land "together with the implementation PR once the feature ships" — so this is expected to still be missing at this stage, but it will need to land before/with whichever PR actually ships the feature.

3. Architectural Soundness

3.1 Elegance of the Solution

Reasonable and consistent with the already-agreed design direction on #11666 (ECharts, max 6 pins, reuse existing polling) — the concern here is not the shape of the solution but who should be building it and whether the still-open layout feedback has been addressed.

3.2 Maintainability

Mostly good; see Issue 1 (helper duplication) above.

3.3 Extensibility

Fine — the pin/series abstraction is generic enough to extend to more metric keys without structural changes.

3.4 Historical-Version Compatibility

N/A — frontend-only, no persisted state.

4. Issue Summary

# Issue Location Severity
0 Implements the same feature already claimed and actively designed by @det101 on #11666, without visible coordination or handoff; a maintainer request to confirm coordination is unanswered Issue #11666 / this PR High (process)
1 decodeTargetVertexId duplicated a third time instead of extracted to a shared utility usePinnedMetrics.ts:98-104 (dup of detail.tsx:303-313, 340-349) Low
2 Unreachable label entries (transformRecordsIn, transformRecordsOut, sinkRecordsIn) with no corresponding pin button detail.tsx pinMetricLabel Low
3 Missing trailing newlines + unrelated reindentation mixed into the diff detail.tsx, both locale files Low

5. Merge Recommendation

Conclusion: Not recommended for merge

  1. Blockers — must be fixed:
    • Issue 0: this needs to be resolved as a community/process matter before code review outcome matters — either @zhang-arvin gets explicit confirmation from @det101/a maintainer that they're taking over #11666 (and the still-open layout-scalability feedback from @nzw921rx is folded in), or this PR should be closed/repurposed in favor of continuing @det101's already-further-along design. Please respond to @goutamadwant's question on the PR.
  2. Recommended fixes — non-blocking (useful regardless of which implementation proceeds):
    • Issue 1: extract the duplicated decodeTargetVertexId helper to a shared module.
    • Issue 2: remove or wire up the unused label entries.
    • Issue 3: restore trailing newlines and drop the unrelated reindentation.
    • Add unit tests for usePinnedMetrics (pin/dedupe/limit/clear, edge queueId decoding).

Overall assessment: the implementation itself is competent — correct ECharts lifecycle management, no leaked observers/instances, no N+1 polling, reasonable bounds — but it exists in direct, currently-unacknowledged tension with an already-claimed, further-along, in-design-review feature on the same issue. That needs to be sorted out first; I'd rather see this energy redirected into helping land @det101's version (including the outstanding layout feedback) than have two competing implementations racing to merge.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature][Zeta] Add a selectable live metrics chart for running jobs

3 participants