canic-core 0.30.15

Canic — a canister orchestration and management toolkit for the Internet Computer
Documentation
use crate::dto::prelude::*;

//
// Metrics DTOs
//

//
// MetricsKind
//
// Metric family selector.
//

#[derive(CandidType, Clone, Copy, Deserialize)]
#[remain::sorted]
pub enum MetricsKind {
    Access,
    CyclesFunding,
    CyclesTopup,
    DelegatedAuth,
    Http,
    Icc,
    Lifecycle,
    Perf,
    RootCapability,
    System,
    Timer,
}

//
// MetricEntry
//
// Unified metrics row.
//

#[derive(CandidType, Deserialize)]
pub struct MetricEntry {
    // Ordered labels.
    pub labels: Vec<String>,

    // Optional principal dimension.
    pub principal: Option<Principal>,

    // Metric payload.
    pub value: MetricValue,
}

//
// MetricValue
//

#[derive(CandidType, Deserialize)]
pub enum MetricValue {
    Count(u64),
    CountAndU64 { count: u64, value_u64: u64 },
    U128(u128),
}

//
// QueryPerfSample
//
// Same-call query performance sample.
//

#[derive(CandidType, Deserialize)]
pub struct QueryPerfSample<T> {
    // Query result returned by the probe.
    pub value: T,

    // Local instruction counter observed in the same query call context.
    pub local_instructions: u64,
}