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
By default, the functionality is disabled. You need to enable OpenTelemetry metrics and must configure the OpenTelemetry with appropriate exporters at the startup of your application:
// Inject OpenTelemetry object via Spanner Options or register OpenTelmetry object as Global
243
+
.setOpenTelemetry(openTelemetry)
244
+
.build();
245
+
246
+
Spanner spanner = options.getService();
247
+
```
248
+
249
+
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
250
+
metrics will be tagged with:
251
+
*`database`: the target database name.
252
+
*`instance_id`: the instance id of the target Spanner instance.
253
+
*`client_id`: the user defined database client id.
254
+
255
+
256
+
### Instrument with OpenCensus
257
+
258
+
> Note: OpenCensus project is deprecated. See [Sunsetting OpenCensus](https://opentelemetry.io/blog/2023/sunsetting-opencensus/).
259
+
We recommend migrating to OpenTelemetry, the successor project.
Cloud Spanner client supports OpenTelemetry Traces, which gives insight into the client internals and aids in debugging/troubleshooting production issues.
332
+
333
+
If you are using Maven, add this to your pom.xml file
By default, the functionality is disabled. You need to enable OpenTelemetry traces and must configure the OpenTelemetry with appropriate exporters at the startup of your application.
359
+
360
+
> Note: Enabling OpenTelemetry traces will automatically disable OpenCensus traces.
// Inject OpenTelemetry object via Spanner Options or register OpenTelmetry object as Global
380
+
.setOpenTelemetry(openTelemetry)
381
+
.build();
382
+
383
+
Spanner spanner = options.getService();
384
+
```
385
+
386
+
## Migrate from OpenCensus to OpenTelemetry
387
+
388
+
> 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
389
+
390
+
#### Disable OpenCensus metrics
391
+
Disable OpenCensus metrics for Spanner by including the following code if you still possess OpenCensus dependencies and exporter.
392
+
393
+
```java
394
+
SpannerOptions.disableOpenCensusMetrics();
395
+
```
396
+
397
+
#### Disable OpenCensus traces
398
+
Enabling OpenTelemetry traces for Spanner will automatically disable OpenCensus traces.
399
+
400
+
```java
401
+
SpannerOptions.enableOpenTelemetryTraces();
402
+
```
403
+
404
+
#### Remove OpenCensus Dependencies and Code
405
+
Remove any OpenCensus-related code and dependencies from your codebase if all your dependencies are ready to move to OpenTelemetry.
406
+
407
+
* Remove the OpenCensus Exporters which were configured [here](#configure-the-opencensus-exporter)
408
+
* Remove SpannerRPCViews reference which were configured [here](#enable-rpc-views)
409
+
* Remove the OpenCensus dependencies which were added [here](#opencensus-dependencies)
244
410
411
+
#### Update your Dashboards and Alerts
245
412
413
+
Update your dashboards and alerts to reflect below changes
414
+
***Metrics name** : `cloud.google.com/java` prefix has been removed from OpenTelemery metrics and instead has been added as Instrumenation Scope.
415
+
***Metrics namespace** : OpenTelmetry exporters uses `workload.googleapis.com` namespace opposed to `custom.googleapis.com` with OpenCensus.
0 commit comments