-
Notifications
You must be signed in to change notification settings - Fork 51
Add source code capture for exception traces #229
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
Draft
philliphartin
wants to merge
10
commits into
1.x
Choose a base branch
from
feature/code-excerpts
base: 1.x
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
+603
−8
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…eptionSensor - Introduced `getBasePath` method in `Location` class to access the base path. - Enhanced `ExceptionSensor` to collect and return source code lines around exceptions, including context lines. - Added a test to verify the correct capture of source code lines during exception handling.
…ames in the trace - Added configuration option to enable or disable source line capture for exceptions. - Updated `ExceptionSensor` to conditionally collect source lines based on the new configuration. - Improved trace serialization to include source lines for the first few frames of the exception stack.
…ality - Updated tests to assert the correct capture of source lines for exceptions. - Added a test to verify the disabling of source line capture via configuration.
- Moved the test for capturing source code lines to a new location within the test class. - Added a new route for testing exception handling in the application. - Temporarily disabling source line capture to scaffold test
- Simplified the structure of the collected source code lines in `ExceptionSensor`. - Updated tests to enable source line capture and validate the correct retrieval of source lines for exceptions.
- Wrapped the mail sending logic in a try-catch block to handle exceptions gracefully. - Added reporting and aborting functionality to manage expected exceptions. - Updated test cases to reflect changes in source code line references.
- Changed visibility of `isVendorFile` and `isInternalFile` methods in `Location` class from private to public. - Updated `collectSourceCodeLines` method in `ExceptionSensor` to accept file contents instead of file path, returning a structured object with source lines. - Improved trace serialization to include source code lines for user files, enhancing exception handling capabilities. - Adjusted tests to validate the new structure of source code line collection and ensure accurate retrieval of source lines.
@philliphartin is there any ETA on when this could be expected to be released? That's the last thing before we could cancel our Sentry subscription. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Add Source Code Capture for Exception Traces
This PR adds the ability to capture source code lines around exception locations in user-land code, providing developers with immediate context when debugging exceptions without needing to open files.
What's Changed
Configuration
exceptions.capture_source_lines
configuration option (defaults totrue
)NIGHTWATCH_EXCEPTION_CAPTURE_SOURCE_LINES
environment variableCore Implementation
ExceptionSensor
to capture source code context for user files in exception tracesAPI Changes
Location::isVendorFile()
andLocation::isInternalFile()
publicLocation::getBasePath()
method for source code file resolutionPayload Preview
When an exception occurs in user code, the trace now includes a
code
field with source context:Benefits
Performance Considerations
Testing