LeanProfiler

2.1. The session owns the capture🔗

profile starts one process-wide recording session. It resets the event buffer, records a process snapshot, enables instrumentation, and opens the root span. When the action finishes, it disables new recording before analyzing and exporting the completed events.

The process-wide ownership is deliberate. A report needs one index space and one unambiguous set of output paths. Nested spans are ordinary events, but a second overlapping profile session is rejected rather than allowed to compete for the same buffer.

If profiling is disabled, profileFromEnvironment still runs the action and span does not retain an event. This keeps instrumentation in normal application code instead of requiring a separate profiling build.