Skip to content

Commit 657bae3

Browse files
committed
Add unit test for metric classification
1 parent 4c1ba82 commit 657bae3

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

crates/dogstatsd/src/origin.rs

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,32 @@ mod tests {
330330
}
331331

332332
#[test]
333-
fn test_find_metric_origin_azure_functions() {
333+
fn test_find_metric_origin_azure_functions_enhanced() {
334+
let tags = SortedTags::parse("origin:azurefunction").unwrap();
335+
let metric = Metric {
336+
id: 0,
337+
name: "azure.functions.enhanced.cpu.usage".into(),
338+
value: MetricValue::Gauge(1.0),
339+
tags: Some(tags.clone()),
340+
timestamp: 0,
341+
};
342+
let origin = metric.find_origin(tags).unwrap();
343+
assert_eq!(
344+
origin.origin_product as u32,
345+
OriginProduct::Serverless as u32
346+
);
347+
assert_eq!(
348+
origin.origin_category as u32,
349+
OriginCategory::AzureFunctionsMetrics as u32
350+
);
351+
assert_eq!(
352+
origin.origin_service as u32,
353+
OriginService::ServerlessEnhanced as u32
354+
);
355+
}
356+
357+
#[test]
358+
fn test_find_metric_origin_azure_functions_custom() {
334359
let tags = SortedTags::parse("origin:azurefunction").unwrap();
335360
let metric = Metric {
336361
id: 0,

0 commit comments

Comments
 (0)