Skip to content

Commit adc372a

Browse files
api-clients-generation-pipeline[bot]ci.datadog-api-spec
andauthored
Add sample_attribute to log exclusion filter (#1399)
Co-authored-by: ci.datadog-api-spec <packages@datadoghq.com>
1 parent 3398106 commit adc372a

File tree

6 files changed

+43
-12
lines changed

6 files changed

+43
-12
lines changed

.generator/schemas/v1/openapi.yaml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5931,6 +5931,12 @@ components:
59315931
Scope down exclusion filter to only a subset of logs with a log query.
59325932
example: "*"
59335933
type: string
5934+
sample_attribute:
5935+
description: |-
5936+
Sample attribute to use for the sampling of logs going through this exclusion filter.
5937+
When set, only the logs with the specified attribute are sampled.
5938+
example: "@ci.job_id"
5939+
type: string
59345940
sample_rate:
59355941
description: |-
59365942
Sample rate to apply to logs going through this exclusion filter,
@@ -29896,7 +29902,7 @@ paths:
2989629902
Update an index as identified by its name.
2989729903
Returns the Index object passed in the request body when the request is successful.
2989829904

29899-
Using the `PUT` method updates your indexs configuration by **replacing**
29905+
Using the `PUT` method updates your index's configuration by **replacing**
2990029906
your current configuration with the new one sent to your Datadog organization.
2990129907
operationId: UpdateLogsIndex
2990229908
parameters:

examples/v1_logs-indexes_CreateLogsIndex.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,11 @@ async fn main() {
2020
.reset_utc_offset("+02:00".to_string()),
2121
)
2222
.daily_limit_warning_threshold_percentage(70.0 as f64)
23-
.exclusion_filters(vec![LogsExclusion::new("payment".to_string())
24-
.filter(LogsExclusionFilter::new(1.0).query("*".to_string()))])
23+
.exclusion_filters(vec![LogsExclusion::new("payment".to_string()).filter(
24+
LogsExclusionFilter::new(1.0)
25+
.query("*".to_string())
26+
.sample_attribute("@ci.job_id".to_string()),
27+
)])
2528
.num_flex_logs_retention_days(360)
2629
.num_retention_days(15)
2730
.tags(vec![

examples/v1_logs-indexes_UpdateLogsIndex.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,11 @@ async fn main() {
1818
)
1919
.daily_limit_warning_threshold_percentage(70.0 as f64)
2020
.disable_daily_limit(false)
21-
.exclusion_filters(vec![LogsExclusion::new("payment".to_string())
22-
.filter(LogsExclusionFilter::new(1.0).query("*".to_string()))])
21+
.exclusion_filters(vec![LogsExclusion::new("payment".to_string()).filter(
22+
LogsExclusionFilter::new(1.0)
23+
.query("*".to_string())
24+
.sample_attribute("@ci.job_id".to_string()),
25+
)])
2326
.num_flex_logs_retention_days(360)
2427
.num_retention_days(15)
2528
.tags(vec![

src/datadogV1/api/api_logs_indexes.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -691,7 +691,7 @@ impl LogsIndexesAPI {
691691
/// Update an index as identified by its name.
692692
/// Returns the Index object passed in the request body when the request is successful.
693693
///
694-
/// Using the `PUT` method updates your indexs configuration by **replacing**
694+
/// Using the `PUT` method updates your index's configuration by **replacing**
695695
/// your current configuration with the new one sent to your Datadog organization.
696696
pub async fn update_logs_index(
697697
&self,
@@ -715,7 +715,7 @@ impl LogsIndexesAPI {
715715
/// Update an index as identified by its name.
716716
/// Returns the Index object passed in the request body when the request is successful.
717717
///
718-
/// Using the `PUT` method updates your indexs configuration by **replacing**
718+
/// Using the `PUT` method updates your index's configuration by **replacing**
719719
/// your current configuration with the new one sent to your Datadog organization.
720720
pub async fn update_logs_index_with_http_info(
721721
&self,

src/datadogV1/model/model_logs_exclusion_filter.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ pub struct LogsExclusionFilter {
1515
/// Scope down exclusion filter to only a subset of logs with a log query.
1616
#[serde(rename = "query")]
1717
pub query: Option<String>,
18+
/// Sample attribute to use for the sampling of logs going through this exclusion filter.
19+
/// When set, only the logs with the specified attribute are sampled.
20+
#[serde(rename = "sample_attribute")]
21+
pub sample_attribute: Option<String>,
1822
/// Sample rate to apply to logs going through this exclusion filter,
1923
/// a value of 1.0 excludes all logs matching the query.
2024
#[serde(rename = "sample_rate")]
@@ -30,6 +34,7 @@ impl LogsExclusionFilter {
3034
pub fn new(sample_rate: f64) -> LogsExclusionFilter {
3135
LogsExclusionFilter {
3236
query: None,
37+
sample_attribute: None,
3338
sample_rate,
3439
additional_properties: std::collections::BTreeMap::new(),
3540
_unparsed: false,
@@ -41,6 +46,11 @@ impl LogsExclusionFilter {
4146
self
4247
}
4348

49+
pub fn sample_attribute(mut self, value: String) -> Self {
50+
self.sample_attribute = Some(value);
51+
self
52+
}
53+
4454
pub fn additional_properties(
4555
mut self,
4656
value: std::collections::BTreeMap<String, serde_json::Value>,
@@ -68,6 +78,7 @@ impl<'de> Deserialize<'de> for LogsExclusionFilter {
6878
M: MapAccess<'a>,
6979
{
7080
let mut query: Option<String> = None;
81+
let mut sample_attribute: Option<String> = None;
7182
let mut sample_rate: Option<f64> = None;
7283
let mut additional_properties: std::collections::BTreeMap<
7384
String,
@@ -83,6 +94,13 @@ impl<'de> Deserialize<'de> for LogsExclusionFilter {
8394
}
8495
query = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
8596
}
97+
"sample_attribute" => {
98+
if v.is_null() {
99+
continue;
100+
}
101+
sample_attribute =
102+
Some(serde_json::from_value(v).map_err(M::Error::custom)?);
103+
}
86104
"sample_rate" => {
87105
sample_rate =
88106
Some(serde_json::from_value(v).map_err(M::Error::custom)?);
@@ -99,6 +117,7 @@ impl<'de> Deserialize<'de> for LogsExclusionFilter {
99117

100118
let content = LogsExclusionFilter {
101119
query,
120+
sample_attribute,
102121
sample_rate,
103122
additional_properties,
104123
_unparsed,

tests/scenarios/features/v1/logs_indexes.feature

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,21 @@ Feature: Logs Indexes
1111
@generated @skip @team:DataDog/logs-backend @team:DataDog/logs-core
1212
Scenario: Create an index returns "Invalid Parameter Error" response
1313
Given new "CreateLogsIndex" request
14-
And body with value {"daily_limit": 300000000, "daily_limit_reset": {"reset_time": "14:00", "reset_utc_offset": "+02:00"}, "daily_limit_warning_threshold_percentage": 70, "exclusion_filters": [{"filter": {"query": "*", "sample_rate": 1.0}, "name": "payment"}], "filter": {"query": "source:python"}, "name": "main", "num_flex_logs_retention_days": 360, "num_retention_days": 15, "tags": ["team:backend", "env:production"]}
14+
And body with value {"daily_limit": 300000000, "daily_limit_reset": {"reset_time": "14:00", "reset_utc_offset": "+02:00"}, "daily_limit_warning_threshold_percentage": 70, "exclusion_filters": [{"filter": {"query": "*", "sample_attribute": "@ci.job_id", "sample_rate": 1.0}, "name": "payment"}], "filter": {"query": "source:python"}, "name": "main", "num_flex_logs_retention_days": 360, "num_retention_days": 15, "tags": ["team:backend", "env:production"]}
1515
When the request is sent
1616
Then the response status is 400 Invalid Parameter Error
1717

1818
@generated @skip @team:DataDog/logs-backend @team:DataDog/logs-core
1919
Scenario: Create an index returns "OK" response
2020
Given new "CreateLogsIndex" request
21-
And body with value {"daily_limit": 300000000, "daily_limit_reset": {"reset_time": "14:00", "reset_utc_offset": "+02:00"}, "daily_limit_warning_threshold_percentage": 70, "exclusion_filters": [{"filter": {"query": "*", "sample_rate": 1.0}, "name": "payment"}], "filter": {"query": "source:python"}, "name": "main", "num_flex_logs_retention_days": 360, "num_retention_days": 15, "tags": ["team:backend", "env:production"]}
21+
And body with value {"daily_limit": 300000000, "daily_limit_reset": {"reset_time": "14:00", "reset_utc_offset": "+02:00"}, "daily_limit_warning_threshold_percentage": 70, "exclusion_filters": [{"filter": {"query": "*", "sample_attribute": "@ci.job_id", "sample_rate": 1.0}, "name": "payment"}], "filter": {"query": "source:python"}, "name": "main", "num_flex_logs_retention_days": 360, "num_retention_days": 15, "tags": ["team:backend", "env:production"]}
2222
When the request is sent
2323
Then the response status is 200 OK
2424

2525
@generated @skip @team:DataDog/logs-backend @team:DataDog/logs-core
2626
Scenario: Create an index returns "Unprocessable Entity" response
2727
Given new "CreateLogsIndex" request
28-
And body with value {"daily_limit": 300000000, "daily_limit_reset": {"reset_time": "14:00", "reset_utc_offset": "+02:00"}, "daily_limit_warning_threshold_percentage": 70, "exclusion_filters": [{"filter": {"query": "*", "sample_rate": 1.0}, "name": "payment"}], "filter": {"query": "source:python"}, "name": "main", "num_flex_logs_retention_days": 360, "num_retention_days": 15, "tags": ["team:backend", "env:production"]}
28+
And body with value {"daily_limit": 300000000, "daily_limit_reset": {"reset_time": "14:00", "reset_utc_offset": "+02:00"}, "daily_limit_warning_threshold_percentage": 70, "exclusion_filters": [{"filter": {"query": "*", "sample_attribute": "@ci.job_id", "sample_rate": 1.0}, "name": "payment"}], "filter": {"query": "source:python"}, "name": "main", "num_flex_logs_retention_days": 360, "num_retention_days": 15, "tags": ["team:backend", "env:production"]}
2929
When the request is sent
3030
Then the response status is 422 Unprocessable Entity
3131

@@ -73,15 +73,15 @@ Feature: Logs Indexes
7373
Scenario: Update an index returns "Invalid Parameter Error" response
7474
Given new "UpdateLogsIndex" request
7575
And request contains "name" parameter from "REPLACE.ME"
76-
And body with value {"daily_limit": 300000000, "daily_limit_reset": {"reset_time": "14:00", "reset_utc_offset": "+02:00"}, "daily_limit_warning_threshold_percentage": 70, "disable_daily_limit": false, "exclusion_filters": [{"filter": {"query": "*", "sample_rate": 1.0}, "name": "payment"}], "filter": {"query": "source:python"}, "num_flex_logs_retention_days": 360, "num_retention_days": 15, "tags": ["team:backend", "env:production"]}
76+
And body with value {"daily_limit": 300000000, "daily_limit_reset": {"reset_time": "14:00", "reset_utc_offset": "+02:00"}, "daily_limit_warning_threshold_percentage": 70, "disable_daily_limit": false, "exclusion_filters": [{"filter": {"query": "*", "sample_attribute": "@ci.job_id", "sample_rate": 1.0}, "name": "payment"}], "filter": {"query": "source:python"}, "num_flex_logs_retention_days": 360, "num_retention_days": 15, "tags": ["team:backend", "env:production"]}
7777
When the request is sent
7878
Then the response status is 400 Invalid Parameter Error
7979

8080
@generated @skip @team:DataDog/logs-backend @team:DataDog/logs-core
8181
Scenario: Update an index returns "OK" response
8282
Given new "UpdateLogsIndex" request
8383
And request contains "name" parameter from "REPLACE.ME"
84-
And body with value {"daily_limit": 300000000, "daily_limit_reset": {"reset_time": "14:00", "reset_utc_offset": "+02:00"}, "daily_limit_warning_threshold_percentage": 70, "disable_daily_limit": false, "exclusion_filters": [{"filter": {"query": "*", "sample_rate": 1.0}, "name": "payment"}], "filter": {"query": "source:python"}, "num_flex_logs_retention_days": 360, "num_retention_days": 15, "tags": ["team:backend", "env:production"]}
84+
And body with value {"daily_limit": 300000000, "daily_limit_reset": {"reset_time": "14:00", "reset_utc_offset": "+02:00"}, "daily_limit_warning_threshold_percentage": 70, "disable_daily_limit": false, "exclusion_filters": [{"filter": {"query": "*", "sample_attribute": "@ci.job_id", "sample_rate": 1.0}, "name": "payment"}], "filter": {"query": "source:python"}, "num_flex_logs_retention_days": 360, "num_retention_days": 15, "tags": ["team:backend", "env:production"]}
8585
When the request is sent
8686
Then the response status is 200 OK
8787

0 commit comments

Comments
 (0)