Skip to content

Commit

Permalink
fix(sample transform): component feature check fix (#21677)
Browse files Browse the repository at this point in the history
  • Loading branch information
pront authored Nov 1, 2024
1 parent 7985d45 commit 710f224
Show file tree
Hide file tree
Showing 6 changed files with 325 additions and 340 deletions.
20 changes: 4 additions & 16 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src/transforms/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use std::collections::HashSet;

pub mod dedupe;
pub mod reduce;
#[cfg(feature = "transforms-impl-sample")]
pub mod sample;

#[cfg(feature = "transforms-aggregate")]
Expand Down
33 changes: 1 addition & 32 deletions src/transforms/sample/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,41 +131,10 @@ pub fn default_sample_rate_key() -> OptionalValuePath {

#[cfg(test)]
mod tests {
use super::*;
use crate::{
event::LogEvent, test_util::components::assert_transform_compliance,
transforms::test::create_topology,
};
use tokio::sync::mpsc;
use tokio_stream::wrappers::ReceiverStream;
use crate::transforms::sample::config::SampleConfig;

#[test]
fn generate_config() {
crate::test_util::test_generate_config::<SampleConfig>();
}

#[tokio::test]
async fn emits_internal_events() {
assert_transform_compliance(async move {
let config = SampleConfig {
rate: 1,
key_field: None,
group_by: None,
exclude: None,
sample_rate_key: default_sample_rate_key(),
};
let (tx, rx) = mpsc::channel(1);
let (topology, mut out) = create_topology(ReceiverStream::new(rx), config).await;

let log = LogEvent::from("hello world");
tx.send(log.into()).await.unwrap();

_ = out.recv().await;

drop(tx);
topology.stop().await;
assert_eq!(out.recv().await, None);
})
.await
}
}
4 changes: 3 additions & 1 deletion src/transforms/sample/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#[cfg(feature = "transforms-sample")]
pub mod config;

#[cfg(feature = "transforms-impl-sample")]
pub mod transform;

#[cfg(all(test, feature = "transforms-sample"))]
mod tests;
Loading

0 comments on commit 710f224

Please sign in to comment.