Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(metrics): Add units in built-in measurements [INGEST-1056] #1229

Merged
merged 5 commits into from
Apr 19, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add test
  • Loading branch information
iker-barriocanal committed Apr 14, 2022
commit 9183008a942db5b7d0fe46afc617afad015e2ed7
62 changes: 62 additions & 0 deletions relay-server/src/metrics_extraction/transactions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,68 @@ mod tests {
}
}

#[test]
fn test_metric_measurement_units() {
let json = r#"
{
"type": "transaction",
"timestamp": "2021-04-26T08:00:00+0100",
"start_timestamp": "2021-04-26T07:59:01+0100",
"measurements": {
"fcp": {"value": 1.1},
"stall_count": {"value": 3.3},
"foo": {"value": 8.8}
}
}
"#;

let config: TransactionMetricsConfig = serde_json::from_str(
r#"
{
"extractMetrics": [
"d:transactions/measurements.fcp@millisecond",
"d:transactions/measurements.stall_count@none",
"d:transactions/measurements.foo@none"
]
}
"#,
)
.unwrap();

let event = Annotated::from_json(json).unwrap();

let mut metrics = vec![];
extract_transaction_metrics(&config, None, &[], event.value().unwrap(), &mut metrics);

assert_eq!(metrics.len(), 3, "{:?}", metrics);

assert_eq!(
metrics[0].name, "d:transactions/measurements.fcp@millisecond",
"{:?}",
metrics[0]
);
assert_eq!(
metrics[0].unit,
MetricUnit::Duration(DurationUnit::MilliSecond),
"{:?}",
metrics[0]
);

assert_eq!(
metrics[1].name, "d:transactions/measurements.foo@none",
"{:?}",
metrics[1]
);
assert_eq!(metrics[1].unit, MetricUnit::None, "{:?}", metrics[1]);

assert_eq!(
metrics[2].name, "d:transactions/measurements.stall_count@none",
"{:?}",
metrics[2]
);
assert_eq!(metrics[2].unit, MetricUnit::None, "{:?}", metrics[2]);
}

#[test]
fn test_transaction_duration() {
let json = r#"
Expand Down