|
7 | 7 |
|
8 | 8 | use crate::pipeline::processor::PipelineProcessor; |
9 | 9 | use crate::pipeline::processor::drop::DropProcessor; |
10 | | -use crate::test::{make_metric, processor_factory_context_for_test}; |
| 10 | +use crate::protos::metric::{DownstreamId, MetricSource, MetricValue}; |
| 11 | +use crate::test::{make_metric, make_metric_ex, processor_factory_context_for_test}; |
11 | 12 | use bd_test_helpers::make_mut; |
12 | 13 | use drop::drop_processor_config::Config_source; |
13 | 14 | use drop::drop_rule::drop_condition::Condition_type; |
@@ -527,3 +528,62 @@ async fn warn_interval() { |
527 | 528 | &labels! { "rule_name" => "rule1", "mode" => "enabled" }, |
528 | 529 | ); |
529 | 530 | } |
| 531 | + |
| 532 | +#[tokio::test] |
| 533 | +async fn nan_match() { |
| 534 | + let (mut helper, context) = processor_factory_context_for_test(); |
| 535 | + let processor = Arc::new( |
| 536 | + DropProcessor::new( |
| 537 | + DropProcessorConfig { |
| 538 | + config_source: Some(Config_source::Inline(DropConfig { |
| 539 | + rules: vec![DropRule { |
| 540 | + name: "rule1".into(), |
| 541 | + mode: DropMode::ENABLED.into(), |
| 542 | + conditions: vec![DropCondition { |
| 543 | + condition_type: Some(Condition_type::ValueMatch(ValueMatch { |
| 544 | + value_match_type: Some(Value_match_type::IsNan(true)), |
| 545 | + ..Default::default() |
| 546 | + })), |
| 547 | + ..Default::default() |
| 548 | + }], |
| 549 | + ..Default::default() |
| 550 | + }], |
| 551 | + ..Default::default() |
| 552 | + })), |
| 553 | + ..Default::default() |
| 554 | + }, |
| 555 | + context, |
| 556 | + ) |
| 557 | + .await |
| 558 | + .unwrap(), |
| 559 | + ); |
| 560 | + |
| 561 | + make_mut(&mut helper.dispatcher) |
| 562 | + .expect_send() |
| 563 | + .times(1) |
| 564 | + .returning(|metrics| { |
| 565 | + assert_eq!(metrics, vec![make_metric("not_nan", &[], 100)]); |
| 566 | + }); |
| 567 | + |
| 568 | + let nan_metric = make_metric_ex( |
| 569 | + "nan_metric", |
| 570 | + &[], |
| 571 | + 0, |
| 572 | + None, |
| 573 | + None, |
| 574 | + MetricValue::Simple(f64::NAN), |
| 575 | + MetricSource::PromRemoteWrite, |
| 576 | + DownstreamId::LocalOrigin, |
| 577 | + None, |
| 578 | + ); |
| 579 | + |
| 580 | + processor |
| 581 | + .clone() |
| 582 | + .recv_samples(vec![make_metric("not_nan", &[], 100), nan_metric]) |
| 583 | + .await; |
| 584 | + helper.stats_helper.assert_counter_eq( |
| 585 | + 1, |
| 586 | + "processor:dropped", |
| 587 | + &labels! { "rule_name" => "rule1", "mode" => "enabled" }, |
| 588 | + ); |
| 589 | +} |
0 commit comments