This page offers information about viewing and managing client-side metrics. Client-side metrics offer latency information about the client's RPC requests to Spanner.
Spanner provides client-side metrics that you can use along with server-side metrics to optimize performance and troubleshoot performance issues if they occur.
Client-side metrics are measured from the time a request leaves your application to the time your application receives the response. 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.
Access client-side metrics
Client-side metrics are available on the following client libraries:
Client-side metrics are available after you enable the Cloud Monitoring API.
Client-side metrics are available for users or service
accounts that are granted the Identity and Access Management (IAM) monitoring.timeSeries.create
permission. This permission is included in the following Spanner
IAM roles:
- Cloud Spanner Admin (
roles/spanner.admin
) - Cloud Spanner Database Admin (
roles/spanner.databaseAdmin
) - Cloud Spanner Database Reader (
roles/spanner.databaseReader
) - Cloud Spanner Database User (
roles/spanner.databaseUser
)
For more information about granting roles, see Manage access to projects, folders, and organizations.
You might also be able to get the required monitoring.timeSeries.create
IAM permission through
custom roles.
View metrics in the Metrics Explorer
In the Google Cloud console, go to the Metrics Explorer page.
Select your project.
Click Select a metric.
Search for
spanner.googleapis.com/client
.Select the metric, and then click Apply.
For more information about grouping or aggregating your metric, see Build queries using menus.
Your application needs to run for at least a minute before you can view any published metrics.
Opt out of client-side metrics
If you are already using OpenTelemetry to capture custom client metrics, you can choose to opt out of using client-side metrics by using the following code:
Java
Spanner spanner =
SpannerOptions.newBuilder()
.setProjectId("test-project")
.setBuiltInMetricsEnabled(false)
.build()
.getService();
Go
client, err := spanner.NewClientWithConfig(ctx, database, spanner.ClientConfig{
DisableNativeMetrics: true,
})
Costs
There is no charge to view client-side metrics in Cloud Monitoring. Use of the Monitoring API might incur charges. For more information, see Google Cloud Observability pricing.