-
-
Notifications
You must be signed in to change notification settings - Fork 171
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
feat: programatic minidump capture #1052
Conversation
This provides a new function that will allow for independently created minidumps to be captured by sentry Resolves: #1050
|
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.
Thanks for the change. looks straightforard so far.
Is this PR done and ready for review? because it's marked as such, I'll asume so (if not, you ca use draft PRs in the future so that reviewers don't get notifications yet).
CI is currently failing so that will need to be fixed. Also, the newly added API should have a new test case.
i guess somewhere between draft and final. I for sure not indented to be be merged yet but at the same time i need feedback and review before moving further. |
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.
Thanks @PlasmaDev5!
There are still quite a few open design decisions to consider. In this case, I tend to leave the duplication because there are already visible diverging needs.
I know that you haven't finished this yet, but the function needs
- clear header documentation of tbd design decisions mentioned in my comments
- an integration test and an
example.c
entry
Feel i addressed feedback provided. |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1052 +/- ##
==========================================
- Coverage 81.81% 81.25% -0.57%
==========================================
Files 53 53
Lines 6363 6402 +39
Branches 1207 1214 +7
==========================================
- Hits 5206 5202 -4
- Misses 1045 1086 +41
- Partials 112 114 +2 |
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.
Thanks, things are getting in shape.
Addressed review feedback. I also have work towards the test case and will post a draft version in a comment on here once i start work tomorrow for feedback as i am a lot more unsure with how we want to handle this step. |
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.
If the format linter is bugging you, the Native SDK has a .clang-format
spec that you can use locally.
If you have any questions about integration testing, please let me know.
To give a rundown on what i have planned for the tests I am referencing the attachment tests. |
@supervacuus Any feedback on the test case stuff? and hopefully all review feedback is addressed. |
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.
I am referencing the attachment tests.
It essentially comes down to usingsentry__path_write_buffer
, from what i can tell it should be able to create a .dmp file and just add some unused data. I can then use the new API to send capture this file.
Im not sure if there is a better solution as im still getting to grips with the available API.
Given that the inner parts of sentry_capture_minidump()
are already covered by unit tests and its side effects primarily affect the network and the file system, I think a basic integration test should suffice for starters.
What I would do is the following:
- Build and run the
sentry_example
withlog
andcrash
arguments to produce a minidump (which you can find in the database directory after the crash) and store it intests/fixtures
. At this point, you can also upload the debug info files, which will be useful if you want to verify what the function uploaded in the WebUI. - Add a new command (
capture-minidump
) toexample.c
that passes that fixture as an (initially hard-coded absolute system-) path and an empty event. This also lets you experiment manually with the function to see what the WebUI renders for the incoming event. - Alternatively, you can also send any file as a first step since we don't check whether the path pointed to contains a valid minidump
- Get an integration test running that invokes the example using your new
capture-minidump
command (take inspiration fromtest_capture_http
intest_integration_http.py
, removing anything relating to transport-compression, but adding anassert_minidump(envelope)
at the end) - You can run integration tests locally via
make tests
,scripts\run_tests.ps1
if you are on Windows or directly viapytest
. You can check out the Makefile or the Powershell script to see the venv setup if you want to run this manually. - to allow the test to run in CI, you must pass the fixture path from the test to the example executable (either via command-line arg or via the environment) or let the test or build script copy the fixture to a known location relative to the example executable (which might be helpful to test the removal case).
- if the above works,
- add a test case for (other) attachments (using the command
attachment
+ addingassert_attachment(envelope)
to the case) - Add a test case for
capture-minidump-remove
to verify that the file at the input path was removed.
- add a test case for (other) attachments (using the command
src/sentry_core.c
Outdated
if (!envelope || !sentry__envelope_add_event(envelope, event)) { | ||
sentry_envelope_free(envelope); | ||
sentry_value_decref(event); | ||
} |
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 block must return and free the dump path.
SENTRY_WITH_OPTIONS (options) { | ||
SENTRY_WITH_OPTIONS (options) { |
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.
Nit: unnecessary whitespace.
if (remove_dump_on_send) { | ||
sentry__path_remove(sentry_dump_path); | ||
} |
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.
Because this parameter doesn't actually do what it says in the name (and it cannot at the moment), I'd remove it completely and let users move/remove the file after this function returns.
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.
Note: I could of course remove it myself since I'm taking over this PR, just raised this as a discussion in the PR because I know the original issue had a request to remove processed files. It just doesn't fit with the rest of the API in my opinion.
Closing in favor of: |
Resolves: #1050
Summary
Provides a new function that allows sentry to capture user created minidumps.