Skip to main content

micromegas_telemetry/
block_wire_format.rs

1// block wire format
2use serde::{Deserialize, Serialize};
3
4/// Payload sent by instrumented processes, containing serialized dependencies and objects.
5///
6/// The `dependencies` field contains the serialized data for all the
7/// `UserDefinedType` that are required to deserialize the `objects`.
8#[derive(Debug, Clone, Serialize, Deserialize)]
9pub struct BlockPayload {
10    /// Encoded as a CBOR byte string, but decoding also accepts the legacy
11    /// array-of-integers form still present in object storage — see the
12    /// wire-compat note on `crate::serde_byte_buf`.
13    #[serde(with = "crate::serde_byte_buf")]
14    pub dependencies: Vec<u8>,
15    /// See `dependencies`.
16    #[serde(with = "crate::serde_byte_buf")]
17    pub objects: Vec<u8>,
18}
19
20/// Block metadata sent by instrumented processes.
21///
22/// A block represents a chunk of telemetry data from a single stream.
23/// It contains timing information, references to the process and stream,
24/// and the actual payload of telemetry events.
25#[derive(Debug, Clone, Serialize, Deserialize)]
26pub struct Block {
27    #[serde(
28        deserialize_with = "micromegas_transit::uuid_utils::uuid_from_string",
29        serialize_with = "micromegas_transit::uuid_utils::uuid_to_string"
30    )]
31    pub block_id: uuid::Uuid,
32    #[serde(
33        deserialize_with = "micromegas_transit::uuid_utils::uuid_from_string",
34        serialize_with = "micromegas_transit::uuid_utils::uuid_to_string"
35    )]
36    pub stream_id: uuid::Uuid,
37    #[serde(
38        deserialize_with = "micromegas_transit::uuid_utils::uuid_from_string",
39        serialize_with = "micromegas_transit::uuid_utils::uuid_to_string"
40    )]
41    pub process_id: uuid::Uuid,
42    /// we send both RFC3339 times and ticks to be able to calibrate the tick
43    pub begin_time: String,
44    pub begin_ticks: i64,
45    pub end_time: String,
46    pub end_ticks: i64,
47    pub payload: BlockPayload,
48    pub object_offset: i64,
49    pub nb_objects: i32,
50}