Skip to content

Running driver outside GCP leads to a potentially very long initialisation due to internal calls to an internal GCP URL #2250

@jartur

Description

@jartur

There's an issue with Spanner JDBC driver when run locally (outside of GCP). It boils down to how during connection initialisation it tries to determine whether it's running inside GCP, using an http request to metadata.google.internal which, at least on macOS takes up to 150 seconds to fail, and since this is a blocking call it means that any connection can take that long to be established. This makes it impossible to use the newer versions of the driver (newer than 2.26.1) for local development.

The function in question is com.google.cloud.opentelemetry.detection.GCPPlatformDetector#isRunningOnGcp

Here are two rough paths I found that lead to that function called during initialisation, one of them can be turned off by disabling grpc metrics, but the other one is not possible to override.

com.google.cloud.opentelemetry.detection.GCPPlatformDetector#isRunningOnGcp
com.google.cloud.spanner.BuiltInMetricsProvider#createResourceAttributes 
com.google.cloud.spanner.BuiltInMetricsProvider#getOrCreateOpenTelemetry 
com.google.cloud.spanner.BuiltInMetricsProvider#enableGrpcMetrics 

builder.put(CLOUD_REGION_KEY, BuiltInMetricsProvider.detectClientLocation()); 
com.google.cloud.spanner.TraceWrapper#createCommonAttributes
com.google.cloud.spanner.SessionClient#SessionClient 

Metadata

Metadata

Assignees

Labels

api: spannerIssues related to the googleapis/java-spanner-jdbc API.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions