Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion contract-tests/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ async fn status() -> impl Responder {
"service-endpoints".to_string(),
"context-type".to_string(),
"secure-mode-hash".to_string(),
"inline-context".to_string(),
"inline-context-all".to_string(),
"anonymous-redaction".to_string(),
"omit-anonymous-contexts".to_string(),
"migrations".to_string(),
Expand Down
15 changes: 12 additions & 3 deletions launchdarkly-server-sdk/src/events/dispatcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,12 @@ impl EventDispatcher {
.sampler
.sample(migration_op.sampling_ratio.unwrap_or(1))
{
self.outbox
.add_event(OutputEvent::MigrationOp(migration_op));
self.outbox.add_event(OutputEvent::MigrationOp(
migration_op.into_inline_with_anonymous_redaction(
self.events_configuration.all_attributes_private,
self.events_configuration.private_attributes.clone(),
),
));
}
}
InputEvent::FeatureRequest(fre) => {
Expand Down Expand Up @@ -266,7 +270,12 @@ impl EventDispatcher {
}

if self.sampler.sample(custom.sampling_ratio.unwrap_or(1)) {
self.outbox.add_event(OutputEvent::Custom(custom));
self.outbox.add_event(OutputEvent::Custom(
custom.into_inline_with_anonymous_redaction(
self.events_configuration.all_attributes_private,
self.events_configuration.private_attributes.clone(),
),
));
}
}
}
Expand Down
32 changes: 31 additions & 1 deletion launchdarkly-server-sdk/src/events/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,22 @@ pub struct MigrationOpEvent {
pub(crate) latency: HashMap<Origin, Duration>,
}

impl MigrationOpEvent {
pub(crate) fn into_inline_with_anonymous_redaction(
self,
all_attribute_private: bool,
global_private_attributes: HashSet<Reference>,
) -> Self {
Self {
base: self.base.into_inline_with_anonymous_redaction(
all_attribute_private,
global_private_attributes,
),
..self
}
}
}

impl Serialize for MigrationOpEvent {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
Expand All @@ -120,7 +136,7 @@ impl Serialize for MigrationOpEvent {
let mut state = serializer.serialize_struct("MigrationOpEvent", 10)?;
state.serialize_field("kind", "migration_op")?;
state.serialize_field("creationDate", &self.base.creation_date)?;
state.serialize_field("contextKeys", &self.base.context.context_keys())?;
state.serialize_field("context", &self.base.context)?;
state.serialize_field("operation", &self.operation)?;

if !is_default_ratio(&self.sampling_ratio) {
Expand Down Expand Up @@ -369,6 +385,20 @@ pub struct CustomEvent {
}

impl CustomEvent {
pub(crate) fn into_inline_with_anonymous_redaction(
self,
all_attribute_private: bool,
global_private_attributes: HashSet<Reference>,
) -> Self {
Self {
base: self.base.into_inline_with_anonymous_redaction(
all_attribute_private,
global_private_attributes,
),
..self
}
}

pub fn to_index_event(
&self,
all_attribute_private: bool,
Expand Down