Bake pause/resume into SpansRecorder with a depth counter#74
Merged
Conversation
The PausableRecorder trait could only handle a single ignored event with nothing nested under it. Anything trickier (a normal recordStart/recordEnd under a pause, or a second ignored event) silently desynced the resume. Pause/resume is now a feature of SpansRecorder itself. Static $pauseOwner and $pauseDepth track ownership and call depth across the recorder hierarchy. startSpan and endSpan carry the counter math: increments while owner-paused do not produce real spans, and resume fires the moment depth returns to zero. Lifecycle::flush() clears the static state at every subtask/request boundary so long-running runtimes cannot leak pause state across executions.
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.
Summary
PausableRecordertrait only worked for a single ignored event with nothing nested under it. A normalrecordStart/recordEndpair under a pause, or a second ignored event on the same recorder, silently desynced the resume.SpansRecorderitself. Static$pauseOwnerand$pauseDepthtrack ownership and call depth across the recorder hierarchy.startSpanandendSpancarry the counter math: increments while owner-paused do not produce real spans, and resume fires the moment depth returns to zero.Lifecycle::flush()callsSpansRecorder::resetPauseState()on every existing flush trigger (subtask end, terminate, trash, shutdown), so long-running runtimes (Octane, queue workers) cannot leak pause state across executions.CommandRecorder,JobRecorder, andQueueRecorderconsumers drop the trait, theif (pausedTrace())preambles inrecordEnd/recordFailed, and the$ourTracePauseownership flag. Their public surface is unchanged; the ignored branches still callpauseTrace().Why a counter
The old single-boolean approach treated any
recordEndafter a pause as the matching one. The counter replaces "next end resumes" with "end that lands on zero resumes," which is the only rule that holds under nesting.The motivating shape (ignored A → normal B → ignored C, ends in reverse) is locked in by a unit test, along with: single ignored event, repeated
pauseTrace()by the owner, non-owner pause attempts as no-ops, and explicitresetPauseState()behavior. The globalPest.phpbeforeEachresets the static state so it cannot leak between tests.