Package com.google.cloud.spanner
Class SpannerOptions
java.lang.Object
com.google.cloud.ServiceOptions<Spanner,SpannerOptions>
com.google.cloud.spanner.SpannerOptions
- All Implemented Interfaces:
Serializable
Options for the Cloud Spanner service.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classBuilder forSpannerOptionsinstances.static interfaceSpannerOptions.CallContextConfiguratorcan be used to modify theApiCallContextfor one or more specific RPCs.static interfaceInterface that can be used to provideCallCredentialstoSpannerOptions.static interfaceExecutorProviderthat is used forAsyncResultSet.static classImplementation ofSpannerOptions.CloseableExecutorProviderthat uses a fixed singleScheduledExecutorService.static classHelper class to configure timeouts for specific Spanner RPCs.static interfaceThe environment to read configuration values from. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final io.grpc.Context.Key<SpannerOptions.CallContextConfigurator>Context key for theSpannerOptions.CallContextConfiguratorto use.Fields inherited from class com.google.cloud.ServiceOptions
clientLibToken, CREDENTIAL_ENV_NAME, credentials -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncreateAsyncExecutorProvider(int poolSize, long keepAliveTime, TimeUnit unit) Creates aSpannerOptions.CloseableExecutorProviderthat can be used as anExecutorProviderfor the async API.static voidDisables OpenCensus metrics.static voidEnables OpenCensus traces.static voidEnables OpenTelemetry metrics.static voidEnables OpenTelemetry traces.static com.google.cloud.spanner.SpannerOptions.TracingFrameworkcom.google.api.gax.tracing.ApiTracerFactorycom.google.api.core.ApiFunction<io.grpc.ManagedChannelBuilder,io.grpc.ManagedChannelBuilder> com.google.api.gax.rpc.TransportChannelProviderstatic com.google.cloud.grpc.GrpcTransportOptionsprotected Stringstatic SpannerOptionsReturns default instance ofSpannerOptions.protected StringgetDefaultQueryOptions(DatabaseId databaseId) Returns the default query options to use for the specific database.com.google.cloud.grpc.GcpManagedChannelOptionscom.google.api.gax.grpc.GrpcInterceptorProviderintio.opentelemetry.api.OpenTelemetryReturns an instance of OpenTelemetry.org.threeten.bp.Durationintcom.google.api.gax.retrying.RetrySettingsprotected SpannerRpcbooleanbooleanbooleanReturns true if anApiTracershould be created and set on the Spanner client.static booleanstatic booleanbooleanReturns whether extended OpenTelemetry tracing is enabled.booleanbooleanbooleanbooleanstatic SpannerOptions.Builderprotected booleanshouldRefreshRpc(com.google.cloud.ServiceRpc cachedRpc) protected booleanshouldRefreshService(Spanner cachedService) static voidSets the environment to use to read configuration to the default environment.static voiduseEnvironment(SpannerOptions.SpannerEnvironment environment) Sets the environment to use to read configuration.Methods inherited from class com.google.cloud.ServiceOptions
baseEquals, baseHashCode, defaultRetrySettings, getAppEngineAppId, getAppEngineProjectId, getAppEngineProjectIdFromAppId, getApplicationName, getClientLibToken, getClock, getCredentials, getDefaultProjectId, getDefaultRetrySettings, getFromServiceLoader, getGoogApiClientLibName, getGoogleCloudProjectId, getHost, getLibraryName, getLibraryVersion, getMergedHeaderProvider, getNoRetrySettings, getProjectId, getQuotaProjectId, getResolvedApiaryHost, getResolvedHost, getRetrySettings, getRpc, getScopedCredentials, getService, getServiceAccountProjectId, getTransportOptions, getUniverseDomain, getUserAgent, hasValidUniverseDomain, newInstance, projectIdRequired
-
Field Details
-
CALL_CONTEXT_CONFIGURATOR_KEY
public static final io.grpc.Context.Key<SpannerOptions.CallContextConfigurator> CALL_CONTEXT_CONFIGURATOR_KEYContext key for theSpannerOptions.CallContextConfiguratorto use.
-
-
Constructor Details
-
SpannerOptions
-
-
Method Details
-
createAsyncExecutorProvider
public static SpannerOptions.CloseableExecutorProvider createAsyncExecutorProvider(int poolSize, long keepAliveTime, TimeUnit unit) Creates aSpannerOptions.CloseableExecutorProviderthat can be used as anExecutorProviderfor the async API. TheExecutorProviderwill 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.- Parameters:
poolSize- the maximum number of threads to create in the poolkeepAliveTime- the time that an unused thread in the pool should be kept aliveunit- the time unit used for the keepAliveTime- Returns:
- a
SpannerOptions.CloseableExecutorProviderthat can be used forSpannerOptions.Builder.setAsyncExecutorProvider(CloseableExecutorProvider)
-
getDefaultInstance
Returns default instance ofSpannerOptions. -
newBuilder
-
useEnvironment
Sets the environment to use to read configuration. The default will read configuration from environment variables. -
useDefaultEnvironment
public static void useDefaultEnvironment()Sets the environment to use to read configuration to the default environment. This will read configuration from environment variables. -
enableOpenTelemetryTraces
public static void enableOpenTelemetryTraces()Enables OpenTelemetry traces. Enabling OpenTelemetry traces will disable OpenCensus traces. By default, OpenCensus traces are enabled. -
enableOpenCensusTraces
@ObsoleteApi("The OpenCensus project is deprecated. Use enableOpenTelemetryTraces to switch to OpenTelemetry traces") public static void enableOpenCensusTraces()Enables OpenCensus traces. Enabling OpenCensus traces will disable OpenTelemetry traces. -
getActiveTracingFramework
public static com.google.cloud.spanner.SpannerOptions.TracingFramework getActiveTracingFramework() -
disableOpenCensusMetrics
public static void disableOpenCensusMetrics()Disables OpenCensus metrics. Disable OpenCensus metrics before creating Spanner client. -
isEnabledOpenCensusMetrics
public static boolean isEnabledOpenCensusMetrics() -
enableOpenTelemetryMetrics
public static void enableOpenTelemetryMetrics()Enables OpenTelemetry metrics. Enable OpenTelemetry metrics before creating Spanner client. -
isEnabledOpenTelemetryMetrics
public static boolean isEnabledOpenTelemetryMetrics() -
getDefaultProject
- Overrides:
getDefaultProjectin classcom.google.cloud.ServiceOptions<Spanner,SpannerOptions>
-
getChannelProvider
public com.google.api.gax.rpc.TransportChannelProvider getChannelProvider() -
getChannelConfigurator
public com.google.api.core.ApiFunction<io.grpc.ManagedChannelBuilder,io.grpc.ManagedChannelBuilder> getChannelConfigurator() -
getInterceptorProvider
public com.google.api.gax.grpc.GrpcInterceptorProvider getInterceptorProvider() -
getNumChannels
public int getNumChannels() -
getTransportChannelExecutorThreadNameFormat
-
getSessionPoolOptions
-
getDatabaseRole
-
getSessionLabels
-
getSpannerStubSettings
-
getInstanceAdminStubSettings
-
getDatabaseAdminStubSettings
-
getPartitionedDmlTimeout
public org.threeten.bp.Duration getPartitionedDmlTimeout() -
isGrpcGcpExtensionEnabled
public boolean isGrpcGcpExtensionEnabled() -
getGrpcGcpOptions
public com.google.cloud.grpc.GcpManagedChannelOptions getGrpcGcpOptions() -
isAutoThrottleAdministrativeRequests
public boolean isAutoThrottleAdministrativeRequests() -
getRetryAdministrativeRequestsSettings
public com.google.api.gax.retrying.RetrySettings getRetryAdministrativeRequestsSettings() -
isTrackTransactionStarter
public boolean isTrackTransactionStarter() -
getCallCredentialsProvider
-
getCompressorName
-
isLeaderAwareRoutingEnabled
public boolean isLeaderAwareRoutingEnabled() -
getDirectedReadOptions
-
isAttemptDirectPath
@BetaApi public boolean isAttemptDirectPath() -
getOpenTelemetry
public io.opentelemetry.api.OpenTelemetry getOpenTelemetry()Returns an instance of OpenTelemetry. If OpenTelemetry object is not set via SpannerOptions then GlobalOpenTelemetry will be used as fallback. -
getApiTracerFactory
public com.google.api.gax.tracing.ApiTracerFactory getApiTracerFactory()- Overrides:
getApiTracerFactoryin classcom.google.cloud.ServiceOptions<Spanner,SpannerOptions>
-
isEnableApiTracing
public boolean isEnableApiTracing()Returns true if anApiTracershould be created and set on the Spanner client. Enabling this only has effect if an OpenTelemetry or OpenCensus trace exporter has been configured. -
isUseVirtualThreads
@BetaApi public boolean isUseVirtualThreads() -
isEnableExtendedTracing
public boolean isEnableExtendedTracing()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.
-
getDefaultQueryOptions
Returns the default query options to use for the specific database. -
getAsyncExecutorProvider
-
getPrefetchChunks
public int getPrefetchChunks() -
getDecodeMode
-
getDefaultGrpcTransportOptions
public static com.google.cloud.grpc.GrpcTransportOptions getDefaultGrpcTransportOptions() -
getDefaultHost
- Overrides:
getDefaultHostin classcom.google.cloud.ServiceOptions<Spanner,SpannerOptions>
-
getScopes
- Specified by:
getScopesin classcom.google.cloud.ServiceOptions<Spanner,SpannerOptions>
-
getSpannerRpcV1
-
shouldRefreshService
- Overrides:
shouldRefreshServicein classcom.google.cloud.ServiceOptions<Spanner,SpannerOptions> - Returns:
trueif the cached Spanner service instance isnullor closed. This will cause the methodServiceOptions.getService()to create a newSpannerRpcinstance when one is requested.
-
shouldRefreshRpc
protected boolean shouldRefreshRpc(com.google.cloud.ServiceRpc cachedRpc) - Overrides:
shouldRefreshRpcin classcom.google.cloud.ServiceOptions<Spanner,SpannerOptions> - Returns:
trueif the cachedServiceRpcinstance isnullor closed. This will cause the methodServiceOptions.getRpc()to create a newSpannerinstance when one is requested.
-
toBuilder
- Specified by:
toBuilderin classcom.google.cloud.ServiceOptions<Spanner,SpannerOptions>
-
getEndpoint
-