Skip to content

Add OTLP payload byte-size chunking to Agent365Exporter#248

Merged
alexlu4250 merged 2 commits intomainfrom
user/jianblu/payload-chunking
Apr 28, 2026
Merged

Add OTLP payload byte-size chunking to Agent365Exporter#248
alexlu4250 merged 2 commits intomainfrom
user/jianblu/payload-chunking

Conversation

@alexlu4250
Copy link
Copy Markdown
Contributor

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

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
Copilot AI review requested due to automatic review settings April 27, 2026 23:14
@alexlu4250 alexlu4250 requested a review from a team as a code owner April 27, 2026 23:14
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 27, 2026

⚠️ Deprecation Warning: The deny-licenses option is deprecated for possible removal in the next major release. For more information, see issue 997.

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@alexlu4250
Copy link
Copy Markdown
Contributor Author

@alexlu4250 please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.

@microsoft-github-policy-service agree [company="{your company}"]

Options:

  • (default - no company specified) I have sole ownership of intellectual property rights to my Submissions and I am not making Submissions in the course of work for my employer.
@microsoft-github-policy-service agree
  • (when company given) I am making Submissions in the course of work for my employer (or my employer has intellectual property rights in my Submissions by contract or applicable law). I have permission from my employer to make Submissions and enter into this Agreement on behalf of my employer. By signing below, the defined term “You” includes me and my employer.
@microsoft-github-policy-service agree company="Microsoft"

Contributor License Agreement

@microsoft-github-policy-service agree company="Microsoft"

@alexlu4250 alexlu4250 enabled auto-merge (squash) April 28, 2026 20:33
@alexlu4250 alexlu4250 merged commit d08cf0a into main Apr 28, 2026
9 checks passed
@alexlu4250 alexlu4250 deleted the user/jianblu/payload-chunking branch April 28, 2026 21:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants