Skip to content

Fixes #30895: Complete Metrics hierarchy and details - #30896

Open
harshach wants to merge 2 commits into
mainfrom
harshach/metrics-prototype
Open

Fixes #30895: Complete Metrics hierarchy and details#30896
harshach wants to merge 2 commits into
mainfrom
harshach/metrics-prototype

Conversation

@harshach

@harshach harshach commented Aug 3, 2026

Copy link
Copy Markdown
Collaborator

Describe your changes:

Fixes #30895

I completed the Metrics hierarchy and full detail experience because the existing flat view did not scale to grouped metrics or expose their governance, assets, observability, activity, and approval context.

Type of change:

  • Bug fix
  • Improvement
  • New feature
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation

High-level design:

  • Adds schema-first Metric Groups, parent/child hierarchy context, paginated directional assets, observability contracts, search indexes, and MySQL/PostgreSQL 2.1.0 migrations.
  • Enforces group inheritance and hierarchy integrity in repositories, derives health from upstream table and column tests, and reuses generic lineage, task, notification, history, and workflow infrastructure for approval and rollback.
  • Rebuilds the Metric list and detail route with Untitled UI for Overview, Lineage, Assets, Observability, Activity & Tasks, and Approval Workflow, including responsive, accessible, localized, and dark-mode states.
  • Metric Preview, execution, Current Value, Value Trend, Freshness/SLA, export/import, and custom lineage UI remain outside this change.

Tests:

Use cases covered

  • Group, root, and child metric creation, inheritance, navigation, filtering, expansion, and pagination.
  • Directional asset management, lineage columns, aggregate observability, source redaction, and incident/test rollups.
  • Automatic approval, reviewer decisions, rejection, update rollback, activity, comments, mentions, and tasks.

Unit tests

  • Added Java unit tests for changed repositories, resources, mappers, search indexes, observability, workflow rollback, and permission logic; 79 focused backend tests pass.
  • Added UI component, hook, utility, accessibility, and Untitled-import regression tests; 87 focused UI tests pass, plus 7 related-metric tests after rebasing.

Backend integration tests

  • Added integration coverage for Metric Group and Metric resources, hierarchy/assets/observability/approval behavior, MCP consumers, and MySQL/PostgreSQL migrations.
  • Full MySQL/PostgreSQL integration matrices were not run locally and are left to CI.

Ingestion integration tests

  • Not applicable (no ingestion changes).

Playwright (UI) tests

  • Added Metric hierarchy, governance, activity/tasks, responsive, dark-mode, and visual-regression coverage; focused deployed-stack workflows pass locally.

Manual testing performed

  1. Built the UI and server, then started an isolated MySQL/Elasticsearch/OpenMetadata Docker stack with sample Metric Groups, roots, and variants.
  2. Verified list/detail navigation, default group expansion, left-aligned responsive layouts, assets, observability, activity/tasks, approvals, and generated visual states as admin.

UI screen recording / screenshots:

Metric list

Metric overview

Additional desktop, narrow, dark-mode, Assets, Observability, Activity, and Approval baselines are committed beside these screenshots.

Checklist:

  • I have read the CONTRIBUTING document.
  • My PR title is Fixes <issue-number>: <short explanation>
  • My PR is linked to a GitHub issue via Fixes #<issue-number> above.
  • I have commented on my code, particularly in hard-to-understand areas.
  • For JSON Schema changes: I updated the migration scripts or explained why it is not needed.
  • For UI changes: I attached a screen recording and/or screenshots above.
  • I have added tests (unit / integration / Playwright as applicable) and listed them above.

@github-actions github-actions Bot added backend safe to test Add this label to run secure Github workflows on PRs labels Aug 3, 2026
@harshach
harshach marked this pull request as ready for review August 3, 2026 19:59
@harshach
harshach requested a review from a team as a code owner August 3, 2026 19:59
Copilot AI review requested due to automatic review settings August 3, 2026 19:59
@harshach
harshach requested review from a team, chirag-madlani and karanh37 as code owners August 3, 2026 19:59
@greptile-apps

