Skip to content

feat(observability): make project-level log component names clickable#643

Open
kavix wants to merge 5 commits into
openchoreo:mainfrom
kavix:feat/clickable-log-components
Open

feat(observability): make project-level log component names clickable#643
kavix wants to merge 5 commits into
openchoreo:mainfrom
kavix:feat/clickable-log-components

Conversation

@kavix

@kavix kavix commented Jun 18, 2026

Copy link
Copy Markdown

Purpose

Resolves #3436

In the project-level logging view, log records include the component name as plain text. This PR makes the component name a clickable link that navigates directly to that component's logging view, making it much easier to drill down from project logs to component logs.

Goals

  • Make the componentName field in the LogEntry table a clickable React <Link>.
  • Preserve the current time range and relevant filters (e.g., environment, log level) by passing location.search to the target URL.

Approach

  • Updated LogEntry.tsx in openchoreo-observability to wrap the ComponentName field with @backstage/core-components Link.
  • Used useLocation from react-router-dom to dynamically append current URL search params to the target component's route, preserving all active filters and time ranges automatically.
  • Updated LogEntry.test.tsx to wrap the component in a <MemoryRouter> to satisfy react-router-dom hooks.
  • Added a .changeset file for the @openchoreo/backstage-plugin-openchoreo-observability package.

User stories

  • As a developer, when I see an error from component X in the project logs, I want to click the component name to navigate to all of component X's logs without having to manually navigate there or re-apply my filters.

Release note

Added clickable component names in the project-level logging view to seamlessly navigate to component-scoped logs while preserving active filters.

Documentation

N/A - Minor UI improvement to existing logging view.

Training

N/A

Certification

N/A

Marketing

N/A

Automation tests

  • Unit tests

    Updated LogEntry.test.tsx to ensure proper routing context using MemoryRouter. All existing snapshot and behavior tests pass with the new Link structure.

  • Integration tests

    No changes needed.

Security checks

Samples

N/A

Related PRs

None.

Migrations (if applicable)

N/A

Test environment

  • Tested on local k3d developer environment.

Learning

  • Explored how Backstage core components handle routing and query parameter preservation using useLocation.

Summary by CodeRabbit

  • New Features
    • Component names in the project-level logging view are now clickable, taking you to the component-scoped logging view while keeping the current time range and active filters.
  • Tests
    • Updated and added coverage to ensure the component name renders as a navigation link with the expected URL behavior.

@coderabbitai

coderabbitai Bot commented Jun 18, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 5167d8ef-9958-4853-ae06-e5db9fb14809

📥 Commits

Reviewing files that changed from the base of the PR and between f1d26ab and 6c65bd1.

📒 Files selected for processing (5)
  • plugins/openchoreo-observability/src/components/RuntimeLogs/LogEntry.test.tsx
  • plugins/openchoreo-observability/src/components/RuntimeLogs/LogEntry.tsx
  • plugins/openchoreo-observability/src/components/RuntimeLogs/LogsTable.tsx
  • plugins/openchoreo-observability/src/components/RuntimeLogs/ObservabilityProjectRuntimeLogsPage.tsx
  • plugins/openchoreo-observability/src/components/RuntimeLogs/ObservabilityRuntimeLogsPage.tsx
🚧 Files skipped from review as they are similar to previous changes (2)
  • plugins/openchoreo-observability/src/components/RuntimeLogs/LogEntry.tsx
  • plugins/openchoreo-observability/src/components/RuntimeLogs/LogEntry.test.tsx

📝 Walkthrough

Walkthrough

LogEntry now renders the ComponentName column as a clickable Link by importing Link and useLocation, capturing the current router location, and building runtime-logs URLs with entity metadata. Entity context flows from pages through LogsTable to LogEntry via props. Tests are wrapped in MemoryRouter, and a minor changeset entry documents the feature.

Changes

Clickable Component Names in LogEntry

Layer / File(s) Summary
LogEntry interface and routing imports
plugins/openchoreo-observability/src/components/RuntimeLogs/LogEntry.tsx
Adds Link and useLocation imports along with runtime-logs path construction and Entity typing. LogEntryProps is extended with optional entityNamespace and entityKind fields.
LogEntry ComponentName cell rendered as router Link
plugins/openchoreo-observability/src/components/RuntimeLogs/LogEntry.tsx
Captures current router location via useLocation() hook and replaces the plain-text ComponentName cell with a conditional Link that appends location.search to the component runtime-logs route, calls e.stopPropagation() to prevent row expansion.
LogsTable interface and entity metadata propagation
plugins/openchoreo-observability/src/components/RuntimeLogs/LogsTable.tsx
LogsTableProps is extended with optional entityNamespace and entityKind fields. Component destructures these props and forwards them to each rendered LogEntry instance.
Page-level entity metadata provisioning
plugins/openchoreo-observability/src/components/RuntimeLogs/ObservabilityProjectRuntimeLogsPage.tsx, plugins/openchoreo-observability/src/components/RuntimeLogs/ObservabilityRuntimeLogsPage.tsx
Both pages provide entityNamespace and entityKind props to LogsTable, sourced from the current entity's metadata and kind.
Test harness router setup and ComponentName link verification
plugins/openchoreo-observability/src/components/RuntimeLogs/LogEntry.test.tsx
MemoryRouter is imported and wraps LogEntry in the Harness component to provide router context. A new test case verifies that ComponentName renders as a link with the correct runtime-logs href.
Changeset entry for minor release
.changeset/clickable-log-components.md
Adds a changeset entry marking a minor version bump for @openchoreo/backstage-plugin-openchoreo-observability and describing the clickable component names feature.

