---
title: Slow Operations Logging
description: Tracing information on slow operations can be found in the logs as
  threshold logging, orphan logging, and other span metrics.
pubDate: 2026-08-17T09:53:44.266Z
antora:
  editUrl: https://github.com/couchbase/docs-sdk-nodejs/edit/temp/4.7/modules/howtos/pages/slow-operations-logging.adoc
  xref: xref:nodejs-sdk:howtos:slow-operations-logging.adoc[]
---

[Consult the llms.txt file for a full list of contents](/llms.txt)
[View original HTML](/nodejs-sdk/current/howtos/slow-operations-logging.html)

# Slow Operations Logging

> Tracing information on slow operations can be found in the logs as threshold logging, orphan logging, and other span metrics. Change the settings to alter how much information you collect 

To improve debuggability certain metrics are automatically measured and logged. These include slow queries, responses taking beyond a certain threshold, and orphanned responses.

## [](#threshold-logging-reporting)Threshold Logging Reporting

> [!NOTE]
> As of v4.7.0 the Threshold Logger is native to the Node.js SDK. In previous versions the underlying C++ core was responsible for threshold logging.

Threshold logging is the recording of slow operations — useful for diagnosing when and where problems occur in a distributed environment.

### [](#configuring-threshold-logging)Configuring Threshold Logging

By default the a threshold log report can be emitted every 10 seconds, but you can customize the emit interval, along with operation thresholds:

```javascript
const cluster = await couchbase.connect('couchbase://your-ip', {
  username: 'Administrator',
  password: 'password',
  tracingConfig: {
    emitInterval: 5000, // 5 seconds
    sampleSize: 5, // only report the top 5 slow operations per service
    kvThreshold: 2000, // 2 seconds in milliseconds
  }
})
```

The `ThresholdLogger` can be configured via `TracingConfig` as shown above. The following table shows the currently available properties:

__Table 1\. TracingConfig Properties__
| Property            | Default          | Description                                              |
| ------------------- | ---------------- | -------------------------------------------------------- |
| enableTracing       | true             | If tracing should be enabled.                            |
| kvThreshold         | 500 milliseconds | The key-value operations threshold.                      |
| viewsThreshold      | 1 second         | The view query operations threshold.                     |
| queryThreshold      | 1 second         | The query operations threshold.                          |
| searchThreshold     | 1 second         | The search query operations threshold.                   |
| analyticsThreshold  | 1 second         | The analytics query operations threshold.                |
| eventingThreshold   | 1 second         | The eventing operations threshold.                       |
| managementThreshold | 1 second         | The management operations threshold.                     |
| sampleSize          | 10               | The top number of operations to report.                  |
| emitInterval        | 10 seconds       | The interval at which a threshold report can be emitted. |

Note that the Threshold Logger is set as the cluster level `Tracer` implementation.

#### [](#json-output-format-logging)JSON Output Format & Logging

You should expect to see output in JSON format in the logs for the services encountering problems:

```json
{
  "<service-a>": {
    "total_count": 1234,
    "top_requests": [{<entry>}, {<entry>},...]
  },
  "<service-b>": {
    "total_count": 1234,
    "top_requests": [{<entry>}, {<entry>},...]
  },
}
```

The `total_count` represents the total amount of over-threshold recorded items in each interval per service. The number of entries in "top\_requests" is configured by the `sampleSize`. The service placeholder is replaced with each service — "kv", "query", etc. Each entry looks like this, with all fields populated:

```json
{
  "total_duration_us": 1200,
  "encode_duration_us": 100,
  "last_dispatch_duration_us": 40,
  "total_dispatch_duration_us": 40,
  "last_server_duration_us": 2,
  "total_server_duration_us": 2,
  "operation_name": "upsert",
  "last_local_id": "66388CF5BFCF7522/18CC8791579B567C",
  "operation_id": "0x23",
  "last_local_socket": "10.211.55.3:52450",
  "last_remote_socket": "10.112.180.101:11210"
}
```

If a field is not present (because for example dispatch did not happen), it will not be included.