| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
trace_call() wraps every Spanner operation with a bare MetricsCapture() that creates a MetricsTracer without project_id or instance_id. Since every caller of trace_call already provides its own MetricsCapture with resource_info, this inner one is redundant. The redundant tracer records operation metrics with incomplete resource labels on every operation. Because OpenTelemetry uses cumulative aggregation, these orphan data points persist for the process lifetime and get re-exported every 60 seconds. Cloud Monitoring rejects them with INVALID_ARGUMENT (missing instance_id), producing repeated error logs. Removing the bare MetricsCapture from trace_call eliminates the orphan metric data points entirely. Callers continue to provide their own MetricsCapture(resource_info) with correct labels. Fixes: googleapis#1319
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request addresses a critical issue where a redundant OpenTelemetry MetricsCapture instance within the trace_call function was causing incorrect and incomplete metrics to be exported. By removing this unnecessary MetricsCapture, the system now correctly uses the caller-provided metrics context, resolving INVALID_ARGUMENT errors in Cloud Monitoring and preventing the accumulation of orphan metric data points. Highlights
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here. Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. Footnotes
|
Sorry, something went wrong.
There was a problem hiding this comment.
This pull request removes the MetricsCapture context manager from the trace_call function in _opentelemetry_tracing.py. This change discontinues the use of MetricsCapture within the OpenTelemetry tracing context for Spanner client calls. There is no feedback to provide on the changes.
Sorry, something went wrong.
|
Hi @waiho-gumloop, The code in this repository has moved to https://github.com/googleapis/google-cloud-python/tree/main/packages/google-cloud-spanner. Please could you open a new PR in google-cloud-python? |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Summary
trace_call() wraps every Spanner operation with a bare MetricsCapture() that creates a MetricsTracer without project_id or instance_id. Since every caller of trace_call already provides its own MetricsCapture(resource_info) with correct labels, the one inside trace_call is redundant and harmful.
The redundant tracer records operation metrics (via record_operation_completion()) with incomplete resource labels on every operation. Because OpenTelemetry uses cumulative aggregation, these orphan data points persist for the process lifetime and get re-exported every 60 seconds by the PeriodicExportingMetricReader. Cloud Monitoring rejects them with:
Root cause
When Python evaluates with trace_call(...) as span, MetricsCapture(resource_info):, the execution order is:
This creates persistent orphan aggregation buckets in the OpenTelemetry SDK that are re-exported every 60s.
History
Fix
Remove the bare MetricsCapture() from trace_call. All ~27 call sites already provide their own MetricsCapture with correct resource labels.
Testing
All existing unit tests pass (46/46). The change only removes the redundant context manager; span/trace behavior is unchanged.
Fixes googleapis/google-cloud-python#16173