Skip to content

feat(types): Add organization ID parsing for DSNs#1202

Open
szokeasaurusrex wants to merge 9 commits into
masterfrom
szokeasaurusrex/org-id-dsn-parse
Open

feat(types): Add organization ID parsing for DSNs#1202
szokeasaurusrex wants to merge 9 commits into
masterfrom
szokeasaurusrex/org-id-dsn-parse

Conversation

@szokeasaurusrex

@szokeasaurusrex szokeasaurusrex commented Jun 25, 2026

Copy link
Copy Markdown
Member

Expose Dsn::org_id so callers can derive the SDK organization ID needed for strict trace continuation. Parse only Sentry SaaS ingest DSN hosts, including regional hosts, and return None for self-hosted, Relay, malformed, and overflow cases.

Closes #1159
Closes RUST-233

@github-actions

github-actions Bot commented Jun 25, 2026

Copy link
Copy Markdown
Messages
📖 Do not forget to update Sentry-docs with your feature once the pull request gets approved.

Generated by 🚫 dangerJS against b72fb2d

@szokeasaurusrex
szokeasaurusrex force-pushed the szokeasaurusrex/org-id-dsn-parse branch from cbde4ff to 53bd774 Compare June 25, 2026 13:08
@szokeasaurusrex
szokeasaurusrex marked this pull request as ready for review June 25, 2026 13:10
@szokeasaurusrex
szokeasaurusrex requested a review from lcian as a code owner June 25, 2026 13:10
@linear-code

linear-code Bot commented Jun 25, 2026

Copy link
Copy Markdown

RUST-233

@lcian
lcian removed their request for review June 25, 2026 14:02
@szokeasaurusrex
szokeasaurusrex force-pushed the szokeasaurusrex/org-id-dsn-parse branch from 53bd774 to d8f38f3 Compare July 7, 2026 11:05
@szokeasaurusrex
szokeasaurusrex requested a review from a team as a code owner July 7, 2026 11:05
@szokeasaurusrex
szokeasaurusrex force-pushed the szokeasaurusrex/org-id-dsn-parse branch from d8f38f3 to 08f1a80 Compare July 8, 2026 13:56
@szokeasaurusrex
szokeasaurusrex changed the base branch from master to szokeasaurusrex/sampling-strat July 8, 2026 13:56
@szokeasaurusrex
szokeasaurusrex force-pushed the szokeasaurusrex/org-id-dsn-parse branch from 08f1a80 to cb59fdf Compare July 8, 2026 14:04
@szokeasaurusrex
szokeasaurusrex requested review from Litarnus and giortzisg and removed request for alexander-alderman-webb July 20, 2026 15:07
Make the `ClientOptions` struct `#[non_exhaustive]`.

Users will now have to rely on the builder methods to construct `ClientOptions`. This change will allow us to introduce new configuration options in future SDK releases without requiring a breaking release.

Closes [#1219](#1219)
Closes [RUST-258](https://linear.app/getsentry/issue/RUST-258)
@szokeasaurusrex
szokeasaurusrex force-pushed the szokeasaurusrex/sampling-strat branch from a32eb15 to ce74a79 Compare July 20, 2026 15:52
@szokeasaurusrex
szokeasaurusrex force-pushed the szokeasaurusrex/org-id-dsn-parse branch from cb59fdf to 28f70b6 Compare July 20, 2026 15:53
Enable the `logs` and `metrics` features in the default feature set and update the crate documentation to reflect the new defaults and telemetry behavior.

Resolves [#1104](#1104)
Resolves [RUST-206](https://linear.app/getsentry/issue/RUST-206/enable-logging-by-default-rust)
@szokeasaurusrex
szokeasaurusrex force-pushed the szokeasaurusrex/sampling-strat branch from ce74a79 to 221c434 Compare July 20, 2026 16:23
@szokeasaurusrex
szokeasaurusrex force-pushed the szokeasaurusrex/org-id-dsn-parse branch from 28f70b6 to f8efddc Compare July 20, 2026 16:23
Update changelog with pull request number
Represent traces sampling as a single strategy enum so that leaving tracing unset
is different from explicitly configuring a fixed sample rate of `0.0`. This keeps
sampler callbacks, fixed rates, and disabled tracing mutually exclusive instead
of modeling impossible combinations.

This does not fully implement deferred trace propagation semantics yet. It makes
the public API capable of representing the distinction the propagation spec needs,
so a future implementation can treat unset tracing config differently from an
explicit zero sample rate without another public API change.

Update transaction sampling tests and the changelog for the enum-based behavior,
including that disabled tracing never samples even when the transaction context
carries an explicit sampling decision.

BREAKING CHANGE: `ClientOptions::traces_sample_rate` and `ClientOptions::traces_sampler` fields are replaced by `ClientOptions::traces_sampling_strategy`.
Replace the public `ClientOptions::sample_rate` field with an `EventSamplingStrategy` enum while preserving the existing `sample_rate(...)` builder API for fixed-rate event sampling.

This mirrors the traces sampling model and unblocks #1127 by making it possible to add a sampling function variant to `EventSamplingStrategy` without another public field replacement.

BREAKING CHANGE: Remove the public `ClientOptions::sample_rate` field. Use `ClientOptions::event_sampling_strategy` to inspect event sampling configuration, and continue using `ClientOptions::sample_rate(...)` to configure a fixed sample rate.

References [#1127](#1127)
References [RUST-215](https://linear.app/getsentry/issue/RUST-215)
Expose `Dsn::org_id` so callers can derive the SDK organization ID needed for strict trace continuation. Parse only Sentry SaaS ingest DSN hosts, including regional hosts, and return `None` for self-hosted, Relay, malformed, and overflow cases.

Closes [#1159](#1159)
Closes [RUST-233](https://linear.app/getsentry/issue/RUST-233)
@szokeasaurusrex
szokeasaurusrex force-pushed the szokeasaurusrex/org-id-dsn-parse branch from f8efddc to b72fb2d Compare July 20, 2026 16:29
@szokeasaurusrex
szokeasaurusrex force-pushed the szokeasaurusrex/sampling-strat branch from 221c434 to 17bead9 Compare July 20, 2026 16:29

@cursor cursor 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.

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

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit b72fb2d. Configure here.

Comment thread sentry-types/src/dsn.rs
#[test]
fn test_dsn_org_id_rejects_empty_first_label() {
assert_org_id("https://username@.ingest.sentry.io/42", None);
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Broken empty-label org ID test

Medium Severity

test_dsn_org_id_rejects_empty_first_label builds a DSN from https://username@.ingest.sentry.io/42. That host has an empty DNS label, which the url crate rejects per the URL Standard, so Dsn::from_str(...).unwrap() panics before org_id() is exercised. The case is unreachable through a valid Dsn.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit b72fb2d. Configure here.

Comment thread sentry-types/src/dsn.rs
/// - `o{orgid}.ingest.sentry.io`
fn extract_org_id(host: &str) -> Option<&str> {
// First split on the dots, up to 6 segments.
let mut host_iter = host.splitn(6, '.');

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Just curious, are you splitting it into 6 segments to make sure the last one is always None?

Comment thread sentry-types/src/dsn.rs
None,
);
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

You might want to add a test for a hostname with a 6th part that is not None, e.g. https://username@o123.ingest.de.sentry.io.com/42

Base automatically changed from szokeasaurusrex/sampling-strat to master July 21, 2026 11:21
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.

Parse organization ID from DSN

3 participants