Sequence Diagram

sequenceDiagram
  participant User
  participant LogEntry
  participant ReactRouter
  participant ComponentLogsPage
  User->>LogEntry: clicks ComponentName cell
  LogEntry->>LogEntry: e.stopPropagation()
  LogEntry->>ReactRouter: navigate to /catalog/{entityNamespace}/component/{componentName}/runtime-logs + location.search
  ReactRouter->>ComponentLogsPage: render with preserved time range & filters
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Suggested reviewers

  • sameerajayasoma
  • stefinie123
  • kaviththiranga

Poem

🐇 Hop, hop, a name's no longer plain,
Now click a component, follow the lane!
The time range and filters ride along free,
location.search keeps the query spree.
A tiny stopPropagation keeps rows still—
Clickable logs, what a delightful thrill! 🪵

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: making component names clickable in project-level logs.
Description check ✅ Passed The description comprehensively addresses all required template sections with detailed information about purpose, goals, approach, testing, and security checks.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
plugins/openchoreo-observability/src/components/RuntimeLogs/LogEntry.test.tsx (1)

52-56: ⚡ Quick win

Add a route-preservation assertion for location.search.

The router wrapper is correct, but this setup still doesn’t protect the core behavior added in LogEntry (carrying query params to the component link). Consider using MemoryRouter initialEntries with a query string and asserting the rendered href includes it.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@plugins/openchoreo-observability/src/components/RuntimeLogs/LogEntry.test.tsx`
around lines 52 - 56, The MemoryRouter wrapper in the render function needs to
be configured to pass a query string via initialEntries, and the test needs an
assertion to verify that the rendered LogEntry component's link href includes
those query parameters. Modify the MemoryRouter to include an initialEntries
prop with a URL containing a query string (e.g., path with ?param=value), then
add an assertion that checks the href attribute of the rendered link element in
LogEntry includes that query string parameter to ensure the component properly
preserves route search parameters.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@plugins/openchoreo-observability/src/components/RuntimeLogs/LogEntry.tsx`:
- Line 155: The route being built in the `to` prop at line 155 hardcodes
`default/component` in the URL path, but the runtime-logs route requires dynamic
namespace and kind values to work correctly for entities outside the default
namespace. Replace the hardcoded `default/component` with actual entityNamespace
and entityKind values obtained from parent context or a canonical entity
reference, using `default/component` only as an explicit fallback when these
values are not available. This ensures the navigation route correctly matches
the entity's actual namespace and kind.

---

Nitpick comments:
In
`@plugins/openchoreo-observability/src/components/RuntimeLogs/LogEntry.test.tsx`:
- Around line 52-56: The MemoryRouter wrapper in the render function needs to be
configured to pass a query string via initialEntries, and the test needs an
assertion to verify that the rendered LogEntry component's link href includes
those query parameters. Modify the MemoryRouter to include an initialEntries
prop with a URL containing a query string (e.g., path with ?param=value), then
add an assertion that checks the href attribute of the rendered link element in
LogEntry includes that query string parameter to ensure the component properly
preserves route search parameters.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: d556478f-92ec-4957-b67e-e8f0a4dc32e6

📥 Commits

Reviewing files that changed from the base of the PR and between 8381554 and f1d26ab.

📒 Files selected for processing (3)
  • .changeset/clickable-log-components.md
  • plugins/openchoreo-observability/src/components/RuntimeLogs/LogEntry.test.tsx
  • plugins/openchoreo-observability/src/components/RuntimeLogs/LogEntry.tsx

Comment thread plugins/openchoreo-observability/src/components/RuntimeLogs/LogEntry.tsx Outdated
{log.metadata?.componentName ?? componentName ?? ''}
{compName ? (
<Link
to={`/catalog/${entityNamespace?.toLocaleLowerCase() || 'default'}/${entityKind?.toLocaleLowerCase() || 'component'}/${compName}/runtime-logs${location.search}`}

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.

Let's reuse the buildRuntimeLogsBasePath from openchoreo-react plugin to derive the runtime logs url here

@kavix kavix Jun 19, 2026

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

@stefinie123 Done! Refactored the code to import and use buildRuntimeLogsBasePath(entity) from @openchoreo/backstage-plugin-react

);
};
return render(<Harness />);
}

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.

Lets add a new test to assert the navigation capability added by this PR

@kavix kavix Jun 19, 2026

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

@stefinie123 Done! Added a new test navigates to component runtime logs and stops propagation on component name link click which renders the component inside a MemoryRouter wrapper to assert that:

  1. Clicking the link updates the browser location path to the derived runtime logs URL.
  2. onToggleExpand is not invoked (confirming that click propagation is successfully stopped so the row doesn't toggle).

… link and add tests

Signed-off-by: kavix <kavix@yahoo.com>
@kavix kavix requested a review from stefinie123 June 19, 2026 10:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants