Skip to content

fix: Add dsc project id to all spans#6011

Open
elramen wants to merge 5 commits into
masterfrom
elramen-ds
Open

fix: Add dsc project id to all spans#6011
elramen wants to merge 5 commits into
masterfrom
elramen-ds

Conversation

@elramen
Copy link
Copy Markdown
Member

@elramen elramen commented May 20, 2026

@linear-code
Copy link
Copy Markdown

linear-code Bot commented May 20, 2026

attributes.insert(SENTRY__DSC__TRANSACTION, transaction.clone());
}
if let Some(project_id) = project_id {
attributes.insert(SENTRY__DSC__PROJECT_ID, project_id.value() as i64);
Copy link
Copy Markdown
Member Author

@elramen elramen May 20, 2026

Choose a reason for hiding this comment

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

Do project ids always fit into i64? If yes, I think we should change ProjectId(u64) to ProjectId(i64) (because implementing From<u64> for AttributeValue doesn't make sense as EAP doesn't support it right?).

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.

Then we should store it as a string instead and update conventions accordingly (also confirm with Simon).

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Do you mean that if project ids don't always fit in i64, we should store them as strings? But if they always fit, it's fine to just change to ProjectId(i64) (and leave conventions as is)?

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.

No, we should always store it as a string. It's typed as a u64 we have no other guarantee that it will always fit in an i64, so we should use a format to store that's not gonna make us problems -> string.

@elramen elramen force-pushed the elramen-ds branch 2 times, most recently from 9615a36 to 3e0de84 Compare May 20, 2026 14:36
Comment thread relay-event-normalization/src/event.rs
@elramen elramen marked this pull request as ready for review May 20, 2026 15:05
@elramen elramen requested a review from a team as a code owner May 20, 2026 15:05
@elramen elramen requested a review from Dav1dde May 20, 2026 15:08
attributes.insert(SENTRY__DSC__TRANSACTION, transaction.clone());
}
if let Some(project_id) = project_id {
attributes.insert(SENTRY__DSC__PROJECT_ID, project_id.value() as i64);
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.

No, we should always store it as a string. It's typed as a u64 we have no other guarantee that it will always fit in an i64, so we should use a format to store that's not gonna make us problems -> string.

Comment thread relay-event-normalization/src/eap/mod.rs Outdated
Comment thread relay-event-normalization/src/normalize/span/mod.rs Outdated
Comment thread relay-event-normalization/src/event.rs
Comment thread relay-event-normalization/src/event.rs Outdated
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 2 potential issues.

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 67703e4. Configure here.

attributes.insert(SENTRY__DSC__TRANSACTION, transaction.clone());
}
if let Some(project_id) = sampling_project_id {
attributes.insert(SENTRY__DSC__PROJECT_ID, project_id.value() as i64);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Lossy u64-to-i64 cast for project ID

Medium Severity

ProjectId::value() returns u64, and casting it to i64 with as silently wraps values exceeding i64::MAX. While current project IDs are small, ProjectId is typed as u64 with no guarantee it fits in i64. The PR discussion explicitly concluded this attribute needs to be stored as a string to avoid data corruption, but the code still uses as i64.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 67703e4. Configure here.

SENTRY__DSC__PROJECT_ID.to_owned(),
Annotated::new(Value::U64(project_id.value())),
);
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Inconsistent project ID type between span formats

Medium Severity

The sentry.dsc.project_id attribute is stored as Value::U64 in legacy/v1 spans but as i64 (typed as AttributeType::Integer) in EAP/v2 spans. The same logical value has different representations across span formats, which can cause inconsistent behavior in downstream consumers expecting a uniform type.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 67703e4. Configure here.

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.

2 participants