GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Spanner: client-side metrics export uses wrong project · Issue #13240 · googleapis/google-cloud-java

Spanner: client-side metrics export uses wrong project #13240

New issue
Copy link
New issue
Copy link
Closed
#13262
Closed
Spanner: client-side metrics export uses wrong project#13240
#13262
Copy link
Assignees
rahul2393

Description

@RRap0so
RRap0so
opened on May 20, 2026
Issue body actions

Bug

When SpannerOptions.newBuilder().build() is used without an explicit .setProjectId(), the project ID defaults to the GCP metadata server value — which on GKE with shared VPC is the host project (e.g., a-gke-project-unrelated), not the application project.

DatabaseId.of("my-app-project", instance, db) correctly routes the database connection to the application project. However, the client-side built-in metrics export uses SpannerOptions.getProjectId() to determine the Cloud Monitoring target project. This causes metrics to be exported to the host project, which the service account typically lacks monitoring.metricWriter permission on.

Environment

  • GKE with shared VPC (host project != application project)
  • Spanner Java client with built-in metrics enabled (default in recent versions)
  • Service account has Spanner + Monitoring permissions on the application project only

Error

createServiceTimeSeries request failed for spanner metrics.
Need monitoring metric writer permission on project=a-gke-project-unrelated

Impact

  • Silent metric data loss
  • Repeated permission errors in logs
  • Potential memory pressure from accumulated retry buffers
  • Affects any Java Spanner client on GKE shared VPC without explicit .setProjectId()

Workaround

Explicitly set .setProjectId() on SpannerOptions.newBuilder():

SpannerOptions options = SpannerOptions.newBuilder()
    .setProjectId("my-app-project")
    .build();

Suggested fix

Add a setMetricsProjectId(String) to SpannerOptions.Builder that allows configuring the metrics export project independently. When not set, fall back to getProjectId(). Additionally, log a warning in getDatabaseClient() when the DatabaseId project differs from the metrics project.

Reference implementation: https://github.com/RRap0so/google-cloud-java/tree/fix/metrics-project-default

Activity

  1. RRap0so
    changed the title [-]Spanner: client-side metrics export uses wrong project on GKE with shared VPC[/-] [+]Spanner: client-side metrics export uses wrong project[/+] on May 20, 2026
  2. blakeli0
    assigned
    sakthivelmanii
    on May 20, 2026
  3. sakthivelmanii
    assigned
    rahul2393
    and unassigned
    sakthivelmanii
    on May 25, 2026
  4. rahul2393
    closed this as completedin #13262on May 29, 2026
  5. rahul2393
    added a commit that references this issue on May 29, 2026

    fix(spanner): derive built-in metrics project from database client (#…

    a577934
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @rahul2393
    rahul2393

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402775 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.