Skip to content

Conversation

@Swatinem
Copy link
Contributor

@Swatinem Swatinem commented Dec 1, 2020

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.

Attachments are still based on file paths and loaded lazily, this does not add support for attachments based on in-memory buffers.

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.
@Swatinem Swatinem requested review from a team and philipphofmann December 1, 2020 10:22
Copy link
Member

@philipphofmann philipphofmann left a comment

Choose a reason for hiding this comment

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

Thanks @Swatinem 💯. The API seems sufficient for synching attachments from Java to native.

@philipphofmann
Copy link
Member

I'm sorry I was wrong. I think we need some more changes to this PR.
In Python and Java, we have two different types of attachments reflected in the same class. An attachment can either have a byte array or a path. Each attachment also has a filename or and a content type, see

In the SDK API Evolution meeting, we decided it is fine to just copy the byte array to native with the tradeoff of increasing the memory footprint.

*
* See the NOTE on attachments above for restrictions of this API.
*/
SENTRY_API void sentry_add_attachment(const char *path);
Copy link
Contributor

Choose a reason for hiding this comment

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

Will we always want this to be void? Does a status return make any sense now or in the future?

*
* See the NOTE on attachments above for restrictions of this API.
*/
SENTRY_API void sentry_remove_attachment(const char *path);
Copy link
Contributor

Choose a reason for hiding this comment

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

While an idempotent API is good, would a return from which you can tell whether anything happened or not be useful?

* API Users on windows are encouraged to use `sentry_add_attachmentw` instead.
*
* See the NOTE on attachments above for restrictions of this API.
*/
Copy link
Contributor

Choose a reason for hiding this comment

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

Does it make sense to explicitly say something about the ownership of *path? (same for remove attachment)

sentry__envelope_serialize_into_stringbuilder(envelope, &sb);

*size_out = sentry__stringbuilder_len(&sb);
if (size_out) {
Copy link
Contributor

Choose a reason for hiding this comment

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

nice 😄

@getsantry
Copy link

getsantry bot commented Oct 18, 2023

This issue has gone three weeks without activity. In another week, I will close it.

But! If you comment or otherwise update it, I will reset the clock, and if you remove the label Waiting for: Community, I will leave it alone ... forever!


"A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀

@jpnurmi
Copy link
Collaborator

jpnurmi commented Jul 11, 2025

Hi @Swatinem, this PR can be closed to get it off the list. Thanks for laying the foundations for modifying attachments at runtime! We incorporated these changes into #1266 and the feature was released in 0.9.1. 🎉

@codecov
Copy link

codecov bot commented Jul 11, 2025

Codecov Report

Attention: Patch coverage is 95.58824% with 3 lines in your changes missing coverage. Please review.

Project coverage is 87.65%. Comparing base (c78d7c4) to head (3cb24a2).
Report is 503 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #433      +/-   ##
==========================================
+ Coverage   87.61%   87.65%   +0.04%     
==========================================
  Files          49       50       +1     
  Lines        4222     4260      +38     
==========================================
+ Hits         3699     3734      +35     
- Misses        523      526       +3     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Swatinem
Copy link
Contributor Author

great to see this finally land 🎉 , thanks for pushing this over the finish line.

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.

6 participants