(WIP) Support 413 handling - #48548
Draft
Radhika Gupta (rads-1996) wants to merge 6 commits into
Draft
Conversation
|
Azure Pipelines: Successfully started running 1 pipeline(s). 9 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
Radhika Gupta (rads-1996)
force-pushed
the
support-413-handling
branch
from
August 12, 2026 17:23
d675163 to
f1ae240
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
Adds HTTP 413 handling to the Azure Monitor OpenTelemetry exporter.
Changes:
- Splits oversized batches and persists sub-batches for retry.
- Avoids logging oversized telemetry payloads.
- Adds tests, a reproduction sample, and release notes.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
export/_base.py |
Implements payload sizing, splitting, persistence, and safer logging. |
tests/test_base_exporter.py |
Tests 413 handling and payload splitting. |
sample_test_413.py |
Adds a manual 413 reproduction script. |
CHANGELOG.md |
Documents the feature. |
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
Radhika Gupta (rads-1996)
force-pushed
the
support-413-handling
branch
from
August 13, 2026 20:43
8a54ccb to
3d17a68
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.
Suppressed comments (3)
sdk/monitor/azure-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/export/_base.py:346
- The 413 contract requires splitting and resending down to individual items, but this branch drops the entire batch whenever offline storage is disabled. Users who opt out of persistence therefore receive none of the spec-aligned 413 handling described by this PR. Split/retry in memory regardless of storage availability, using persistence only as a fallback.
if not self.storage:
if not self._is_stats_exporter():
logger.debug(
"Payload too large but offline storage is disabled; dropping %d envelope(s): %s.",
len(envelopes),
response_error.message,
)
if self._should_collect_customer_sdkstats():
track_dropped_items(envelopes, DropCode.CLIENT_STORAGE_DISABLED)
return ExportResult.FAILED_NOT_RETRYABLE
sdk/monitor/azure-monitor-opentelemetry-exporter/CHANGELOG.md:22
- This feature is introduced in the unreleased
1.0.0b57section above, but these duplicate notes place it in the already released1.0.0b56history (2026-08-06), incorrectly implying that published version contains the new behavior. Remove this entry from the historical release.
- Handle `413 Payload Too Large` responses by splitting the batch and persisting each half to
local storage for retry at a smaller size, instead of dropping the entire batch. A single
envelope that is too large to split is dropped.
sdk/monitor/azure-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/export/_base.py:359
- When a 413 occurs while draining storage, the original blob remains on disk until
_transmitreturns (_transmit_from_storagelines 294–302), while this line writes the split copies immediately. With the default 50 MiB cap, a large original can consume enough capacity that only the first split is persisted; the later split is dropped, and then the original is deleted, permanently losing telemetry. Replace the original without temporarily duplicating its contents (or resend the splits directly), and cover a 413 encountered during storage drain.
result_from_storage_put = self.storage.put([x.as_dict() for x in sub_batch])
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
Add support to handle the 413 payload too large status code, in alignment with spec.
All SDK Contribution checklist:
General Guidelines and Best Practices
Testing Guidelines