Skip to content

feat(metrics): initialise MULTIPLEXED_METRIC_ROUTING_KEY for routing#19096

Closed
harshit078 wants to merge 28 commits intogetsentry:developfrom
harshit078:routing-to-different-dsn
Closed

feat(metrics): initialise MULTIPLEXED_METRIC_ROUTING_KEY for routing#19096
harshit078 wants to merge 28 commits intogetsentry:developfrom
harshit078:routing-to-different-dsn

Conversation

@harshit078
Copy link
Copy Markdown
Contributor

@harshit078 harshit078 commented Jan 29, 2026

Before submitting a pull request, please take a look at our
Contributing guidelines and verify:

  • If you've added code that should be tested, please add tests.
  • Ensure your code lints and the test suite passes (yarn lint) & (yarn test).
  • Link an issue if there is one related to your pull request. If no issue is linked, one will be auto-generated and linked.

Closes #18913

What changed

  • implemented attribute-based routing for metrics
  • added MetricRoutingInfo with dsn and release as its field
  • added routing to MetricOptions and enabled captureMetric to inject routing info into attributes
  • similarly added routing to InternalCaptureMetricOptions
  • created _stripRoutingAttributes function which removes routing info before sending to sentry

@harshit078 harshit078 marked this pull request as ready for review February 2, 2026 12:05
@harshit078
Copy link
Copy Markdown
Contributor Author

Hi @chargome, the PR is ready to review. Thanks !

@Lms24 Lms24 requested a review from chargome February 4, 2026 09:05
Copy link
Copy Markdown
Member

@chargome chargome left a comment

Choose a reason for hiding this comment

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

Nice, thanks for opening the PR! I left some comments. Also, we definitely want to test this behaviour somehow in a browser integration test.

const container = Array.isArray(item) ? (item[1] as SerializedMetricContainer) : undefined;
const containerItems = container?.items;
if (containerItems) {
metric = containerItems[0];
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Wouldn't this mean we always just pull the first metric?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

yes it would mean we pull the first metric. What I'm thinking now after your comment is that I can add a logic which will check if all metrics and route to same or multiple destinations. Whats your opinion ?

@harshit078 harshit078 requested a review from chargome February 6, 2026 12:50
Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

@chargome chargome self-assigned this Feb 12, 2026
@andreiborza
Copy link
Copy Markdown
Member

Unrelated to this PR, I sent you an email @harshit078. Let me know if you have any questions about it.

@harshit078
Copy link
Copy Markdown
Contributor Author

Hey @andreiborza , I got the email sent by you and I just replied back to it ;)

Copy link
Copy Markdown
Member

@chargome chargome left a comment

Choose a reason for hiding this comment

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

Thinking about this again I think we're facing a fundamental design issue here. We always batch metrics into one envelope for sending them. So whatever routing destination the first metric in the envelope has will overrule the others. Same for applying the release as attribute. We would therefore need to split up the envelopes per routing destination before sending them. I'm currently leaning against having that much logic for this feature and this increasing bundle size unless we get a clear signal from the users that we should support this. We might even want to partition the buffer onto DSNs.

Summed up, this approach is too brittle atm. Sorry for the back and forth on this one but I will close the PR and resolve this internally once needed!

getSpanStatusFromHttpCode,
setHttpStatus,
makeMultiplexedTransport,
MULTIPLEXED_TRANSPORT_EXTRA_KEY,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is still a breaking change

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.

Support routing metrics to different DSNs in MFE setup

3 participants