greptile-apps Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Too many files changed for review. (284 files found, 100 file limit)

Bypass the limit by tagging @greptile-apps to review.

Copilot AI 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.

Copilot wasn't able to review this pull request because it exceeds the maximum number of lines (20,000). Try reducing the number of changed lines and requesting a review from Copilot again.

@github-actions

github-actions Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

❌ PR checklist incomplete

This PR cannot be merged until the following are addressed on its linked issue:

The fields live on the linked issue in the Shipping project (open the issue → right sidebar → Projects). After you set them, re-run this check (or push a commit) — issue/project changes do not re-trigger it automatically.

Maintainers can bypass this check by adding the skip-pr-checks label.

Comment on lines +1157 to +1164
repository.get(null, id, repository.getFields("id"));
Set<UUID> visibleAssets = new HashSet<>();
for (MetricAssetDirection linked : repository.getAssetsWithDirection(id)) {
if (canViewAsset(securityContext, linked.getAsset())) {
visibleAssets.add(linked.getAsset().getId());
}
}
return repository.getObservability(id, visibleAssets);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Performance: Observability endpoint fetches linked assets twice

getObservability() calls repository.getAssetsWithDirection(id) in the resource to build the visibleAssets set (and runs a per-asset authorize() for each linked asset), then calls repository.getObservability(id, visibleAssets), whose compute() invokes metricRepository.getAssetsWithDirection(metricId) a second time. Each getAssetsWithDirection walks lineage for every linked asset, so it runs the full asset+lineage resolution twice per request. Consider passing the already-resolved linkedAssets into the builder (e.g. an overload of build/compute that accepts the pre-fetched List) so the lineage scan runs once.

Was this helpful? React with 👍 / 👎

Comment on lines +388 to +402
int visibleMetricCount(UUID groupId, Predicate<EntityReference> isVisible) {
CollectionDAO.MetricGroupDAO groupDAO = (CollectionDAO.MetricGroupDAO) dao;
return scanMemberIds(groupDAO, groupId, 0, 0, null, "%", false, isVisible).total();
}

private MemberScan scanMemberIds(
CollectionDAO.MetricGroupDAO groupDAO,
UUID groupId,
int limit,
int offset,
String query,
String nameLike,
boolean rootOnly,
Predicate<EntityReference> isVisible) {
List<UUID> page = new ArrayList<>();

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Performance: Metric group member listing scans all members per page/count

scanMemberIds() always walks every member of a group in MEMBER_SCAN_BATCH_SIZE (200) batches — issuing loadMetricReferences() (and, for rootOnly, subtreeMatchesQuery()->expandSubtree()) on each batch — because it must compute the visible total and skip to the offset with permission filtering applied in Java. visibleMetricCount() does the same full scan just to count. For groups with many members this is O(n) DB round trips on every /metricGroups/{id}/metrics request and every count, regardless of the requested page size. This is inherent to permission-aware pagination, but for large groups it can become a hot-path scalability issue; consider caching the visible count or bounding the scan.

Was this helpful? React with 👍 / 👎

@github-actions

github-actions Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

✅ TypeScript Types Auto-Updated

The generated TypeScript types have been automatically updated based on JSON schema changes in this PR.

Copilot AI review requested due to automatic review settings August 3, 2026 20:04

Copilot AI 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.

Copilot wasn't able to review this pull request because it exceeds the maximum number of lines (20,000). Try reducing the number of changed lines and requesting a review from Copilot again.

@gitar-bot

gitar-bot Bot commented Aug 3, 2026

Copy link
Copy Markdown
Code Review 👍 Approved with suggestions 0 resolved / 2 findings

Completes the metrics hierarchy and detail experience with new schema-first groups, search indexes, and UI views. Consider optimizing the observability endpoint asset fetching and metric group member pagination scans to avoid redundant queries.

💡 Performance: Observability endpoint fetches linked assets twice

📄 openmetadata-service/src/main/java/org/openmetadata/service/resources/metrics/MetricResource.java:1157-1164 📄 openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/MetricObservabilityBuilder.java:154-168

getObservability() calls repository.getAssetsWithDirection(id) in the resource to build the visibleAssets set (and runs a per-asset authorize() for each linked asset), then calls repository.getObservability(id, visibleAssets), whose compute() invokes metricRepository.getAssetsWithDirection(metricId) a second time. Each getAssetsWithDirection walks lineage for every linked asset, so it runs the full asset+lineage resolution twice per request. Consider passing the already-resolved linkedAssets into the builder (e.g. an overload of build/compute that accepts the pre-fetched List) so the lineage scan runs once.

💡 Performance: Metric group member listing scans all members per page/count

📄 openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/MetricGroupRepository.java:388-402

scanMemberIds() always walks every member of a group in MEMBER_SCAN_BATCH_SIZE (200) batches — issuing loadMetricReferences() (and, for rootOnly, subtreeMatchesQuery()->expandSubtree()) on each batch — because it must compute the visible total and skip to the offset with permission filtering applied in Java. visibleMetricCount() does the same full scan just to count. For groups with many members this is O(n) DB round trips on every /metricGroups/{id}/metrics request and every count, regardless of the requested page size. This is inherent to permission-aware pagination, but for large groups it can become a hot-path scalability issue; consider caching the visible count or bounding the scan.

🤖 Prompt for agents
Code Review: Completes the metrics hierarchy and detail experience with new schema-first groups, search indexes, and UI views. Consider optimizing the observability endpoint asset fetching and metric group member pagination scans to avoid redundant queries.

1. 💡 Performance: Observability endpoint fetches linked assets twice
   Files: openmetadata-service/src/main/java/org/openmetadata/service/resources/metrics/MetricResource.java:1157-1164, openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/MetricObservabilityBuilder.java:154-168

   getObservability() calls repository.getAssetsWithDirection(id) in the resource to build the visibleAssets set (and runs a per-asset authorize() for each linked asset), then calls repository.getObservability(id, visibleAssets), whose compute() invokes metricRepository.getAssetsWithDirection(metricId) a second time. Each getAssetsWithDirection walks lineage for every linked asset, so it runs the full asset+lineage resolution twice per request. Consider passing the already-resolved linkedAssets into the builder (e.g. an overload of build/compute that accepts the pre-fetched List<MetricAssetDirection>) so the lineage scan runs once.

2. 💡 Performance: Metric group member listing scans all members per page/count
   Files: openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/MetricGroupRepository.java:388-402

   scanMemberIds() always walks every member of a group in MEMBER_SCAN_BATCH_SIZE (200) batches — issuing loadMetricReferences() (and, for rootOnly, subtreeMatchesQuery()->expandSubtree()) on each batch — because it must compute the visible total and skip to the offset with permission filtering applied in Java. visibleMetricCount() does the same full scan just to count. For groups with many members this is O(n) DB round trips on every /metricGroups/{id}/metrics request and every count, regardless of the requested page size. This is inherent to permission-aware pagination, but for large groups it can become a hot-path scalability issue; consider caching the visible count or bounding the scan.

Options

Display: compact → Showing less information.

Comment with these commands to change the behavior for this request:

Compact
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Gitar | Powered by Gitar — free for open source

@github-actions

github-actions Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

❌ UI Checkstyle Failed

❌ Antd + Less Deprecation Guard

A new antd import or new .less file was added. Use UntitledUI + Tailwind for new work.

Affected files

openmetadata-ui/src/main/resources/ui/src/components/common/Table/TableV2.test.tsx: import type { ColumnsType } from 'antd/es/table/interface'

🔍 ESLint findings in this PR's files — ESLint report could not be read — see the job log.

Errors block the build. Warnings do not yet — they are rules whose backlog is still
being worked down, listed so this PR does not add to it. See docs/ui-code-quality-gate.md.

No machine-readable report was produced.


Fix locally (fast - only checks files changed in this branch):

make ui-checkstyle-changed

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

Labels

backend safe to test Add this label to run secure Github workflows on PRs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Complete Metrics hierarchy and detail experience

2 participants