Skip to content

Commit bca52c3

Browse files
chore(humio_metrics sink): add test for duplicate metrics (#15620)
* Add test for duplicate metrics Signed-off-by: Stephen Wakely <[email protected]> * Include metric_tag_values option in test Signed-off-by: Stephen Wakely <[email protected]> * Rename test to multi_value_tags Signed-off-by: Stephen Wakely <[email protected]> Signed-off-by: Stephen Wakely <[email protected]>
1 parent b56193e commit bca52c3

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

src/sinks/humio/metrics.rs

+44
Original file line numberDiff line numberDiff line change
@@ -293,4 +293,48 @@ mod tests {
293293
output[1].1
294294
);
295295
}
296+
297+
#[tokio::test]
298+
async fn multi_value_tags() {
299+
let (mut config, cx) = load_sink::<HumioMetricsConfig>(indoc! {r#"
300+
token = "atoken"
301+
batch.max_events = 1
302+
metric_tag_values = "full"
303+
"#})
304+
.unwrap();
305+
306+
let addr = test_util::next_addr();
307+
// Swap out the endpoint so we can force send it
308+
// to our local server
309+
let endpoint = format!("http://{}", addr);
310+
config.endpoint = Some(endpoint.clone());
311+
312+
let (sink, _) = config.build(cx).await.unwrap();
313+
314+
let (rx, _trigger, server) = build_test_server(addr);
315+
tokio::spawn(server);
316+
317+
// Make our test metrics.
318+
let metrics = vec![Event::from(
319+
Metric::new(
320+
"metric1",
321+
MetricKind::Incremental,
322+
MetricValue::Counter { value: 42.0 },
323+
)
324+
.with_tags(Some(metric_tags!(
325+
"code" => "200",
326+
"code" => "success"
327+
)))
328+
.with_timestamp(Some(Utc.ymd(2020, 8, 18).and_hms(21, 0, 1))),
329+
)];
330+
331+
let len = metrics.len();
332+
run_and_assert_sink_compliance(sink, stream::iter(metrics), &HTTP_SINK_TAGS).await;
333+
334+
let output = rx.take(len).collect::<Vec<_>>().await;
335+
assert_eq!(
336+
r#"{"event":{"counter":{"value":42.0},"kind":"incremental","name":"metric1","tags":{"code":["200","success"]}},"fields":{},"time":1597784401.0}"#,
337+
output[0].1
338+
);
339+
}
296340
}

0 commit comments

Comments
 (0)