Repository navigation
fix(bigtable): skip metrics export if previous write was too recent #18630
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
abhishekacharya200
wants to merge
3
commits into
googleapis:main
Choose a base branch
from
abhishekacharya200:fix-bigtable-metrics-shutdown-export
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
93d8551
fix(bigtable): skip metrics export if previous write was too recent
abhishekacharya200 58ef62a
fix(bigtable): only record the export time after every project is wri…
abhishekacharya200 3209ffa
fix(bigtable): track the last metrics export time per project
abhishekacharya200 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
30 seems like a magic number, why 30? should this be 60?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using
30(half the 60s interval) gives plenty of headroom so normal 60s periodic ticks are never skipped due to latency/jitterSee analysis from Gemini below
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Following up on #18630 (comment) and #18630 (comment):
When a process exits shortly after a 60s periodic export, teardown triggers a final flush that Cloud Monitoring rejects with
400(The same issue seen in #18576).We have 2 potential solutions here:
or
30stimer check inexport()(skipping the RPC if the last export was< 30sago)Shutdown hook Lets partial writes and other projects go through on exit, since
create_service_time_seriesstill writes any new time series in the batch even when returning400for points exported too recently. However,export()already catches errors and logs a warning today, so we'd still make a rejected400RPC and log a warning on exit—or if we suppress warnings on shutdown, we'd hide real errors for short-lived scripts (< 60s) where teardown is the only export. Also, sinceMeterProvider's built-inatexithook callsexporter.export()beforeexporter.shutdown(), we'd have to passshutdown_on_exit=FalsetoMeterProviderand register our ownatexithook so the shutdown flag is set beforeMeterProvider.shutdown()runs.30stimer check inexport()Avoids the400RPC and warning log noise on normal exit, and works without the extra shutdown hook plumbing that is needed for1.. It skips the final< 30sof points on exit for a project that just exported, though if we change_last_export_timeto a per-project dict (dict[str, float]), other projects will still go through.I'm leaning toward keeping the
30stimer check (updated to track_last_export_timeper project) to avoid the warning noise, failed RPC on exit, andatexitplumbing, unless we think preserving the final< 30sof partial time series is worth those trade-offs. Thoughts?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the detailed write up, both of you. I went with the 30 second check and made it per project in 3209ffa: each project keeps its own last write time, so a project that just exported skips the final flush on exit while other projects still go through, and after a partial failure only the failed project is written again. Happy to switch to the shutdown hook instead if you'd rather keep the final partial series.