> For AI agents: the complete documentation index is available at /next/llms.txt, the full documentation bundle is available at /next/llms-full.txt.

# Tracing

This page documents the `Tracing` CDP domain supported by Lynx DevTool.



:::warning Experimental reference
This generated reference is still being completed.

- CDP events are not included yet.
- Some Lynx extensions are listed but do not yet have detailed documentation.
- Method descriptions are not automatically verified against the implementation and may be incomplete or inaccurate.

Verify behavior against the implementation and the linked upstream CDP reference before relying on it.
:::

## Overview

- Scope: `global-and-instance`
- CDP domain: [Tracing](https://chromedevtools.github.io/devtools-protocol/tot/Tracing/)

## Standard Methods

- [Tracing.end](https://chromedevtools.github.io/devtools-protocol/tot/Tracing/#method-end)
- [Tracing.start](https://chromedevtools.github.io/devtools-protocol/tot/Tracing/#method-start)

## Lynx Extensions

### `Tracing.getStartupTracingConfig`

Returns the stored startup tracing configuration string.

- Origin: `lynx-extension`
- Source: `devtool/lynx_devtool/agent/domain_agent/inspector_tracing_agent.cc`

###### Parameters

No parameters.

###### Returns

| Name     | Type     | Description                                                                  |
| -------- | -------- | ---------------------------------------------------------------------------- |
| `config` | `string` | Startup tracing configuration string read from the trace controller storage. |

###### Notes

- Dispatches through LynxGlobalDevToolMediator on the global DevTool task runner.
- Reads GlobalDevToolPlatformFacade::GetTraceController()->GetStartupTracingConfig().
- The trace controller stores the configuration as an opaque string. Lynx does not parse or validate it in this CDP method.
- Returns a CDP error with message Failed to get trace controller when no trace controller is available.
- If the global mediator has no default task runner, the current handler does not send an explicit CDP response.

###### Examples

**Read startup tracing config**

Request:

```json
{
  "id": 1,
  "method": "Tracing.getStartupTracingConfig"
}
```

Response:

```json
{
  "id": 1,
  "result": {
    "config": "{\"traceConfig\":{\"includedCategories\":[\"*\"]}}"
  }
}
```

### `Tracing.getStartupTracingFile`

Emits a Tracing.tracingComplete event for the stored startup tracing file.

- Origin: `lynx-extension`
- Source: `devtool/lynx_devtool/agent/domain_agent/inspector_tracing_agent.cc`

###### Parameters

No parameters.

###### Returns

No return fields.

###### Events

- Tracing.tracingComplete

###### Notes

- Dispatches through LynxGlobalDevToolMediator on the global DevTool task runner.
- Reads GlobalDevToolPlatformFacade::GetTraceController()->GetStartupTracingFilePath().
- When a startup tracing file path exists, the method first sends an empty OK response and then sends Tracing.tracingComplete.
- Tracing.tracingComplete.params.stream is a FileStream handle encoded as a string. Read it with IO.read and close it with IO.close.
- Tracing.tracingComplete.params.dataLossOccurred is true when the file cannot be opened as a stream.
- Tracing.tracingComplete.params.isStartupTracing is true for this method.
- Returns a CDP error with message Startup Tracing is running when no file is available because tracing is still active.
- Returns a CDP error with message Failed to get startup tracing file when no file is available and tracing is not active.
- Returns a CDP error with message Failed to get trace controller when no trace controller is available.

###### Examples

**Request the startup tracing file**

Request:

```json
{
  "id": 1,
  "method": "Tracing.getStartupTracingFile"
}
```

Response:

```json
{
  "id": 1,
  "result": {}
}
```

**Startup tracing complete event**

Response:

```json
{
  "method": "Tracing.tracingComplete",
  "params": {
    "dataLossOccurred": false,
    "stream": "1",
    "isStartupTracing": true
  }
}
```

### `Tracing.setStartupTracingConfig`

Stores an opaque startup tracing configuration string.

- Origin: `lynx-extension`
- Source: `devtool/lynx_devtool/agent/domain_agent/inspector_tracing_agent.cc`

###### Parameters

| Name     | Type     | Required | Description                                                                   |
| -------- | -------- | -------- | ----------------------------------------------------------------------------- |
| `config` | `string` | Yes      | Startup tracing configuration string to persist through the trace controller. |

###### Returns

No return fields.

###### Notes

- Dispatches through LynxGlobalDevToolMediator on the global DevTool task runner.
- Writes params.config to GlobalDevToolPlatformFacade::GetTraceController()->SetStartupTracingConfig().
- The trace controller stores the configuration as an opaque string. Lynx does not parse or validate it in this CDP method.
- Returns an empty OK response when params.config is present.
- Returns a CDP error with message Set Startup Tracing config is null when params.config is missing.
- Returns a CDP error with message Failed to get trace controller when no trace controller is available.
- If the global mediator has no default task runner, the current handler does not send an explicit CDP response.

###### Examples

**Store startup tracing config**

Request:

```json
{
  "id": 1,
  "method": "Tracing.setStartupTracingConfig",
  "params": {
    "config": "{\"traceConfig\":{\"includedCategories\":[\"*\"]}}"
  }
}
```

Response:

```json
{
  "id": 1,
  "result": {}
}
```

### `Tracing.takeVMSnapshotByUrl`

Take snapshot of MTS or BTS virtual machines of page with given URL.

- Origin: `lynx-extension`
- Source: `devtool/lynx_devtool/agent/domain_agent/inspector_tracing_agent.cc`

###### Parameters

| Name   | Type     | Required | Description                                   |
| ------ | -------- | -------- | --------------------------------------------- |
| `url`  | `string` | Yes      | The url of page to take snapshot.             |
| `type` | `string` | Yes      | Type of the snapshot to take. 'bts' or 'mts'. |

###### Returns

No return fields.

###### Notes

- Dispatches through LynxGlobalDevToolMediator on the global DevTool task runner.
- Returns an empty OK response when tracing session is active and params.url and params.type are present.
- Returns a CDP error with message 'Argument error' when url or type parameter is missing.
- Returns a CDP error with message 'Tracing is not started' when tracing session is not active.
- If the global mediator has no default task runner, the current handler does not send an explicit CDP response.

###### Examples

**Take snapshot of page with given URL**

Request:

```json
{
  "id": 1,
  "method": "Tracing.takeVMSnapshotByUrl",
  "params": {
    "config": "{\"url\":\"https://xxx/template.js\",\"type\":\"bts\"}"
  }
}
```

Response:

```json
{
  "id": 1,
  "result": {}
}
```

