Skip to content

Commit e4b2394

Browse files
Merge pull request #483 from couchbase/DOC-11091--thresholdLoggingTracerConfig
DOC-11091 thresholdLoggingTracerConfig and ClusterOptions
2 parents f2ce7bb + f24d0bc commit e4b2394

1 file changed

Lines changed: 21 additions & 2 deletions

File tree

modules/howtos/pages/observability-tracing.adoc

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,34 @@ To give insight into a request/response flow, the SDK provides a `RequestTracer`
1414
By default, the SDK will emit information about requests that are over a configurable threshold every 10 seconds.
1515
Note that if no requests are over the threshold no event / log will be emitted.
1616

17-
It is possible to customize this behavior by modifying the configuration:
17+
It is possible to customize this behavior by modifying the configuration.
18+
The recommended way to configure the environment is via a callback when connecting to the cluster:
1819

1920
[source,java]
2021
----
21-
include::devguide:example$java/Tracing.java[tag=tracing-configure,indent=0]
22+
var cluster = Cluster.connect(
23+
connectionString,
24+
clusterOptions(username, password)
25+
.environment(env -> env
26+
.thresholdLoggingTracerConfig(config -> config
27+
.enabled(true) // it's enabled by default, so this line is not strictly necessary
28+
.emitInterval(Duration.ofMinutes(1))
29+
.kvThreshold(Duration.ofSeconds(2))
30+
)
31+
)
32+
);
2233
----
2334

2435
In this case the emit interval is one minute and Key/Value requests will only be considered if their latency is greater or equal than two seconds.
2536

37+
// Don't think we'll need to call this out explicitly, but it's here if we need to uncomment it:
38+
//
39+
// TIP:
40+
// Using the `ClusterOptions.environment()`, as in the above snippet, ensures that the SDK manages the environment --
41+
// shutting down after disconnecting from the cluster.
42+
// If you create your own `own ClusterEnvironent` or `ClusterEnvironment.Builder` then you will need to manage the environment yourself.
43+
44+
2645
The JSON blob emitted looks similar to the following (prettified here for readability):
2746

2847
[source,json]

0 commit comments

Comments
 (0)