Skip to main content

to_len

Function to_len 

Source
pub fn to_len<T: TraceData, S: AsRef<[Span<T>]>>(traces: &[S]) -> u32
Expand description

Computes the number of bytes required to encode the given traces.

This does not allocate any actual buffer, but simulates writing in order to measure the encoded size of the traces.

§Arguments

  • traces - A reference to a slice of spans.

§Returns

  • u32 - The number of bytes that would be written by the encoder.

§Examples

use libdd_trace_utils::msgpack_encoder::v04::to_len;
use libdd_trace_utils::span::v04::SpanSlice;

let span = SpanSlice {
    name: "test-span",
    ..Default::default()
};
let traces = vec![vec![span]];
let encoded_len = to_len(&traces);

assert!(encoded_len > 0);