Default affinity key lifetime for dynamic channel pool. This is how long to keep an affinity
key after its last use. Zero means keeping keys forever. Default is 10 minutes, which is
sufficient to ensure that requests within a single transaction use the same channel.
Default maximum time for one attempt to prime a channel that the dynamic channel pool adds
during scale-up. Scaled-up channels are primed by executing SELECT 1 with a multiplexed
session before they are published to the pool.
Default cleanup interval for dynamic channel pool affinity keys. This is how frequently the
affinity key cleanup process runs. Default is 1 minute (1/10 of default affinity key lifetime).
Creates a CloseableExecutorProvider that can be used as an ExecutorProvider for
the async API. The ExecutorProvider will lazily create up to poolSize threads. The
backing threads will automatically be shutdown if they have not been used during the keep-alive
time. The backing threads are created as daemon threads.
Creates a GcpChannelPoolOptions instance with Spanner-specific defaults for dynamic
channel pooling. These defaults are optimized for typical Spanner workloads.
Default values:
Max size: {@value #DEFAULT_DYNAMIC_POOL_MAX_CHANNELS}
Min size: {@value #DEFAULT_DYNAMIC_POOL_MIN_CHANNELS}
Max RPC per channel: {@value #DEFAULT_DYNAMIC_POOL_MAX_RPC}
Min RPC per channel: {@value #DEFAULT_DYNAMIC_POOL_MIN_RPC}
Scale down interval: 3 minutes
Affinity key lifetime: 10 minutes
Cleanup interval: 1 minute
Channel prime timeout: 10 seconds
Channel prime max attempts: {@value #DEFAULT_DYNAMIC_POOL_CHANNEL_PRIME_MAX_ATTEMPTS}
Channels that the pool adds during scale-up are primed with SELECT 1 on a
multiplexed session before they are published. The primer is registered by the Spanner client
when dynamic channel pooling is enabled, unless these options already contain a primer. Priming
rotates across available multiplexed sessions owned by live database clients of the Spanner instance. Closed or invalid database clients do not supply sessions for priming.
Wires gRPC-layer built-in metrics into the given channel provider builder for each active
metrics sink: the Cloud Monitoring (GCM) sink when #isEnableBuiltInMetrics() is true,
and the caller-owned OpenTelemetry sink when a CustomOpenTelemetryMetricsProvider is
configured. Does nothing when isEmulatorEnabled is true or gRPC built-in metrics are
disabled via the environment.
Returns the effective MetricsProvider used for client metrics. This is the provider set
with Builder#setClientMetricsProvider(MetricsProvider) after applying instance type
rules: NoopMetricsProvider is returned when the DefaultMetricsProvider is used
with an InstanceType#OMNI client. A CustomOpenTelemetryMetricsProvider records
the same client instruments to an independent caller-owned OpenTelemetry destination on all
instance types, including Omni, and is not affected by Builder#setBuiltInMetricsEnabled(boolean) or the SPANNER_DISABLE_BUILTIN_METRICS
environment variable. #toBuilder() preserves the provider as originally set, so
rebuilding the options re-applies these rules against the new configuration.
Returns the channel pool options for dynamic channel pooling. If no options were explicitly
set, returns the Spanner-specific defaults.
See Also: #createDefaultDynamicChannelPoolOptions()
Returns whether dynamic channel pooling is enabled. Dynamic channel pooling is disabled by
default. Use Builder#enableDynamicChannelPool() to explicitly enable it. Note that
calling Builder#setNumChannels(int) will disable dynamic channel pooling even if it was
explicitly enabled.
Returns true if an com.google.api.gax.tracing.ApiTracer should be created and set on
the Spanner client. Enabling this only has effect if an OpenTelemetry or OpenCensus trace
exporter has been configured.
Returns true if built-in metrics are exported to the default Cloud Monitoring (GCM)
destination. Always false for InstanceType#OMNI clients, where the GCM sink is
unavailable. This flag does not affect a caller-owned client-metrics destination configured
with Builder#setClientMetricsProvider(MetricsProvider).
Returns whether extended OpenTelemetry tracing is enabled. Enabling this option will add the
following additional attributes to the traces that are generated by the client:
db.statement: Contains the SQL statement that is being executed.
thread.name: The name of the thread that executes the statement.
Returns whether experimental GCP fallback behavior is enabled through the
GOOGLE_SPANNER_EXPERIMENTAL_GCP_FALLBACK_RECOVERY environment variable. When enabled, the
fallback channels are wrapped in the grpc-gcp pool, instead of wrapping one pool per path.
true if the cached Spanner service instance is null or
closed. This will cause the method #getService() to create a new SpannerRpc
instance when one is requested.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2026-11-19 UTC."],[],[]]