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.

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

OperationTracingEnabled

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.

true

OperationTracingServerDurationEnabled

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

true

ThresholdLoggingTracerInterval

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

10,000 (10 seconds)

ThresholdLoggingTracerSampleSize

The maximum number of items to log per service.

10

ThresholdLoggingTracerKVThreshold

The KV operation operation threshold. Expressed in microseconds.

500,000 (500 milliseconds)

ThresholdLoggingTracerViewsThreshold

The View query operation threshold. Expressed in microseconds.

1,000,000 (1 second)

ThresholdLoggingTracerQueryThreshold

The N1QL query operation threshold. Expressed in microseconds.

1,000,000 (1 second)

ThresholdLoggingTracerSearchThreshold

The FTS query operation threshold. Expressed in microseconds.

1,000,000 (1 second)

ThresholdLoggingTracerAnalyticsThreshold

The Analytics query operation threshold. Expressed in microseconds.

1,000,000 (1 second)

OrphanedResponseLoggingEnabled

Boolean used to determine if orphaned response logging is enabled.

true

OrphanedResponseLoggingInterval

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

10,000 (10 seconds)

OrphanedResponseLoggingSampleSize

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

10

Threshold Logging in the Node.js SDK

Response Time Observability is implemented as Threshold Logging in the Node.js SDK from release 2.5.0.

Table 2. Threshold Logging Tracer Properties
Setting name Description Default Value

enable_tracing

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. Also when enabled the SDK will try and retrieve duration metrics from the server for KV operations.

true

tracing_threshold_queue_flush_interval

The interval between executions that process the collected operation spans. Expressed in seconds with fractions (or microseconds for lcb_cntl).

10.0 seconds (or 10000000 microseconds)

tracing_threshold_queue_size

The maximum number of items to keep in internal queue per service.

128

tracing_threshold_kv

The KV operation operation threshold. Expressed in seconds with fractions (or microseconds for lcb_cntl).

0.5 second (500000 microseconds)

tracing_threshold_view

The View query operation threshold. Expressed in seconds with fractions (or microseconds for lcb_cntl).

1 second (1000000 microseconds)

tracing_threshold_n1ql

The N1QL query operation threshold. Expressed in seconds with fractions (or microseconds for lcb_cntl).

1 second (1000000 microseconds)

tracing_threshold_fts

The FTS query operation threshold. Expressed in seconds with fractions (or microseconds for lcb_cntl).

1 second (1000000 microseconds)

tracing_threshold_analytics

The Analytics query operation threshold. Expressed in seconds with fractions (or microseconds for lcb_cntl).

1 second (1000000 microseconds)

tracing_orphaned_queue_flush_interval

The interval between executions that processes the collected operation spans. Expressed in seconds with fractions (or microseconds for lcb_cntl).

10.0 seconds (or 10000000 microseconds)

tracing_orphaned_queue_size

The maximum number of items to keep in internal queue per service.

128

Customizing

You can customise Tracer settings through the connection string, or using lcb_cntl. Here is an example on how to customize our default tracer to reduce the time interval when the information gets logged:

var cluster = new couchbase.Cluster("couchbase://127.0.0.1/default?tracing_threshold_queue_flush_interval=10.0");

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