fix: record exceptions and ERROR status in trace_fn decorator - #23
Open
andrewwhitecdw wants to merge 1 commit into
Open
Conversation
Author
|
Closing per adversarial audit: branch contains off-scope or not-a-bug changes. |
andrewwhitecdw
restored the
andrewwhitecdw/fix/trace-fn-exception-status
branch
August 17, 2026 20:30
Author
|
script closed on accident |
When a decorated function raised, the span recorded the exception via the OpenTelemetry context manager but did not set the span status to ERROR. managed_span already does this; align trace_fn with the same behavior. Adds a regression test verifying the span status is ERROR when the wrapped function raises. Signed-off-by: Andrew White <andrewh@cdw.com> Signed-off-by: andrewwhitecdw <andrewwhitecdw@users.noreply.github.com>
andrewwhitecdw
force-pushed
the
andrewwhitecdw/fix/trace-fn-exception-status
branch
from
August 18, 2026 00:14
682e8a4 to
298af65
Compare
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
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.
Bug
When a decorated function raised, the span recorded the exception via the OpenTelemetry context manager but did not set the span status to ERROR.
managed_spanalready does this;trace_fnwas inconsistent.Fix
Wrap the function call in a try/except inside
trace_fn, record the exception, set the span status toStatusCode.ERROR, and re-raise.Test
Added
TestTraceFn::test_exception_recorded, which verifies the span status is ERROR when the wrapped function raises.Verification
pytest tests/test_helpers.py -vpasses (17 tests).ruff check src/nemo/lens/helpers.py tests/test_helpers.pyandruff format --check ...pass.