Skip to content

Add a scope guard for logging to help us capture all exit paths (#1383)#1383

Open
ryanzhang22 wants to merge 1 commit intopytorch:mainfrom
ryanzhang22:export-D102829439
Open

Add a scope guard for logging to help us capture all exit paths (#1383)#1383
ryanzhang22 wants to merge 1 commit intopytorch:mainfrom
ryanzhang22:export-D102829439

Conversation

@ryanzhang22
Copy link
Copy Markdown
Contributor

@ryanzhang22 ryanzhang22 commented Apr 29, 2026

Summary:

Currently, we mark all areas where we want to indicate stage completion with UST_LOGGER_MARK_COMPLETED. This macro routes us to the UST logger write method which keep a running list of all LOG(ERROR) messages. If no ERROR messages have been logged, we'll mark the stage as a success. Otherwise, we will include the error message in the Scuba write.

With this setup it's pretty easy for us to miss an exit path, especially in the post-processing path where we have a bunch of early exit branches. This change introduces a USTLoggerStageGuard to help automatically manage stage exit without needing to explicitly remember to mark UST_LOGGER_MARK_COMPLETED.

Note that this doesn't help us capture cases where something failed catastrophically and the process immediately exits. Many of these callsites were already pretty well instrumented, this just makes stuff a little cleaner.

Differential Revision: D102829439

@meta-cla meta-cla Bot added the cla signed label Apr 29, 2026
@meta-codesync
Copy link
Copy Markdown

meta-codesync Bot commented Apr 29, 2026

@ryanzhang22 has exported this pull request. If you are a Meta employee, you can view the originating Diff in D102829439.

…rch#1383)

Summary:

Currently, we mark all areas where we want to indicate stage completion with `UST_LOGGER_MARK_COMPLETED`. This macro routes us to the UST logger `write` method which keep a running list of all LOG(ERROR) messages. If no ERROR messages have been logged, we'll mark the stage as a success. Otherwise, we will include the error message in the Scuba write.

With this setup it's pretty easy for us to miss an exit path, especially in the post-processing path where we have a bunch of early exit branches. This change introduces a `USTLoggerStageGuard` to help automatically manage stage exit without needing to explicitly remember to mark `UST_LOGGER_MARK_COMPLETED`.

Note that this doesn't help us capture cases where something failed catastrophically and the process immediately exits. Many of these callsites were already pretty well instrumented, this just makes stuff a little cleaner.

Differential Revision: D102829439
@meta-codesync meta-codesync Bot changed the title Add a scope guard for logging to help us capture all exit paths Add a scope guard for logging to help us capture all exit paths (#1383) May 1, 2026
@ryanzhang22 ryanzhang22 force-pushed the export-D102829439 branch from 531e801 to 89b8afd Compare May 1, 2026 19:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant