Skip to main content

encode_snapshot

Function encode_snapshot 

Source
pub fn encode_snapshot(
    agent_id: String,
    start: i64,
    end: i64,
    metrics: HashMap<String, Vec<(i64, f64)>>,
    threshold: usize,
) -> Result<Vec<u8>, Box<dyn Error>>
Expand description

Encode metrics as a 5-minute snapshot with LTTB downsampling per metric

§Arguments

  • agent_id - Agent identifier
  • start - Window start timestamp (ms)
  • end - Window end timestamp (ms)
  • metrics - Map of metric_name -> [(timestamp, value), …]
  • threshold - LTTB downsampling threshold (points per metric)

§Returns

MessagePack-encoded snapshot ready for HTTP POST