Skip to content

feat: Auto-link correlated sources bidirectionally #990

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jul 24, 2025

Conversation

dhable
Copy link
Contributor

@dhable dhable commented Jul 10, 2025

Automatically maintain bidirectional relationships between correlated sources. When a user selects a correlated source (e.g., Log → Metric), the target source is updated to link back (Metric → Log) if not already linked.

  • Works for both new and existing sources
  • Preserves existing correlations (no overwriting)
  • Improves data consistency across the application

Automatically maintain bidirectional relationships between correlated sources.
When a user selects a correlated source (e.g., Log → Metric), the target
source is updated to link back (Metric → Log) if not already linked.

- Works for both new and existing sources
- Preserves existing correlations (no overwriting)
- Improves data consistency across the application
Copy link

changeset-bot bot commented Jul 10, 2025

🦋 Changeset detected

Latest commit: 1aeffc5

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

This PR includes changesets to release 2 packages
Name Type
@hyperdx/app Minor
@hyperdx/api Minor

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

Copy link

vercel bot commented Jul 10, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
hyperdx-v2-oss-app ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 23, 2025 10:24pm

Copy link
Contributor

github-actions bot commented Jul 10, 2025

Stably Runner - Test Suite - 'Smoke Test'

Test Suite Run Result: 🟢 Success (4/4 tests passed) [dashboard]


This comment was generated from stably-runner-action

const currentSourceId = watch('id');

useEffect(() => {
const { unsubscribe } = watch(async (_value, { name, type }) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this particular watch signature is deprecated in favor of subscribe https://react-hook-form.com/docs/useform/subscribe

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, it's listed in the docs as deprecated and spelunking the react-hook-form releases this happened in v7.55.0 (commit 7f95b26). There is no subscribe handler available until that revision.

We're currently using v7.43.8 so moving to the subscribe approach would require buying into 12 possible breaking version bumps. Do we want to tackle that upgrade effort in this PR or make it a separate effort?

const previouslyLinkedSource = sources.find(
s =>
s.kind === targetKind &&
(s as any)[targetField] === currentSourceId,
Copy link
Contributor

Choose a reason for hiding this comment

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

nit any

Copy link
Contributor Author

@dhable dhable Jul 23, 2025

Choose a reason for hiding this comment

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

Removed.

});

return () => unsubscribe();
}, [watch, kind, currentSourceId, sources, updateSource]);
Copy link
Contributor

Choose a reason for hiding this comment

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

just wondering if circular dependencies are possible here...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There is code to only set the bidirectional link if the other side of the link doesn't have a value. That should prevent infinite update loops as well as allowing users to setup more complex correlation DAGs.

Is that what you were getting at?

Copy link
Contributor

@teeohhem teeohhem left a comment

Choose a reason for hiding this comment

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

Mind adding a test or two for this?

Added a few comments/questions

@kodiakhq kodiakhq bot merged commit bb37520 into main Jul 24, 2025
8 checks passed
@kodiakhq kodiakhq bot deleted the hdx-1556/linking-sources branch July 24, 2025 15:42
wrn14897 pushed a commit that referenced this pull request Jul 24, 2025
Automatically maintain bidirectional relationships between correlated sources. When a user selects a correlated source (e.g., Log → Metric), the target source is updated to link back (Metric → Log) if not already linked.

- Works for both new and existing sources
- Preserves existing correlations (no overwriting)
- Improves data consistency across the application
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants