Skip to content

chore(spanner): add missing project_id label to metrics - #6843

Open
olavloite wants to merge 1 commit into
googleapis:mainfrom
olavloite:spanner-add-missing-project-id
Open

olavloite wants to merge 1 commit into
googleapis:mainfrom
olavloite:spanner-add-missing-project-id

Conversation

@olavloite

Copy link
Copy Markdown
Contributor

Adds the missing project_id label to metrics.

Note: Added as a 'chore:' and not 'fix:' as these metrics had not yet been released.

@olavloite
olavloite requested review from a team as code owners September 16, 2026 15:45
@product-auto-label product-auto-label Bot added the api: spanner Issues related to the Spanner API. label Sep 16, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request adds the project_id attribute to the monitored resource labels in resource_to_monitored_resource and updates the corresponding unit and mock tests to assert its presence. Feedback suggests refactoring the match block in exporter.rs to reuse the existing is_monitored_resource_label helper function, which reduces duplication and improves maintainability.

Comment on lines 331 to 335
match key_str {
"instance_id" | "location" | "instance_config" | "client_hash" => {
"project_id" | "instance_id" | "location" | "instance_config" | "client_hash" => {
labels.insert(key_str.to_string(), value_to_string(val));
}
_ => {}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Instead of duplicating the list of monitored resource labels here, we can reuse the existing helper function is_monitored_resource_label which is already defined in this file. This reduces duplication and prevents future inconsistencies.

        if is_monitored_resource_label(key_str) {
            labels.insert(key_str.to_string(), value_to_string(val));
        }

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this makes a lot of sense to me. Any reason not to reason the method @olavloite ?

@codecov

codecov Bot commented Sep 16, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.91%. Comparing base (2faf555) to head (b8ff358).
⚠️ Report is 9 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6843      +/-   ##
==========================================
- Coverage   96.92%   96.91%   -0.01%     
==========================================
  Files         327      327              
  Lines      108648   108651       +3     
==========================================
- Hits       105309   105302       -7     
- Misses       3339     3349      +10     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@alvarowolfx alvarowolfx left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gonna approve it, but ideally it should be refactored to use is_monitored_resource_label. Also you can use impl instead of chore, since you don't consider this a fix and metrics is still not available.

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

Labels

api: spanner Issues related to the Spanner API.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants