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
@@ -150,217 +150,30 @@ the Cloud Spanner Java client.
150
150
151
151
## Metrics
152
152
153
-
### Available client-side metrics:
153
+
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.
154
154
155
-
*`spanner/max_in_use_sessions`: This returns the maximum
156
-
number of sessions that have been in use during the last maintenance window
157
-
interval, so as to provide an indication of the amount of activity currently
158
-
in the database.
155
+
Client-side metrics are measured from the time a request leaves your application to the time your application receives the response.
156
+
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.
159
157
160
-
*`spanner/max_allowed_sessions`: This shows the maximum
161
-
number of sessions allowed.
158
+
These metrics are default enabled, you can choose to opt out of using client-side metrics by using the following code:
162
159
163
-
*`spanner/num_sessions_in_pool`: This metric allows users to
164
-
see instance-level and database-level data for the total number of sessions in
165
-
the pool at this very moment.
166
-
167
-
*`spanner/num_acquired_sessions`: This metric allows
168
-
users to see the total number of acquired sessions.
169
-
170
-
*`spanner/num_released_sessions`: This metric allows
171
-
users to see the total number of released (destroyed) sessions.
172
-
173
-
*`spanner/get_session_timeouts`: This gives you an
174
-
indication of the total number of get session timed-out instead of being
175
-
granted (the thread that requested the session is placed in a wait queue where
176
-
it waits until a session is released into the pool by another thread) due to
177
-
pool exhaustion since the server process started.
178
-
179
-
*`spanner/gfe_latency`: This metric shows latency between
180
-
Google's network receiving an RPC and reading back the first byte of the response.
181
-
182
-
*`spanner/gfe_header_missing_count`: This metric shows the
183
-
number of RPC responses received without the server-timing header, most likely
184
-
indicating that the RPC never reached Google's network.
which gives insight into the client internals and aids in debugging/troubleshooting
190
-
production issues. OpenTelemetry metrics will provide you with enough data to enable you to
191
-
spot, and investigate the cause of any unusual deviations from normal behavior.
192
-
193
-
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
194
-
metrics will be tagged with:
195
-
*`database`: the target database name.
196
-
*`instance_id`: the instance id of the target Spanner instance.
197
-
*`client_id`: the user defined database client id.
198
-
199
-
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:
200
-
201
-
#### OpenTelemetry Dependencies
202
-
If you are using Maven, add this to your pom.xml file
> 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.
358
169
359
170
## Traces
360
171
Cloud Spanner client supports OpenTelemetry Traces, which gives insight into the client internals and aids in debugging/troubleshooting production issues.
361
172
362
173
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.
363
174
175
+
Refer [Configure client-side tracing](https://cloud.google.com/spanner/docs/set-up-tracing#configure-client-side-tracing) to configure traces
176
+
364
177
#### OpenTelemetry Dependencies
365
178
366
179
If you are using Maven, add this to your pom.xml file
@@ -447,6 +260,29 @@ This option can also be enabled by setting the environment variable
447
260
448
261
> Note: The attribute keys that are used for additional information about retry attempts and the number of requests might change in a future release.
449
262
263
+
#### End-to-end Tracing
264
+
265
+
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:
266
+
* Identify whether the latency is due to network latency between your application and Spanner, or if the latency is occurring within Spanner.
267
+
* 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 [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 understand the attributes for this.
277
+
278
+
> Note: End-to-end traces can only be exported to [Cloud Trace](https://cloud.google.com/trace/docs).
279
+
280
+
281
+
## Instrument with OpenCensus
282
+
283
+
> Note: OpenCensus project is deprecated. See [Sunsetting OpenCensus](https://opentelemetry.io/blog/2023/sunsetting-opencensus/).
284
+
We recommend migrating to OpenTelemetry, the successor project.
285
+
450
286
## Migrate from OpenCensus to OpenTelemetry
451
287
452
288
> 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
0 commit comments