-
-
Notifications
You must be signed in to change notification settings - Fork 199
feat: Support modifying attachments after init (continued) #1266
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
3b1c3d1 to
5dda340
Compare
Moves the attachments to the scope, and adds `sentry_add_attachment` and `sentry_remove_attachment` and wstr variants that modify this attachment list after calling init. Attachments are identified by their path.
e42a44e to
32a6aea
Compare
|
Hmm, is there a potential need for the user to be able to specify attachment or content types? Instead of using path strings in the API, an opaque sentry_attachment_t* file_attachment = sentry_attachment_from_path(png_path);
sentry_attachment_set_content_type(file_attachment, "image/png");
sentry_add_attachment(file_attachment);
sentry_attachment_t* memory_attachment = sentry_attachment_from_buffer(png_data, png_data_len);
sentry_attachment_set_content_type(memory_attachment, "image/png");
sentry_add_attachment(memory_attachment); |
supervacuus
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great. Already approved the crashpad changes.
This also provides a solution for #978 if one uses a local scope together with the dynamic attachment. Adding this use case to the documentation might be a good idea.
Co-authored-by: Mischan Toosarani-Hausberger <[email protected]>
- remove sentry__apply_attachments_to_envelope - add sentry__envelope_add_attachments - reuse sentry__envelope_add_attachment
We recently discussed this in the context of view hierarchies. There is no sensible reason to expose the attachment type, since those should be handled by the SDK internally. Content type could be something to expose if users use non-standard extensions that the Python MIME type checker doesn't recognize.
I agree that using short-lived (eaten by "add") opaque attachments could be a nice addition. However, would we also provide option interfaces for those? Should we still offer the less verbose path-based variants? |
I was worried about introducing API that would steal the best names without being easy to extend, but it would be unfortunate to lose the convenient path-based API. If attachment-specific API is ever needed, changing |
I understand that worry. I think if you want to future-proof this, then we could decide on the following naming:
With the naming set in stone, you could now release |
|
I checked sentry-docs and other SDKs for inspiration. It appears that in-memory buffers are generally referred to as "data" and/or "bytes". If we reserve
for the path and data-based convenience APIs? Expand here to see the vision in more detail...Current APIFor reference. Could be deprecated and removed in 1.0 in favor of the new global APIs. Optionsvoid sentry_options_add_attachment(sentry_options_t *opts, const char *path);
void sentry_options_add_attachment_n(sentry_options_t *opts, const char *path, size_t path_len);
void sentry_options_add_attachmentw(sentry_options_t *opts, const wchar_t *path);
void sentry_options_add_attachmentw_n(sentry_options_t *opts, const wchar_t *path, size_t path_len);Proposed APIHere's a draft of the attachment API with some potential future additions. Global// later
// void sentry_add_attachment(sentry_attachment_t *attachment);
// alternative names: sentry_attach_file, sentry_add_attachment_path
void sentry_add_attachment_from_file(const char *path);
void sentry_add_attachment_from_file_n(const char *path, size_t path_len);
void sentry_add_attachment_from_filew(const wchar_t *path);
void sentry_add_attachment_from_filew_n(const wchar_t *path, size_t path_len);
// later (alternative names: sentry_attach_data, sentry_add_attachment_data)
// void sentry_add_attachment_from_data(const uint8_t *bytes, size_t bytes_len, const char *filename); // + _n + w
void sentry_remove_attachment(const char *path); // or filename for in-memory buffers
void sentry_remove_attachment_n(const char *path, size_t path_len);
void sentry_remove_attachmentw(const wchar_t *path);
void sentry_remove_attachmentw_n(const wchar_t *path, size_t path_len);Scope// later
// void sentry_scope_add_attachment(sentry_scope_t *scope, sentry_attachment_t *attachment);
// alternative names: sentry_scope_attach_file, sentry_scope_add_attachment_path
void sentry_scope_add_attachment_from_file(sentry_scope_t *scope, const char *path);
void sentry_scope_add_attachment_from_file_n(sentry_scope_t *scope, const char *path, size_t path_len);
void sentry_scope_add_attachment_from_filew(sentry_scope_t *scope, const wchar_t *path);
void sentry_scope_add_attachment_from_filew_n(sentry_scope_t *scope, const wchar_t *path, size_t path_len);
// later (alternative names: sentry_scope_attach_data, sentry_scope_add_attachment_from_data)
// void sentry_scope_add_attachment_data(sentry_scope_t *scope, const uint8_t *bytes, size_t bytes_len, const char *filename); + _n + wAttachment (later)// alternative names: sentry_attachment_new_path
sentry_attachment_t *sentry_attachment_from_file(const char *path); // + _n + w
// alternative names: sentry_attachment_new_data
sentry_attachment_t *sentry_attachment_from_data(const uint8_t *bytes, size_t bytes_len, const char *filename); // + _n + w
// void sentry_attachment_set_content_type(sentry_attachment_t *attachment, const char *content_type);
// void sentry_attachment_set_filename(sentry_attachment_t *attachment, const char *filename); // + _n + w
// ... |
I fully agree with the proposed structure; however, I think I would still follow the current naming scheme:
This groups all attachment functions when sorted lexicographically. Only with void sentry_remove_attachment(const char *path); // or filename for in-memory buffersIt became clear to me that we need a reference here for non-path-based removal... (you probably don't want to compare buffers byte by byte for removal). Even buffer-based attachments require a filename to be visible in the UI. Meaning that the interface will be the same for any type of attachment source (which is probably what you meant anyway, but just to be sure). |
|
The proposal was meant to follow the
|
|
That is a sensible argument, and I largely agree (especially wrt My only concern is that the proposed global scope operations clutter the name hierarchy with verbs that diverge significantly in their utility and fail to name what they do (not the fault of your proposal). However, they are consistent with the current naming (i.e., more complex forms of Thanks for the naming iteration. This is time well spent when considering the addition of interfaces later on. |
In this light, I would probably opt for the shorter (global/local) scope function names in your proposal. Meaning
|
supervacuus
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Beauty, thx! That got quite a bit of polish during the last rounds. I agree that using the actual opaque pointer as a handle to refer to attachments is better than going via the filename.
From my side this is ready.
supervacuus
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Beauty, thx! That got quite a bit of polish during the last rounds. I agree that using the actual opaque pointer as a handle to refer to attachments is better than going via the filename.
From my side this is ready.
supervacuus
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Beauty, thx! That got quite a bit of polish during the last rounds. I agree that using the actual opaque pointer as a handle to refer to attachments is better than going via the filename.
From my side this is ready.
|
Nothing is worth being said if you can't do it at least three times. 😅 I guess yesterday's outage is still ongoing. |
|
Thanks for the feedback and guidance! I'm also happy with the result :)
I opened a doc PR here: |
<!-- Use this checklist to make sure your PR is ready for merge. You may delete any sections you don't need. --> ## DESCRIBE YOUR PR Adds documentation for Native SDK PR - getsentry/sentry-native#1266 > Platforms / Native / Enriching Events / Attachments ## IS YOUR CHANGE URGENT? Help us prioritize incoming PRs by letting us know when the change needs to go live. - [ ] Urgent deadline (GA date, etc.): <!-- ENTER DATE HERE --> - [ ] Other deadline: <!-- ENTER DATE HERE --> - [x] None: Not urgent, can wait up to 1 week+ ## SLA - Teamwork makes the dream work, so please add a reviewer to your PRs. - Please give the docs team up to 1 week to review your PR unless you've added an urgent due date to it. Thanks in advance for your help! ## PRE-MERGE CHECKLIST *Make sure you've checked the following before merging your changes:* - [x] Checked Vercel preview for correctness, including links - [x] PR was reviewed and approved by any necessary SMEs (subject matter experts) - [ ] PR was reviewed and approved by a member of the [Sentry docs team](https://github.com/orgs/getsentry/teams/docs) ## LEGAL BOILERPLATE <!-- Sentry employees and contractors can delete or ignore this section. --> Look, I get it. The entity doing business as "Sentry" was incorporated in the State of Delaware in 2015 as Functional Software, Inc. and is gonna need some rights from me in order to utilize my contributions in this here PR. So here's the deal: I retain all rights, title and interest in and to my contributions, and by keeping this boilerplate intact I confirm that Sentry can use, modify, copy, and redistribute my contributions, under Sentry's choice of terms. ## EXTRA RESOURCES - [Sentry Docs contributor guide](https://docs.sentry.io/contributing/)
<!-- Use this checklist to make sure your PR is ready for merge. You may delete any sections you don't need. --> ## DESCRIBE YOUR PR Adds documentation for Native SDK PR - getsentry/sentry-native#1266 > Platforms / Native / Enriching Events / Attachments ## IS YOUR CHANGE URGENT? Help us prioritize incoming PRs by letting us know when the change needs to go live. - [ ] Urgent deadline (GA date, etc.): <!-- ENTER DATE HERE --> - [ ] Other deadline: <!-- ENTER DATE HERE --> - [x] None: Not urgent, can wait up to 1 week+ ## SLA - Teamwork makes the dream work, so please add a reviewer to your PRs. - Please give the docs team up to 1 week to review your PR unless you've added an urgent due date to it. Thanks in advance for your help! ## PRE-MERGE CHECKLIST *Make sure you've checked the following before merging your changes:* - [x] Checked Vercel preview for correctness, including links - [x] PR was reviewed and approved by any necessary SMEs (subject matter experts) - [ ] PR was reviewed and approved by a member of the [Sentry docs team](https://github.com/orgs/getsentry/teams/docs) ## LEGAL BOILERPLATE <!-- Sentry employees and contractors can delete or ignore this section. --> Look, I get it. The entity doing business as "Sentry" was incorporated in the State of Delaware in 2015 as Functional Software, Inc. and is gonna need some rights from me in order to utilize my contributions in this here PR. So here's the deal: I retain all rights, title and interest in and to my contributions, and by keeping this boilerplate intact I confirm that Sentry can use, modify, copy, and redistribute my contributions, under Sentry's choice of terms. ## EXTRA RESOURCES - [Sentry Docs contributor guide](https://docs.sentry.io/contributing/)
<!-- Use this checklist to make sure your PR is ready for merge. You may delete any sections you don't need. --> ## DESCRIBE YOUR PR Adds documentation for Native SDK PR - getsentry/sentry-native#1266 > Platforms / Native / Enriching Events / Attachments ## IS YOUR CHANGE URGENT? Help us prioritize incoming PRs by letting us know when the change needs to go live. - [ ] Urgent deadline (GA date, etc.): <!-- ENTER DATE HERE --> - [ ] Other deadline: <!-- ENTER DATE HERE --> - [x] None: Not urgent, can wait up to 1 week+ ## SLA - Teamwork makes the dream work, so please add a reviewer to your PRs. - Please give the docs team up to 1 week to review your PR unless you've added an urgent due date to it. Thanks in advance for your help! ## PRE-MERGE CHECKLIST *Make sure you've checked the following before merging your changes:* - [x] Checked Vercel preview for correctness, including links - [x] PR was reviewed and approved by any necessary SMEs (subject matter experts) - [ ] PR was reviewed and approved by a member of the [Sentry docs team](https://github.com/orgs/getsentry/teams/docs) ## LEGAL BOILERPLATE <!-- Sentry employees and contractors can delete or ignore this section. --> Look, I get it. The entity doing business as "Sentry" was incorporated in the State of Delaware in 2015 as Functional Software, Inc. and is gonna need some rights from me in order to utilize my contributions in this here PR. So here's the deal: I retain all rights, title and interest in and to my contributions, and by keeping this boilerplate intact I confirm that Sentry can use, modify, copy, and redistribute my contributions, under Sentry's choice of terms. ## EXTRA RESOURCES - [Sentry Docs contributor guide](https://docs.sentry.io/contributing/)
TODO:
_nAPISee: #586