Skip to content

add group_by to sample processor #820

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
4 changes: 2 additions & 2 deletions .generated-info
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"spec_repo_commit": "b75095c",
"generated": "2025-07-31 10:50:58.895"
"spec_repo_commit": "b14c9da",
"generated": "2025-07-31 15:36:46.970"
}
10 changes: 10 additions & 0 deletions .generator/schemas/v2/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27480,6 +27480,16 @@ components:
description: The `sample` processor allows probabilistic sampling of logs at
a fixed rate.
properties:
group_by:
description: Optional list of fields to group events by. Each group will
be sampled independently
example:
- service
- host
items:
type: string
minItems: 1
type: array
id:
description: The unique identifier for this component. Used to reference
this component in other parts of the pipeline (for example, as the `input`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ use std::fmt::{self, Formatter};
#[skip_serializing_none]
#[derive(Clone, Debug, PartialEq, Serialize)]
pub struct ObservabilityPipelineSampleProcessor {
/// Optional list of fields to group events by. Each group will be sampled independently
#[serde(rename = "group_by")]
pub group_by: Option<Vec<String>>,
/// The unique identifier for this component. Used to reference this component in other parts of the pipeline (for example, as the `input` to downstream components).
#[serde(rename = "id")]
pub id: String,
Expand Down Expand Up @@ -44,6 +47,7 @@ impl ObservabilityPipelineSampleProcessor {
type_: crate::datadogV2::model::ObservabilityPipelineSampleProcessorType,
) -> ObservabilityPipelineSampleProcessor {
ObservabilityPipelineSampleProcessor {
group_by: None,
id,
include,
inputs,
Expand All @@ -55,6 +59,11 @@ impl ObservabilityPipelineSampleProcessor {
}
}

pub fn group_by(mut self, value: Vec<String>) -> Self {
self.group_by = Some(value);
self
}

pub fn percentage(mut self, value: f64) -> Self {
self.percentage = Some(value);
self
Expand Down Expand Up @@ -91,6 +100,7 @@ impl<'de> Deserialize<'de> for ObservabilityPipelineSampleProcessor {
where
M: MapAccess<'a>,
{
let mut group_by: Option<Vec<String>> = None;
let mut id: Option<String> = None;
let mut include: Option<String> = None;
let mut inputs: Option<Vec<String>> = None;
Expand All @@ -107,6 +117,12 @@ impl<'de> Deserialize<'de> for ObservabilityPipelineSampleProcessor {

while let Some((k, v)) = map.next_entry::<String, serde_json::Value>()? {
match k.as_str() {
"group_by" => {
if v.is_null() {
continue;
}
group_by = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
}
"id" => {
id = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
}
Expand Down Expand Up @@ -152,6 +168,7 @@ impl<'de> Deserialize<'de> for ObservabilityPipelineSampleProcessor {
let type_ = type_.ok_or_else(|| M::Error::missing_field("type_"))?;

let content = ObservabilityPipelineSampleProcessor {
group_by,
id,
include,
inputs,
Expand Down
Loading