mirror of
https://github.com/sched-ext/scx.git
synced 2024-11-28 21:50:23 +00:00
scx_stats: Add "all" attribute and rename metadata type strings
This commit is contained in:
parent
ebc1a89c34
commit
a9922deaa2
@ -17,7 +17,7 @@ struct DomainStats {
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Serialize, Deserialize, Stats)]
|
||||
#[stat(desc = "cluster statistics")]
|
||||
#[stat(desc = "cluster statistics", all)]
|
||||
struct ClusterStats {
|
||||
pub name: String,
|
||||
#[stat(desc = "update timestamp")]
|
||||
|
@ -18,7 +18,7 @@ struct DomainStats {
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Serialize, Deserialize, Stats)]
|
||||
#[stat(desc = "cluster statistics")]
|
||||
#[stat(desc = "cluster statistics", all)]
|
||||
struct ClusterStats {
|
||||
pub name: String,
|
||||
#[stat(desc = "update timestamp")]
|
||||
|
@ -10,10 +10,15 @@ use syn::{
|
||||
|
||||
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||
pub enum ScxStatsKind {
|
||||
#[serde(rename = "i64")]
|
||||
I64,
|
||||
#[serde(rename = "u64")]
|
||||
U64,
|
||||
#[serde(rename = "float")]
|
||||
Float,
|
||||
#[serde(rename = "string")]
|
||||
String,
|
||||
#[serde(rename = "struct")]
|
||||
Struct(String),
|
||||
}
|
||||
|
||||
@ -160,6 +165,7 @@ impl ScxStatsData {
|
||||
|
||||
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||
pub enum ScxStatsAttr {
|
||||
All,
|
||||
Desc(String),
|
||||
OMPrefix(String),
|
||||
}
|
||||
@ -174,6 +180,7 @@ impl Parse for ScxStatsAttrVec {
|
||||
loop {
|
||||
let ident = input.parse::<Ident>()?;
|
||||
match ident.to_string().as_str() {
|
||||
"all" => attrs.push(ScxStatsAttr::All),
|
||||
"desc" => {
|
||||
input.parse::<Token!(=)>()?;
|
||||
attrs.push(ScxStatsAttr::Desc(input.parse::<LitStr>()?.value()))
|
||||
@ -197,6 +204,8 @@ impl Parse for ScxStatsAttrVec {
|
||||
|
||||
#[derive(Clone, Debug, Default, Serialize, Deserialize)]
|
||||
pub struct ScxStatsAttrs {
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub all: Option<bool>,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub desc: Option<String>,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
@ -212,6 +221,7 @@ impl ScxStatsAttrs {
|
||||
let vec = attr.parse_args::<ScxStatsAttrVec>()?;
|
||||
for attr in vec.attrs.into_iter() {
|
||||
match attr {
|
||||
ScxStatsAttr::All => sattrs.all = Some(true),
|
||||
ScxStatsAttr::Desc(v) => sattrs.desc = Some(v),
|
||||
ScxStatsAttr::OMPrefix(v) => sattrs.om_prefix = Some(v),
|
||||
}
|
||||
@ -245,6 +255,9 @@ impl ScxStatsField {
|
||||
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||
pub struct ScxStatsMeta {
|
||||
pub name: String,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub all: Option<bool>,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub desc: Option<String>,
|
||||
pub fields: Vec<ScxStatsField>,
|
||||
}
|
||||
@ -273,6 +286,7 @@ impl Parse for ScxStatsMetaAux {
|
||||
Ok(Self {
|
||||
meta: ScxStatsMeta {
|
||||
name: item_struct.ident.to_string(),
|
||||
all: attrs.all,
|
||||
desc: attrs.desc,
|
||||
fields,
|
||||
},
|
||||
|
@ -303,6 +303,7 @@ impl LayerStats {
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Default, Serialize, Deserialize, Stats)]
|
||||
#[stat(all)]
|
||||
pub struct SysStats {
|
||||
#[stat(desc = "update interval")]
|
||||
pub intv: f64,
|
||||
|
Loading…
Reference in New Issue
Block a user