public static class MetricDumpSerialization.MetricSerializationResult
This class encapsulates all serialized metrics and a count for each metric type.
The counts are stored separately from the metrics since the final count for any given type can only be
determined after all metrics of that type were serialized. Storing them together in a single byte would
require an additional copy of all serialized metrics, as you would first have to serialize the metrics into a
temporary buffer to calculate the counts, write the counts to the final output and copy all metrics from the
Note that while one could implement the serialization in such a way so that at least 1 byte (a validity flag)
is written for each metric, this would require more bandwidth due to the sheer number of metrics.