PayloadChunking Class

Definition

Heuristic span size estimation and byte-level chunking for OTLP/HTTP JSON payloads.

The Agent 365 OTLP traces endpoint enforces a 1 MB request body limit. Per-span truncation (250 KB cap inside ExportFormatter) prevents any single span from being too large; this class provides the second layer of defense at the batch level by splitting batches into sub-batches whose cumulative estimated size stays under MaxPayloadBytes.

public static class PayloadChunking
type PayloadChunking = class
Public Class PayloadChunking
Inheritance
PayloadChunking

Methods

Name Description
ChunkBySize<T>(IEnumerable<T>, Func<T,Int64>, Int64)

Splits items into sub-batches whose cumulative estimated size stays under maxChunkBytes.

Invariants:

  • Input order is preserved across chunks.
  • Empty input produces empty output.
  • A single item whose size exceeds maxChunkBytes forms its own single-item chunk (never silently dropped).
  • No chunk is ever empty.
EstimateActivityBytes(Activity)

Heuristic estimator for the serialized size of an OTLP span produced from the supplied Activity when emitted as OTLP/HTTP JSON.

Uses generous constants tuned to over-estimate by ~25-50%, providing headroom for JSON serializer variance (whitespace, enum representation, integer-as-string).

EstimateValueBytes(Object)

Estimates the serialized byte size of a single attribute value in OTLP/HTTP JSON.

Applies to