Add OTLP payload byte-size chunking to Agent365Exporter#248
Merged
alexlu4250 merged 2 commits intomainfrom Apr 28, 2026
Merged
Conversation
A365 OTLP traces endpoint enforces a 1 MB request body limit. The exporter previously batched by span count (512) with no byte-level enforcement, so batches of gen-AI spans could exceed 1 MB and get rejected (403/502/500). This adds two layers of defense: - Heuristic span size estimator (EstimateActivityBytes) with generous over-estimation - Byte-size chunking (ChunkBySize) that splits per-identity batches into sub-batches under MaxPayloadBytes (default 900 KB, configurable via Agent365ExporterOptions) - All-or-nothing semantics: if any chunk fails, the entire batch fails and the BatchExportProcessor retries Per-span truncation (250 KB cap in ExportFormatter) already existed; this complements it at the batch level. Mirrors Agent365-nodejs PR #237 (commit e05b3b6a). Work item: AB#37660995
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
Contributor
There was a problem hiding this comment.
Pull request overview
Adds byte-size-aware batching to the Agent365 OTLP/HTTP exporter to reduce the risk of exceeding the A365 ~1 MB request body limit (especially with large gen-AI spans), complementing existing per-span truncation.
Changes:
- Introduces heuristic OTLP span byte-size estimation (
estimate_span_bytes/estimate_value_bytes) and generic chunking (chunk_by_size) with a default max payload of 900 KB. - Updates
_Agent365Exporter.export()to chunk per (tenantId, agentId) group and send multiple requests with all-or-nothing semantics per group. - Adds unit + end-to-end style tests validating estimation, chunking invariants, truncation behavior, and exporter multi-request behavior.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
tests/observability/core/exporters/test_payload_chunking.py |
Adds coverage for estimator/chunker utilities and exporter multi-request chunking behavior. |
.../observability/core/exporters/utils.py |
Adds payload sizing constants, byte estimators, and a generic chunk_by_size helper. |
.../observability/core/exporters/agent365_exporter.py |
Chunks exports by estimated payload bytes and sends multiple POSTs per identity group. |
Contributor
Author
@microsoft-github-policy-service agree company="Microsoft" |
fpfp100
approved these changes
Apr 28, 2026
juliomenendez
approved these changes
Apr 28, 2026
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.
A365 OTLP traces endpoint enforces a 1 MB request body limit. The exporter previously batched by span count (512) with no byte-level enforcement, so batches of gen-AI spans could exceed 1 MB and get rejected (403/502/500).
This adds two layers of defense:
Heuristic span size estimator (EstimateActivityBytes) with generous over-estimation
Byte-size chunking (ChunkBySize) that splits per-identity batches into sub-batches under MaxPayloadBytes (default 900 KB, configurable via Agent365ExporterOptions)
All-or-nothing semantics: if any chunk fails, the entire batch fails and the BatchExportProcessor retries
Per-span truncation (250 KB cap in ExportFormatter) already existed; this complements it at the batch level.
Mirrors Agent365-nodejs PR #237 (commit e05b3b6a).
Work item: AB#37660995