Skip to content

Migrate begin/endEvent try/finally patterns to Systrace.trace (#56937)#56937

Open
rubennorte wants to merge 2 commits into
facebook:mainfrom
rubennorte:export-D106073157
Open

Migrate begin/endEvent try/finally patterns to Systrace.trace (#56937)#56937
rubennorte wants to merge 2 commits into
facebook:mainfrom
rubennorte:export-D106073157

Conversation

@rubennorte
Copy link
Copy Markdown
Contributor

@rubennorte rubennorte commented May 22, 2026

Summary:

Migrates existing Systrace.beginEvent / Systrace.endEvent (and bare beginEvent/endEvent) try/finally blocks to the new Systrace.trace helper, which keeps the same semantics but is more concise.

Other existing beginEvent/endEvent call sites are left untouched because they have __DEV__ guards that do not wrap the entire body and would require additional restructuring.

Changelog: [Internal]

Reviewed By: javache

Differential Revision: D106073157

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label May 22, 2026
@meta-codesync
Copy link
Copy Markdown

meta-codesync Bot commented May 22, 2026

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

@github-actions
Copy link
Copy Markdown

Warning

JavaScript API change detected

This PR commits an update to ReactNativeApi.d.ts, indicating a change to React Native's public JavaScript API.

  • Please include a clear changelog message.
  • This change will be subject to additional review.

This change was flagged as: POTENTIALLY_BREAKING

@meta-codesync meta-codesync Bot changed the title Migrate begin/endEvent try/finally patterns to Systrace.trace Migrate begin/endEvent try/finally patterns to Systrace.trace (#56937) May 22, 2026
rubennorte added a commit to rubennorte/react-native that referenced this pull request May 22, 2026
…book#56937)

Summary:

Migrates existing `Systrace.beginEvent` / `Systrace.endEvent` (and bare `beginEvent`/`endEvent`) try/finally blocks to the new `Systrace.trace` helper, which keeps the same semantics but is more concise.

Other existing `beginEvent`/`endEvent` call sites are left untouched because they have `__DEV__` guards that do not wrap the entire body and would require additional restructuring.

Changelog: [Internal]

Reviewed By: javache

Differential Revision: D106073157
@rubennorte rubennorte force-pushed the export-D106073157 branch from a2db1db to 39020ca Compare May 22, 2026 11:24
rubennorte added a commit to rubennorte/react-native that referenced this pull request May 22, 2026
…book#56937)

Summary:

Migrates existing `Systrace.beginEvent` / `Systrace.endEvent` (and bare `beginEvent`/`endEvent`) try/finally blocks to the new `Systrace.trace` helper, which keeps the same semantics but is more concise.

Other existing `beginEvent`/`endEvent` call sites are left untouched because they have `__DEV__` guards that do not wrap the entire body and would require additional restructuring.

Changelog: [Internal]

Reviewed By: javache

Differential Revision: D106073157
@rubennorte rubennorte force-pushed the export-D106073157 branch from 39020ca to 4fdba4d Compare May 22, 2026 11:25
Summary:

Adds a new `trace` helper to the `Systrace` module that wraps a function call between `beginEvent` and `endEvent`, ensuring the trace section is closed even if the function throws.

Usage:

```
Systrace.trace('name', () => {
  // logic to trace
});
```

The implementation is guarded with `isEnabled()` and inlines `beginEvent`/`endEvent` so that the no-op path avoids redundant work when tracing is disabled.

Changelog:
[General][Added] - Add `Systrace.trace` helper that wraps a function with begin/end events using try/finally

Reviewed By: javache

Differential Revision: D106071568
…book#56937)

Summary:

Migrates existing `Systrace.beginEvent` / `Systrace.endEvent` (and bare `beginEvent`/`endEvent`) try/finally blocks to the new `Systrace.trace` helper, which keeps the same semantics but is more concise.

Other existing `beginEvent`/`endEvent` call sites are left untouched because they have `__DEV__` guards that do not wrap the entire body and would require additional restructuring.

Changelog: [Internal]

Reviewed By: javache

Differential Revision: D106073157
@rubennorte rubennorte force-pushed the export-D106073157 branch from 4fdba4d to 52b3488 Compare May 22, 2026 11:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. fb-exported meta-exported p: Facebook Partner: Facebook Partner

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant