A newer version of this documentation is available.

View Latest

Threshold Logging Tracing through the SDK


    Why Tracing?

    Tracing is recording details about discrete steps or phases of a request lifecycle, such as request encoding / decoding, or dispatching to server. These phases are timed independently, and contain additional contextual information. A single request is typically made up of multiple tracing points.

    Open Tracing

    OpenTracing is a standardised API to structure tracing information in a consistent and predictable manner.

    Threshold Configuration Settings

    The threshold tracer receives completed spans and verifies if an operation has exceeded the given threshold for the operation type. Operations that exceed the threshold are periodically logged with a total count and a sample of the slowest ones. The following are SDK configuration properties, also found in the Client Settings page of some SDKs.

    Table 1. Threshold Logging Tracer Properties
    Property Name Description Default Value


    Boolean used to determine tracing is enabled. Defaults to using the ThesholdLoggingTracer if enabled. When false a Noop or similar tracing implementation should be used instead.



    Boolean used to instruct the SDK to try and retrieve duration metrics from the server for KV operations.



    The interval between executions that process the collected operation spans. Expressed in milliseconds.

    10,000 (10 seconds)


    The maximum number of items to log per service.



    The KV operation operation threshold. Expressed in microseconds.

    500,000 (500 milliseconds)


    The View query operation threshold. Expressed in microseconds.

    1,000,000 (1 second)


    The N1QL query operation threshold. Expressed in microseconds.

    1,000,000 (1 second)


    The FTS query operation threshold. Expressed in microseconds.

    1,000,000 (1 second)


    The Analytics query operation threshold. Expressed in microseconds.

    1,000,000 (1 second)


    Boolean used to determine if orphaned response logging is enabled.



    The interval used to flush orphaned response information to the log. Expressed in microseconds.

    10,000 (10 seconds)


    The number of sample orphaned responses whose to log additional information for per execution.


    Threshold Logging in Java

    Response Time Observability is implemented as Threshold Logging in Java SDK from release 2.6.0.


    You can customise Tracer settings through the CouchbaseEnvironment.Builder. Here is an example on how to customize our default tracer to reduce the time interval when the information gets logged:

    Tracer tracer = ThresholdLogTracer.create(ThresholdLogReporter.builder()
      .logInterval(10, TimeUnit.SECONDS) // log every 10 seconds
    CouchbaseEnvironment env = DefaultCouchbaseEnvironment.builder()

    Follow along with our example of Tracing from the Java SDK with Couchbase Server, to discover how to use tracing in the Java SDK for Response Time Observability.