Skip to main content

serialise_batch

Function serialise_batch 

Source
pub fn serialise_batch(records: &[Log]) -> OtlpResult<String>
Expand description

Serialise a batch of records into a single OTLP/HTTP JSON envelope.

Each record is first rendered via its LogFormat::OTLP Display impl, which produces an attributes / body / severityNumber / severityText / spanId / timeUnixNano / traceId shape. Those individual record JSON blobs are then nested inside the OTLP resourceLogs[].scopeLogs[].logRecords[] envelope the collector expects.

§Errors

Returns OtlpError::Serialise if a record fails to parse back as JSON (should be impossible — the OTLP Display impl emits valid JSON by construction).