-
Notifications
You must be signed in to change notification settings - Fork 5
feat: Add return and exception event tracing #8
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: Add return and exception event tracing #8
Conversation
- Add trace_returns and trace_exceptions configuration options - Implement return event handling for complete function execution flow - Implement exception event handling for better debugging visibility - Add _handle_function_return() and _handle_function_exception() methods - Add _handle_line_return() and _handle_line_exception() methods - Update SpewConfig with new boolean options and validation - Update spew() function and SpewContext with new parameters - Support both functions_only and line-by-line tracing modes - Add comprehensive test script demonstrating new functionality Fixes Agent-Hellboy#3: Trace return and exception events
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #8 +/- ##
==========================================
- Coverage 96.80% 96.55% -0.25%
==========================================
Files 4 4
Lines 125 203 +78
==========================================
+ Hits 121 196 +75
- Misses 4 7 +3
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Hi @AnshKumarTripathi , please add unittest and remove the system test. |
…re-commit - Add comprehensive unit tests for return and exception event handling - Remove system test file as requested by maintainer - Update README with new features and examples - Set up pre-commit hooks for code quality - Fix all linting and formatting issues - Increase test coverage from 23 to 51 tests Addresses maintainer feedback for PR Agent-Hellboy#8 Fixes Agent-Hellboy#3: Trace return and exception events
- Fix unused variable warnings in exception handling (exc_tb -> _) - Add comprehensive test coverage for missing lines in trace.py - Cover linecache.getline() and inspect.getsourcelines() code paths - Add 5 new test cases to cover all missing coverage lines - Improve overall test coverage to meet project standards - All 56 tests passing with 0 linting errors Addresses maintainer feedback for PR Agent-Hellboy#8
…_trace_new_features.py and test_coverage_gaps.py - Added 20 unit tests to TestTraceHook class - Added 7 integration tests to TestIntegration class - All 53 tests passing (increased from 23) - Organized tests into existing 4 test classes as maintainer requested
…False - Changed trace_returns default from True to False - Changed trace_exceptions default from False to False - Removed 'Configurable tracing' line from README features - Updated all documentation to reflect new defaults - Makes new features opt-in rather than opt-out for better backward compatibility
- Changed trace_returns default from True to False in spew() function - Changed trace_exceptions default from True to False in spew() function - Now consistent with SpewContext and SpewConfig defaults - Completes the change to make new features opt-in across entire codebase
|
@Agent-Hellboy I added the changes requested in the new commit. |
|
Also can you tell me how to run this all bot tests that happens in GitHub? So i can run it locally first and push only the changes that are fully passed. So it saves me some embracement :) |
|
Hi @AnshKumarTripathi , please add unittest, you have added intergation test. please
go to project root and do pre-commit install after installing https://pre-commit.com/ check tox.ini and ci files to understand how does ci run here, please remove AI genarted test script keep it in test_spewer only. |
you can use |
|
there are 4 classes inside the test file please check in which class your test should go. |
|
@Agent-Hellboy Now when I used pre-commit, then i found out it was just a linter error and was not a super duper blocker. |
|
Hi @AnshKumarTripathi please test your changes against a script with external dependencies. If you can please check codecov report and see if you can improve it or not. Please don’t use AI to write unit test. |
|
Hi @Agent-Hellboy Sorry for going for two weeks without telling, but i met with an accident so was not able to do it. |
No problem at all, please take care. Your contribution will be counted; someone will add a patchset, or I will do it myself. |
- Add 7 new tests covering line-mode return/exception branches - Add tests for .pyc/.pyo file handling edge cases - Add integration tests with real Python code execution - Fix incorrect default values in README documentation - Coverage improved from 92% to 93% (60 tests, was 53) Addresses codecov failures in PR Agent-Hellboy#8
|
Gettin 96+ % test coverage was not possible for me, but i tired my best, below is the report
|
Okay, add a screenshot using this library. |
Use py_compile to generate those files, and you can create weird frame objects using frameobject. I can help you with that, but please try it yourself first. happy to help you any way. |
|
btw, you did a good job. If you don't want to work right now, I can merge this PR, and you can explore it later, but it's for your learning only. |
I think i will work on this later, let me try different issue for a change. I have grown attached to this project, will also contribute after the event ends |
|
Also I just looked that my PR has some conflicts, so let me know what changes i need to do. |
|
Thanks @AnshKumarTripathi , please resolve conflict and also please check other issues , if you want to work on it. |

Summary
This PR implements Issue #3: Trace return and exception events, significantly enhancing the debugging capabilities of spewer.
What's Changed
New Features:
trace_returnsandtrace_exceptionsparametersfunctions_only=Trueand line-by-line tracingAPI Changes:
trace_returns: bool = Trueparameter tospew()andSpewContexttrace_exceptions: bool = Trueparameter tospew()andSpewContextSpewConfigwith new boolean options and validationImplementation Details:
TraceHook.__call__()to handle return and exception events_handle_function_return()and_handle_function_exception()methods_handle_line_return()and_handle_line_exception()methodsSpewConfig.__post_init__()🧪 Testing
Test Script: