feat(types): Add organization ID parsing for DSNs#1202
Conversation
|
cbde4ff to
53bd774
Compare
53bd774 to
d8f38f3
Compare
d8f38f3 to
08f1a80
Compare
08f1a80 to
cb59fdf
Compare
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)
a32eb15 to
ce74a79
Compare
cb59fdf to
28f70b6
Compare
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)
ce74a79 to
221c434
Compare
28f70b6 to
f8efddc
Compare
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)
f8efddc to
b72fb2d
Compare
221c434 to
17bead9
Compare
There was a problem hiding this comment.
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.
Reviewed by Cursor Bugbot for commit b72fb2d. Configure here.
| #[test] | ||
| fn test_dsn_org_id_rejects_empty_first_label() { | ||
| assert_org_id("https://username@.ingest.sentry.io/42", None); | ||
| } |
There was a problem hiding this comment.
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.
Reviewed by Cursor Bugbot for commit b72fb2d. Configure here.
| /// - `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, '.'); |
There was a problem hiding this comment.
Just curious, are you splitting it into 6 segments to make sure the last one is always None?
| None, | ||
| ); | ||
| } | ||
|
|
There was a problem hiding this comment.
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


Expose
Dsn::org_idso callers can derive the SDK organization ID needed for strict trace continuation. Parse only Sentry SaaS ingest DSN hosts, including regional hosts, and returnNonefor self-hosted, Relay, malformed, and overflow cases.Closes #1159
Closes RUST-233