Skip to content

Commit ab56892

Browse files
docs(spanner): Update client side metrics and permission issues in README (#13491)
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
1 parent af39539 commit ab56892

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

spanner/README.md

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,4 +113,27 @@ defer client.Close()
113113
// Example Log message for when transaction is recycled
114114
// session <session-info> checked out of pool at <session-checkout-time> is long running and will be removed due to possible session leak for goroutine
115115
// <Stack Trace of transaction>
116-
```
116+
```
117+
118+
## Metrics
119+
120+
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.
121+
122+
Client-side metrics are measured from the time a request leaves your application to the time your application receives the response.
123+
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.
124+
125+
These metrics are enabled by default. You can opt out of using client-side metrics with the following code:
126+
127+
```go
128+
client, err := spanner.NewClientWithConfig(
129+
ctx, database, spanner.ClientConfig{DisableNativeMetrics: true},
130+
)
131+
if err != nil {
132+
log.Fatal(err)
133+
}
134+
defer client.Close()
135+
```
136+
137+
You can also disable these metrics by setting `SPANNER_DISABLE_BUILTIN_METRICS` to `true`.
138+
139+
> Note: Exporting client-side metrics requires the `monitoring.timeSeries.create` IAM permission. To grant this, ask your administrator to assign the [Monitoring Metric Writer](https://cloud.google.com/iam/docs/roles-permissions/monitoring#monitoring.metricWriter) (`roles/monitoring.metricWriter`) IAM role to your application's service account.

0 commit comments

Comments
 (0)