.log('Tracing started')  
        await new Promise(resolve => setTimeout(resolve, 5000))  
        const path = await contentTracing.stopRecording()  
        console.log('Tracing data recorded to ' + path)  
      })()  
    })  
    

##  Methods  â

The ` contentTracing ` module has the following methods:

###  ` contentTracing.getCategories() ` â

Returns ` Promise<string[]> ` \- resolves with an array of category groups
once all child processes have acknowledged the ` getCategories ` request

Get a set of category groups. The category groups can change as new code paths
are reached. See also the [ list of built-in tracing categories
](https://chromium.googlesource.com/chromium/src/+/main/base/trace_event/builtin_categories.h)
.

> **NOTE:** Electron adds a non-default tracing category called ` "electron" `
> . This category can be used to capture Electron-specific tracing events.

###  ` contentTracing.startRecording(options) ` â

  * ` options ` ( [ TraceConfig ](/docs/latest/api/structures/trace-config) | [ TraceCategoriesAndOptions ](/docs/latest/api/structures/trace-categories-and-options) ) 

Returns ` Promise<void> ` \- resolved once all child processes have
acknowledged the ` startRecording ` request.

Start recording on all processes.

Recording begins immediately locally and asynchronously on child processes as
soon as they receive the EnableRecording request.

If a recording is already running, the promise will be immediately resolved,
as only one trace operation can be in progress at a time.

###  ` contentTracing.stopRecording([resultFilePath]) ` â

  * ` resultFilePath ` string (optional) 

Returns ` Promise<string> ` \- resolves with a path to a file that contains
the traced data once all child processes have acknowledged the ` stopRecording
` request

Stop recording on all processes.

Child processes typically cache trace data and only rarely flush and send
trace data back to the main process. This helps to minimize the runtime
overhead of tracing since sending trace data over IPC can be an expensive
operation. So, to end tracing, Chromium asynchronously asks all child
processes to flush any pending trace data.

Trace data will be written into ` resultFilePath ` . If ` resultFilePath ` is
empty or not provided, trace data will be written to a temporary file, and the
path will be returned in the promise.

###  ` contentTracing.getTraceBufferUsage() ` â

Returns ` Promise<Object> ` \- Resolves with an object containing the ` value
` and ` percentage ` of trace buffer maximum usage

  * ` value ` number 
  * ` percentage ` number 

Get the maximum usage across processes of trace buffer as a percentage of the
full state.

[ Edit this page
](https://github.com/electron/electron/edit/main/docs/api/content-tracing.md)

[ Previous  clipboard  ](/docs/latest/api/clipboard) [ Next  crashReporter
](/docs/latest/api/crash-reporter)

  * Methods 
    * ` getCategories `
    * ` startRecording `
    * ` stopRecording `
    * ` getTraceBufferUsage `

Docs

  * [ Getting Started ](/docs/latest/)
  * [ API Reference ](/docs/latest/api/app)

Checklists

  * [ Performance ](/docs/latest/tutorial/performance)
  * [ Security ](/docs/latest/tutorial/security)

Tools

  * [ Electron Forge ](https://electronforge.io)
  * [ Electron Fiddle ](/fiddle)

Community

  * [ Governance ](/governance)
  * [ Resources ](/community)
  * [ Discord  ](https://discordapp.com/invite/APGC3k5yaH)
  * [ Twitter  ](https://twitter.com/electronjs)
  * [ Mastodon  ](https://social.lfx.dev/@electronjs)
  * [ Stack Overflow  ](https://stackoverflow.com/questions/tagged/electron)

More

  * [ GitHub  ](https://github.com/electron/electron)
  * [ Open Collective  ](https://opencollective.com/electron)
  * [ Infrastructure Dashboard  ](https://p.datadoghq.com/sb/c44e1df0-85d7-11ee-94c9-da7ad0900002-c245f7ef47d0d0c32abecdc0938c2a85)

[ ![OpenJS Foundation Logo](/assets/img/openjsf_logo.svg) ![OpenJS Foundation
Logo](/assets/img/openjsf_logo-dark.