Skip to content

Commit

Permalink
feat(meta): Add record_meta field to counters consumer (#5680)
Browse files Browse the repository at this point in the history
This field will be used by the materialized view to determine whether the row
should be processed into the meta table.
  • Loading branch information
evanh authored Mar 25, 2024
1 parent f5f9208 commit 050c343
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
10 changes: 10 additions & 0 deletions rust_snuba/src/processors/generic_metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,8 @@ struct CountersRawRow {
common_fields: CommonMetricFields,
#[serde(default)]
count_value: f64,
#[serde(skip_serializing_if = "Option::is_none")]
record_meta: Option<u8>,
}

/// Parse is the trait which should be implemented for all metric types.
Expand Down Expand Up @@ -210,6 +212,12 @@ impl Parse for CountersRawRow {
}
let retention_days = enforce_retention(Some(from.retention_days), &config.env_config);

let record_meta = match from.use_case_id.as_str() {
"escalating_issues" => Some(0),
"metric_stats" => Some(0),
_ => Some(1),
};

let common_fields = CommonMetricFields {
use_case_id: from.use_case_id,
org_id: from.org_id,
Expand All @@ -230,6 +238,7 @@ impl Parse for CountersRawRow {
Ok(Some(Self {
common_fields,
count_value,
record_meta,
}))
}
}
Expand Down Expand Up @@ -726,6 +735,7 @@ mod tests {
day_retention_days: None,
},
count_value: 1.0,
record_meta: Some(1),
};
assert_eq!(
result.unwrap(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ expression: snapshot_payload
"min_retention_days": 90,
"org_id": 1,
"project_id": 3,
"record_meta": 1,
"retention_days": 90,
"tags.indexed_value": [
0,
Expand Down

0 comments on commit 050c343

Please sign in to comment.