Skip to content

Commit 0f1e263

Browse files
authored
chore: traces documentation (#3195)
1 parent c3d3f23 commit 0f1e263

File tree

2 files changed

+69
-3
lines changed

2 files changed

+69
-3
lines changed

.readme-partials.yaml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ custom_content: |
183183
184184
> Note: The attribute keys that are used for additional information about retry attempts and the number of requests might change in a future release.
185185
186+
186187
### Instrument with OpenCensus
187188
188189
> Note: OpenCensus project is deprecated. See [Sunsetting OpenCensus](https://opentelemetry.io/blog/2023/sunsetting-opencensus/).
@@ -315,6 +316,38 @@ custom_content: |
315316
316317
Spanner spanner = options.getService();
317318
```
319+
320+
#### OpenTelemetry SQL Statement Tracing
321+
The OpenTelemetry traces that are generated by the Java client include any request and transaction
322+
tags that have been set. The traces can also include the SQL statements that are executed and the
323+
name of the thread that executes the statement. Enable this with the `enableExtendedTracing`
324+
option:
325+
326+
```
327+
SpannerOptions options = SpannerOptions.newBuilder()
328+
.setOpenTelemetry(openTelemetry)
329+
.setEnableExtendedTracing(true)
330+
.build();
331+
```
332+
333+
This option can also be enabled by setting the environment variable
334+
`SPANNER_ENABLE_EXTENDED_TRACING=true`.
335+
336+
#### OpenTelemetry API Tracing
337+
You can enable tracing of each API call that the Spanner client executes with the `enableApiTracing`
338+
option. These traces also include any retry attempts for an API call:
339+
340+
```
341+
SpannerOptions options = SpannerOptions.newBuilder()
342+
.setOpenTelemetry(openTelemetry)
343+
.setEnableApiTracing(true)
344+
.build();
345+
```
346+
347+
This option can also be enabled by setting the environment variable
348+
`SPANNER_ENABLE_API_TRACING=true`.
349+
350+
> Note: The attribute keys that are used for additional information about retry attempts and the number of requests might change in a future release.
318351
319352
## Migrate from OpenCensus to OpenTelemetry
320353

README.md

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,13 @@ implementation 'com.google.cloud:google-cloud-spanner'
5757
If you are using Gradle without BOM, add this to your dependencies:
5858

5959
```Groovy
60-
implementation 'com.google.cloud:google-cloud-spanner:6.70.0'
60+
implementation 'com.google.cloud:google-cloud-spanner:6.71.0'
6161
```
6262

6363
If you are using SBT, add this to your dependencies:
6464

6565
```Scala
66-
libraryDependencies += "com.google.cloud" % "google-cloud-spanner" % "6.70.0"
66+
libraryDependencies += "com.google.cloud" % "google-cloud-spanner" % "6.71.0"
6767
```
6868
<!-- {x-version-update-end} -->
6969

@@ -289,6 +289,7 @@ This option can also be enabled by setting the environment variable
289289

290290
> Note: The attribute keys that are used for additional information about retry attempts and the number of requests might change in a future release.
291291
292+
292293
### Instrument with OpenCensus
293294

294295
> Note: OpenCensus project is deprecated. See [Sunsetting OpenCensus](https://opentelemetry.io/blog/2023/sunsetting-opencensus/).
@@ -422,6 +423,38 @@ SpannerOptions options = SpannerOptions.newBuilder()
422423
Spanner spanner = options.getService();
423424
```
424425

426+
#### OpenTelemetry SQL Statement Tracing
427+
The OpenTelemetry traces that are generated by the Java client include any request and transaction
428+
tags that have been set. The traces can also include the SQL statements that are executed and the
429+
name of the thread that executes the statement. Enable this with the `enableExtendedTracing`
430+
option:
431+
432+
```
433+
SpannerOptions options = SpannerOptions.newBuilder()
434+
.setOpenTelemetry(openTelemetry)
435+
.setEnableExtendedTracing(true)
436+
.build();
437+
```
438+
439+
This option can also be enabled by setting the environment variable
440+
`SPANNER_ENABLE_EXTENDED_TRACING=true`.
441+
442+
#### OpenTelemetry API Tracing
443+
You can enable tracing of each API call that the Spanner client executes with the `enableApiTracing`
444+
option. These traces also include any retry attempts for an API call:
445+
446+
```
447+
SpannerOptions options = SpannerOptions.newBuilder()
448+
.setOpenTelemetry(openTelemetry)
449+
.setEnableApiTracing(true)
450+
.build();
451+
```
452+
453+
This option can also be enabled by setting the environment variable
454+
`SPANNER_ENABLE_API_TRACING=true`.
455+
456+
> Note: The attribute keys that are used for additional information about retry attempts and the number of requests might change in a future release.
457+
425458
## Migrate from OpenCensus to OpenTelemetry
426459

427460
> Using the [OpenTelemetry OpenCensus Bridge](https://mvnrepository.com/artifact/io.opentelemetry/opentelemetry-opencensus-shim), you can immediately begin exporting your metrics and traces with OpenTelemetry
@@ -688,7 +721,7 @@ Java is a registered trademark of Oracle and/or its affiliates.
688721
[kokoro-badge-link-5]: http://storage.googleapis.com/cloud-devrel-public/java/badges/java-spanner/java11.html
689722
[stability-image]: https://img.shields.io/badge/stability-stable-green
690723
[maven-version-image]: https://img.shields.io/maven-central/v/com.google.cloud/google-cloud-spanner.svg
691-
[maven-version-link]: https://central.sonatype.com/artifact/com.google.cloud/google-cloud-spanner/6.70.0
724+
[maven-version-link]: https://central.sonatype.com/artifact/com.google.cloud/google-cloud-spanner/6.71.0
692725
[authentication]: https://github.com/googleapis/google-cloud-java#authentication
693726
[auth-scopes]: https://developers.google.com/identity/protocols/oauth2/scopes
694727
[predefined-iam-roles]: https://cloud.google.com/iam/docs/understanding-roles#predefined_roles

0 commit comments

Comments
 (0)