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 Go

    Response Time Observability is implemented in the Go SDK from version 1.4 onwards. With OperationTracingEnabled set to true [the default in Couchbase Server 5.5], operation_tracing is passed in the cluster connection query string. And with OperationTracingServerDurationEnabled set [it currently defaults to false], the server_duration is passed in the cluster connection query string. This is a brief example of customizing the threshold settings.

    cluster, _ := gocb.Connect("couchbase://localhost”)
    // cluster, _ := gocb.Connect("couchbase://localhost?operation_tracing=true&server_duration=true”) example of using connection string options
        Username: username,
        Password: password,
    tracer := gocb.ThresholdLoggingTracer{}
    tracer.Interval = 1 * time.Second
    tracer.KvThreshold = 500 * time.Millisecond
    tracer.ViewsThreshold = 1 * time.Second
    tracer.N1qlThreshold = 1 * time.Second
    tracer.SearchThreshold = 1 * time.Second
    tracer.AnalyticsThreshold = 1 * time.Second
    tracer.SampleSize = 20
    cluster.SetTracer(&tracer)  // Note that this must come before cluster.OpenBucket