Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

feat(py): Expose DataCategory via C-ABI #651

Merged
merged 6 commits into from
Jul 8, 2020
Merged

Conversation

jan-auer
Copy link
Member

@jan-auer jan-auer commented Jul 7, 2020

Exposes DataCategory via the C-ABI to Python for consumption in Sentry and Snuba. Along with this, also exposes the SpanStatus, still via the old dictionary. In a future change, this could be made an enum, too.

To expose the constants, they have been moved to relay-cabi. Unfortunately, a limitation in cbindgen does not allow to parse relay-general directly. On the upside, this creates a central place for constants that are exposed from Relay to other services in Sentry.

Along with this, the deprecated serialization of span status "unknown_error" is removed. By now, all downstream consumers have been updated.

@jan-auer jan-auer requested review from untitaker and a team July 7, 2020 21:33
@jan-auer jan-auer self-assigned this Jul 7, 2020
Returns categories that count as traditional error tracking events.
"""
return frozenset(
DataCategory.DEFAULT, DataCategory.ERROR, DataCategory.SECURITY
Copy link
Member Author

@jan-auer jan-auer Jul 7, 2020

Choose a reason for hiding this comment

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

Note that this changes compared to Sentry, where SECURITY was not included:

https://github.com/getsentry/sentry/blob/9f08305e09866c8bd6d0c24f5b0aabdd7dd6c59c/src/sentry/constants.py#L532-L533

This is mainly used by quotas, which will now include security events as originally intended.

SpanStatus::Unimplemented => write!(f, "unimplemented"),
SpanStatus::Unavailable => write!(f, "unavailable"),
SpanStatus::InternalError => write!(f, "internal_error"),
SpanStatus::Unknown => write!(f, "unknown"),
Copy link
Member Author

Choose a reason for hiding this comment

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

This is now changed from "unknown_error", along with all other uses.

runtime_props.misc_primary_cpu_brand = None;
#[allow(deprecated)]
{
runtime_props.misc_primary_cpu_brand = None;
Copy link
Member Author

Choose a reason for hiding this comment

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

This is fixes an existing warning, unrelated to this patch.

if not attr.startswith(prefix):
continue

status_name = attr[len(prefix) :].lower()
Copy link
Member Author

@jan-auer jan-auer Jul 7, 2020

Choose a reason for hiding this comment

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

I would say this is actually safe - per convention the constants must always match the default serialization. That said, if we ever diverge from this in the future (which we should not!) we can call into an API for this.

Copy link
Member

Choose a reason for hiding this comment

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

Yes this seems safe.

Copy link
Member

@untitaker untitaker left a comment

Choose a reason for hiding this comment

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

I think the changes to the default serialization of SpanStatus should be deployed with extreme care.

py/sentry_relay/consts.py Outdated Show resolved Hide resolved
if not attr.startswith(prefix):
continue

status_name = attr[len(prefix) :].lower()
Copy link
Member

Choose a reason for hiding this comment

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

Yes this seems safe.

@jan-auer jan-auer merged commit 69b6bd5 into master Jul 8, 2020
@jan-auer jan-auer deleted the feat/expose-data-category branch July 8, 2020 11:55
jan-auer added a commit that referenced this pull request Jul 8, 2020
* master:
  fix(server): Forward outcomes in processing mode (#653)
  feat(py): Expose DataCategory via C-ABI (#651)
  build: Update backtrace-rs (#652)
  fix(unreal): Do not serialize broken misc_primary_cpu_brand (#650)
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants