Hacktoberfest 2026:維護者為十月標記出來的 issue,仍然開放、適合新手。 瀏覽 Hacktoberfest issue

(google-cloud-spanner) Built-in metrics fail when one process uses databases in different projects

未關閉
#18,155 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

維護者通常 1 天內回覆

@hippi345 已經在處理了。

開始於 2026年10月17日。

  • #18750 來自 @hippi345 —— 未關閉

評估

難度
4/5
預估耗時
3-5 天
新手友好度
45/100
Issue 類型
缺陷
描述清晰度
基本清楚
活躍度
活躍
技術堆疊
google-cloud, python

研究方向

首先使用 google-cloud-spanner 3.68.0 執行提供的雙專案範例,並檢查 spanner.Client 使用的內建指標路徑。將預設行為與 SPANNER_DISABLE_BUILTIN_METRICS 和 Client(disable_builtin_metrics=True) 進行比較,然後追蹤第一個用戶端的專案在匯出期間如何被重複使用。完成的標準是:每個資料庫的指標都到達各自的專案,同時不停用內建指標。

由索引模型根據 Issue 內容生成。

描述

Environment details
  • OS type and version: Linux (also happens on macOS)
  • Python version: 3.13
  • google-cloud-spanner version: 3.68.0
Steps to reproduce
  1. In one process, create two clients for databases in two different projects.
  2. Run a query on each.
  3. Wait a minute for the metrics export.
Code example
from google.cloud import spanner

a = spanner.Client(project="project-a")
b = spanner.Client(project="project-b")

a.instance("i").database("d").snapshot().execute_sql("SELECT 1")
b.instance("i").database("d").snapshot().execute_sql("SELECT 1")
What happens

The metrics export fails, and no metrics show up in Cloud Monitoring for either project:

InvalidArgument: 400 Field resource.labels.project_id had an invalid value of
"project-b": if present, must be the project number or ID in the request name
(projects/project-a).

Whichever client is created first decides where all metrics go, so everything from the other project is rejected — and it takes the first project's metrics down with it, since they're sent in the same request.

What I expected

Metrics for each database go to that database's project. Running against several projects is pretty normal, and right now it means no built-in metrics at all.

What I tried

SPANNER_DISABLE_BUILTIN_METRICS=true and Client(disable_builtin_metrics=True) both work, but only by giving up the metrics. As far as I can tell there's no way to pass in my own exporter or meter provider, so there's no way to keep them. Java has this (googleapis/google-cloud-java#13679) and there's an open request for Go (googleapis/google-cloud-go#11204), but I couldn't find anything similar here.

主要語言
Python
星號
5.4k
分支
1.8k
平均合併
2 天 6 小時
30 天內合併 PR
197

環境準備

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

googleapis/google-cloud-python 的其他 Issue

查看 googleapis/google-cloud-python 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。