Repository navigation
Conversation
…te double shutdown warning
Pull request dashboard statusWaiting on the author · refreshed 2026-10-17 02:50 UTC Respond to 1 review item (e.g. link a commit, explain why not, ask a follow-up):
Status above doesn't look right?
|
|
please sign the CLA |
|
how does this PR fix #5157? |
|
@ocelotl Thank you for reviewing! Regarding how this PR addresses #5157: The traceback captured in #5157 shows two symptoms occurring together:
These two failures share a single root cause:
This PR fixes both:
|
|
/dashboard route:reviewers |
|
@dlowzzxx, this pull request was routed to reviewers. |
|
Ok, I looked into this, and I think this PR is valuable, but it still does not fix #5157. You are right that there is a leaked ticker thread, but it does not cause the issue here in the way this PR is intended to fix it:
#5157 is 2 separate problems, I am adding their fixes here:
I'll comment in this PR diff with the parts of this PR I find valuable. |
| data_points=data_points, | ||
| aggregation_temporality=aggregation_temporality, | ||
| ) | ||
| else: |
There was a problem hiding this comment.
This is a genuine bug fix, Aggregation is a public API so we can expect to handle this case.
A user with a custom Aggregation would get a warning with every export, so we probably want to reconsider this particular approach.
There was a problem hiding this comment.
Addressed: warnings are now deduplicated via self._unsupported_aggregation_warned using (instrument, type(view_instrument_match._aggregation)) as the key, ensuring unmapped or custom aggregations only log a warning once per instrument.
There was a problem hiding this comment.
I would suggest another approach: take look here.
I think it is better to put the check this PR attempts to introduce there as well. If we use the current approach from this PR the warning shows once and only if the process starts after its logging is set up, if not the warning is lost and the user never realizes their data is gone. Here we can just keep the else/continue.
There was a problem hiding this comment.
Addressed: moved the unsupported aggregation check to _check_view_instrument_compatibility (returning False so the incompatible view is not applied, matching #5461) and kept the clean else: continue fallback in MetricReaderStorage.collect().
| @@ -0,0 +1 @@ | |||
| `opentelemetry-sdk`: log a warning and skip unmapped aggregations in `MetricReaderStorage.collect` to prevent `UnboundLocalError`, and shut down periodic metric readers in tests to prevent background daemon thread leaks. | |||
There was a problem hiding this comment.
This should be updated, test case changes are not something we want to tell users about.
There was a problem hiding this comment.
Updated: simplified the changelog fragment to describe only user-facing SDK behavior (skip unmapped aggregations in MetricReaderStorage.collect and log a warning once per instrument to prevent UnboundLocalError).
| @@ -245,11 +245,14 @@ def test_exporter_temporality_preference(self): | |||
| }, | |||
| ) | |||
| pmr = PeriodicExportingMetricReader(exporter) | |||
| @@ -258,11 +261,14 @@ def test_exporter_aggregation_preference(self): | |||
| }, | |||
| ) | |||
| pmr = PeriodicExportingMetricReader(exporter) | |||
There was a problem hiding this comment.
Updated to self.addCleanup(pmr.shutdown) as in #5641.
ocelotl
left a comment
There was a problem hiding this comment.
This PR contains valuable changes but needs refactoring, its changes are also not a fix for the target issue.
|
@ocelotl Thank you for the detailed review and clarifying the root cause for #5157! I have refactored this PR according to your feedback:
/dashboard route:reviewers |
|
@ocelotl All review feedback and inline threads have been addressed and updated:
Latest commit: b232b18 /dashboard route:reviewers |
|
thanks! please resolve the conflicts ✌️ so I can continue reviewing and approving |
…y-python into fix/metrics-test-thread-leak-collector-fallback-5157
|
@ocelotl Conflicts with main have been resolved cleanly! All tests pass. Ready for your review and approval ✌️ /dashboard route:reviewers |
| warn_key = (instrument, type(view_instrument_match._aggregation)) | ||
| if warn_key not in self._unsupported_aggregation_warned: | ||
| self._unsupported_aggregation_warned.add(warn_key) | ||
| _logger.warning( |
There was a problem hiding this comment.
This would render something like this
Unsupported aggregation <opentelemetry.sdk.metrics._internal.aggregation._SumAggregation object at 0x79db26bccc20> for instrument <opentelemetry.sdk.metrics._internal.instrument._Counter object at 0x79db26bccad0>
Better to use type(view_instrument_match._aggregation).__name__ and instrument.name.
There was a problem hiding this comment.
Addressed: updated warning formatting to use ype(view._aggregation).name and instrument.name.
…rument_compatibility (open-telemetry#5622)
|
@ocelotl Thank you for the review and guidance! I have updated the implementation to align with PR #5461:
Commit: /dashboard route:reviewers |
…ad-leak-collector-fallback-5157
|
Rebased on latest |
|
Hi @dlowzzxx — just a friendly reminder that this pull request is waiting on you. The dashboard status comment has the open items and is kept current.
|
…ack-5157 Assisted-by: OpenAI Codex
Assisted-by: OpenAI Codex
Description
Related to #5157
Prevent MetricReaderStorage.collect from using unassigned or stale metric data when it encounters an unsupported aggregation. Drop and unsupported aggregations are skipped, while supported metrics are still collected
Reject unsupported custom aggregation views during initialization, log a warning and use the default view instead. The tests cover both fallback and collection with supported and unsupported matches
Also use addCleanup to shut down the periodic exporting reader in the two affected preference tests. The changelog remains .changelog/5622.fixed
Type of change
Verification
Refreshed with upstream main and pushed at
58107d0224cb391129144e27355a249e94409bcbon October 14Focused metric storage tests pass, 20 tests. The SDK metrics suite passes 332 tests plus 44 subtests, with 11 platform skips on Windows. Two shutdown warnings are emitted after the successful suite summary
Fresh CI identified Pylint findings for renamed override parameters and an extra collection branch. The override now uses the base parameter names, and the redundant drop-specific branch was removed because the final fallback already skips it
Pylint 3.3.4 passes on both changed files with only the Windows checkout line-ending warning disabled. Ruff 0.16.0 lint and formatting, and whitespace checks pass. Full local tox lint is not a passing result because of checkout-wide CRLF warnings and os.fork findings in untouched platform-specific files
Full precommit, typecheck and the official dependency matrix were not rerun locally. The latest GitHub check rollup is SUCCESS across 579 contexts. Human re-review remains required
Checklist
The refresh used OpenAI Codex assistance, disclosed in commit trailers