Skip to content

Parse organization ID from DSN #1159

Description

@szokeasaurusrex

Add a Dsn::org_id() helper so the SDK can derive its organization ID from SaaS DSNs as required by the strict trace continuation spec. This is the first implementation task in the strict trace continuation stack tracked by #1016.

The helper should parse SaaS-style hosts whose first DNS label is o<digits> and return None for self-hosted, Relay, malformed, or overflow cases. Add a CHANGELOG.md entry because this is a public API addition.

Implementation notes

Target files:

  • sentry-types/src/dsn.rs
  • sentry-types/src/protocol/v7.rs for the existing OrganizationId type
  • CHANGELOG.md

Implementation:

  • Add Dsn::org_id(&self) -> Option<OrganizationId>.
  • Parse only the first host label.
  • Accept labels matching o<digits>.
  • Return None for labels such as oabc, 123, empty labels, self-hosted hosts, Relay hosts, and integer overflow.

Examples:

  • o123.ingest.sentry.io -> Some(123.into())
  • o123.sentry.io -> None
  • sentry.io -> None
  • relay.example.com -> None
  • localhost -> None
  • oabc.ingest.sentry.io -> None

Tests:

  • Add unit tests in sentry-types/src/dsn.rs for valid SaaS hosts, malformed first labels, self-hosted hosts, and overflow.
  • Validate with cargo test -p sentry-types dsn.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions