Class SpannerMetrics (6.124.0)

public final class SpannerMetrics

Utility methods for configuring Spanner client metrics.

Inheritance

java.lang.Object > SpannerMetrics

Static Methods

configureMeterProviderBuilder(SdkMeterProviderBuilder meterProviderBuilder)

public static void configureMeterProviderBuilder(SdkMeterProviderBuilder meterProviderBuilder)

Applies the Spanner client-metrics views to a caller-owned SdkMeterProviderBuilder. Recommended (but not required) when using CustomOpenTelemetryMetricsProvider: the views rename the raw instruments to the exported spanner/client/... metric names, apply the Spanner latency histogram bucket boundaries, and restrict the recorded attributes to the supported client-metric labels. Without the views, metrics are still recorded with the raw instrument names, default buckets and unfiltered attributes.

Use a dedicated SdkMeterProviderBuilder (and resulting meter provider) for the Spanner client metrics, not one that is shared with other instrumentation. Some of the registered views select generic gRPC instruments (for example grpc.client.attempt.duration on the grpc-java meter), so on a shared meter provider they would also rename metrics recorded by unrelated gRPC clients into the spanner/client namespace and filter their attributes down to the Spanner client-metric labels.

Register the views at most once per SdkMeterProviderBuilder.

Parameter
Name Description
meterProviderBuilder io.opentelemetry.sdk.metrics.SdkMeterProviderBuilder