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 OpenTelmetry object as Global
148
+
.setOpenTelemetry(openTelemetry)
149
+
.build();
150
+
151
+
Spanner spanner = options.getService();
152
+
```
153
+
154
+
### Instrument with OpenCensus
155
+
156
+
> Note: OpenCensus project is deprecated. See [Sunsetting OpenCensus](https://opentelemetry.io/blog/2023/sunsetting-opencensus/).
157
+
We recommend migrating to OpenTelemetry, the successor project.
which gives insight into the client internals and aids in debugging/troubleshooting
161
+
production issues. OpenCensus metrics will provide you with enough data to enable you to
162
+
spot, and investigate the cause of any unusual deviations from normal behavior.
163
+
164
+
All Cloud Spanner Metrics are prefixed with `cloud.google.com/java/spanner`
165
+
166
+
The metrics are tagged with:
167
+
* `database`: the target database name.
168
+
* `instance_id`: the instance id of the target Spanner instance.
169
+
* `client_id`: the user defined database client id.
170
+
* `library_version`: the version of the library that you're using.
171
+
172
+
173
+
By default, the functionality is disabled. You need to include opencensus-impl
174
+
dependency to collect the data and exporter dependency to export to backend.
175
+
176
+
[Click here](https://medium.com/google-cloud/troubleshooting-cloud-spanner-applications-with-opencensus-2cf424c4c590) for more information.
177
+
178
+
#### OpenCensus Dependencies
179
+
102
180
If you are using Maven, add this to your pom.xml file
At the start of your application configure the exporter:
123
203
124
204
```java
@@ -130,9 +210,107 @@ custom_content: |
130
210
// The minimum reporting period for Stackdriver is 1 minute.
131
211
StackdriverStatsExporter.createAndRegister();
132
212
```
213
+
#### Enable RPC Views
133
214
134
-
By default, the functionality is disabled. You need to include opencensus-impl
135
-
dependency to collect the data and exporter dependency to export to backend.
215
+
By default, all session metrics are enabled. To enable RPC views, use either of the following method:
136
216
137
-
[Click here](https://medium.com/google-cloud/troubleshooting-cloud-spanner-applications-with-opencensus-2cf424c4c590) for more information.
217
+
```java
218
+
// Register views for GFE metrics, including gfe_latency and gfe_header_missing_count.
Cloud Spanner client supports OpenTelemetry Traces, which gives insight into the client internals and aids in debugging/troubleshooting production issues.
230
+
231
+
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.
232
+
233
+
#### OpenTelemetry Dependencies
234
+
235
+
If you are using Maven, add this to your pom.xml file
// Inject OpenTelemetry object via Spanner Options or register OpenTelmetry object as Global
281
+
.setOpenTelemetry(openTelemetry)
282
+
.build();
283
+
284
+
Spanner spanner = options.getService();
285
+
```
286
+
287
+
## Migrate from OpenCensus to OpenTelemetry
288
+
289
+
> 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
290
+
291
+
#### Disable OpenCensus metrics
292
+
Disable OpenCensus metrics for Spanner by including the following code if you still possess OpenCensus dependencies and exporter.
293
+
294
+
```java
295
+
SpannerOptions.disableOpenCensusMetrics();
296
+
```
297
+
298
+
#### Disable OpenCensus traces
299
+
Enabling OpenTelemetry traces for Spanner will automatically disable OpenCensus traces.
300
+
301
+
```java
302
+
SpannerOptions.enableOpenTelemetryTraces();
303
+
```
304
+
305
+
#### Remove OpenCensus Dependencies and Code
306
+
Remove any OpenCensus-related code and dependencies from your codebase if all your dependencies are ready to move to OpenTelemetry.
307
+
308
+
* Remove the OpenCensus Exporters which were configured [here](#configure-the-opencensus-exporter)
309
+
* Remove SpannerRPCViews reference which were configured [here](#enable-rpc-views)
310
+
* Remove the OpenCensus dependencies which were added [here](#opencensus-dependencies)
311
+
312
+
#### Update your Dashboards and Alerts
138
313
314
+
Update your dashboards and alerts to reflect below changes
315
+
* **Metrics name** : `cloud.google.com/java` prefix has been removed from OpenTelemery metrics and instead has been added as Instrumenation Scope.
316
+
* **Metrics namespace** : OpenTelmetry exporters uses `workload.googleapis.com` namespace opposed to `custom.googleapis.com` with OpenCensus.
0 commit comments