You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
which gives insight into the client internals and aids in debugging/troubleshooting
92
-
production issues. OpenTelemetry metrics will provide you with enough data to enable you to
93
-
spot, and investigate the cause of any unusual deviations from normal behavior.
94
-
95
-
All Cloud Spanner Metrics are prefixed with `spanner/` and uses `cloud.google.com/java` as [Instrumentation Scope](https://opentelemetry.io/docs/concepts/instrumentation-scope/). The
96
-
metrics will be tagged with:
97
-
* `database`: the target database name.
98
-
* `instance_id`: the instance id of the target Spanner instance.
99
-
* `client_id`: the user defined database client id.
100
-
101
-
By default, the functionality is disabled. You need to add OpenTelemetry dependencies, enable OpenTelemetry metrics and must configure the OpenTelemetry with appropriate exporters at the startup of your application:
102
-
103
-
#### OpenTelemetry Dependencies
104
-
If you are using Maven, add this to your pom.xml file
// Inject OpenTelemetry object via Spanner Options or register OpenTelemetry object as Global
148
-
.setOpenTelemetry(openTelemetry)
149
-
.build();
150
-
151
-
Spanner spanner = options.getService();
152
-
```
55
+
Cloud Spanner client supports [client-side metrics](https://cloud.google.com/spanner/docs/view-manage-client-side-metrics) that you can use along with server-side metrics to optimize performance and troubleshoot performance issues if they occur.
153
56
154
-
#### OpenTelemetry SQL Statement Tracing
155
-
The OpenTelemetry traces that are generated by the Java client include any request and transaction
156
-
tags that have been set. The traces can also include the SQL statements that are executed and the
157
-
name of the thread that executes the statement. Enable this with the `enableExtendedTracing`
158
-
option:
57
+
Client-side metrics are measured from the time a request leaves your application to the time your application receives the response.
58
+
In contrast, server-side metrics are measured from the time Spanner receives a request until the last byte of data is sent to the client.
59
+
60
+
These metrics are enabled by default. You can opt out of using client-side metrics with the following code:
> Note: Client-side metrics needs `monitoring.timeSeries.create` IAM permission to export metrics data. Ask your administrator to grant your service account the [Monitoring Metric Writer](https://cloud.google.com/iam/docs/roles-permissions/monitoring#monitoring.metricWriter) (roles/monitoring.metricWriter) IAM role on the project.
260
71
261
72
## Traces
262
73
Cloud Spanner client supports OpenTelemetry Traces, which gives insight into the client internals and aids in debugging/troubleshooting production issues.
263
74
264
75
By default, the functionality is disabled. You need to add OpenTelemetry dependencies, enable OpenTelemetry traces and must configure the OpenTelemetry with appropriate exporters at the startup of your application.
265
76
77
+
See [Configure client-side tracing](https://cloud.google.com/spanner/docs/set-up-tracing#configure-client-side-tracing) for more details on configuring traces.
78
+
266
79
#### OpenTelemetry Dependencies
267
80
268
81
If you are using Maven, add this to your pom.xml file
@@ -348,10 +161,33 @@ custom_content: |
348
161
`SPANNER_ENABLE_API_TRACING=true`.
349
162
350
163
> Note: The attribute keys that are used for additional information about retry attempts and the number of requests might change in a future release.
164
+
165
+
#### End-to-end Tracing
166
+
167
+
In addition to client-side tracing, you can opt in for [end-to-end tracing](https://cloud.google.com/spanner/docs/tracing-overview#end-to-end-side-tracing). End-to-end tracing helps you understand and debug latency issues that are specific to Spanner such as the following:
168
+
* Identify whether the latency is due to network latency between your application and Spanner, or if the latency is occurring within Spanner.
169
+
* Identify the Google Cloud regions that your application requests are being routed through and if there is a cross-region request. A cross-region request usually means higher latencies between your application and Spanner.
Refer to [Configure end-to-end tracing](https://cloud.google.com/spanner/docs/set-up-tracing#configure-end-to-end-tracing) to configure end-to-end tracing and to understand its attributes.
179
+
180
+
> Note: End-to-end traces can only be exported to [Cloud Trace](https://cloud.google.com/trace/docs).
181
+
182
+
183
+
## Instrument with OpenCensus
351
184
185
+
> Note: OpenCensus project is deprecated. See [Sunsetting OpenCensus](https://opentelemetry.io/blog/2023/sunsetting-opencensus/).
186
+
We recommend migrating to OpenTelemetry, the successor project.
187
+
352
188
## Migrate from OpenCensus to OpenTelemetry
353
189
354
-
> 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
190
+
> 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.
355
191
356
192
#### Disable OpenCensus metrics
357
193
Disable OpenCensus metrics for Spanner by including the following code if you still possess OpenCensus dependencies and exporter.
0 commit comments