Skip to content

Commit 8be962a

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

File tree

6 files changed

+52
-10
lines changed

6 files changed

+52
-10
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.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,11 @@ public static void main(String[] args) {
2424
.exclusionFilters(
2525
Collections.singletonList(
2626
new LogsExclusion()
27-
.filter(new LogsExclusionFilter().query("*").sampleRate(1.0))
27+
.filter(
28+
new LogsExclusionFilter()
29+
.query("*")
30+
.sampleAttribute("@ci.job_id")
31+
.sampleRate(1.0))
2832
.name("payment")))
2933
.filter(new LogsFilter().query("source:python"))
3034
.name("main")

examples/v1/logs-indexes/UpdateLogsIndex.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,11 @@ public static void main(String[] args) {
2626
.exclusionFilters(
2727
Collections.singletonList(
2828
new LogsExclusion()
29-
.filter(new LogsExclusionFilter().query("*").sampleRate(1.0))
29+
.filter(
30+
new LogsExclusionFilter()
31+
.query("*")
32+
.sampleAttribute("@ci.job_id")
33+
.sampleRate(1.0))
3034
.name("payment")))
3135
.filter(new LogsFilter().query("source:python"))
3236
.numFlexLogsRetentionDays(360L)

src/main/java/com/datadog/api/client/v1/api/LogsIndexesApi.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -698,7 +698,7 @@ public CompletableFuture<LogsIndex> updateLogsIndexAsync(
698698
* Update an index as identified by its name. Returns the Index object passed in the request body
699699
* when the request is successful.
700700
*
701-
* <p>Using the <code>PUT</code> method updates your indexs configuration by
701+
* <p>Using the <code>PUT</code> method updates your index's configuration by
702702
* <strong>replacing</strong> your current configuration with the new one sent to your Datadog
703703
* organization.
704704
*

src/main/java/com/datadog/api/client/v1/model/LogsExclusionFilter.java

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
/** Exclusion filter is defined by a query, a sampling rule, and a active/inactive toggle. */
2121
@JsonPropertyOrder({
2222
LogsExclusionFilter.JSON_PROPERTY_QUERY,
23+
LogsExclusionFilter.JSON_PROPERTY_SAMPLE_ATTRIBUTE,
2324
LogsExclusionFilter.JSON_PROPERTY_SAMPLE_RATE
2425
})
2526
@jakarta.annotation.Generated(
@@ -29,6 +30,9 @@ public class LogsExclusionFilter {
2930
public static final String JSON_PROPERTY_QUERY = "query";
3031
private String query;
3132

33+
public static final String JSON_PROPERTY_SAMPLE_ATTRIBUTE = "sample_attribute";
34+
private String sampleAttribute;
35+
3236
public static final String JSON_PROPERTY_SAMPLE_RATE = "sample_rate";
3337
private Double sampleRate;
3438

@@ -62,6 +66,28 @@ public void setQuery(String query) {
6266
this.query = query;
6367
}
6468

69+
public LogsExclusionFilter sampleAttribute(String sampleAttribute) {
70+
this.sampleAttribute = sampleAttribute;
71+
return this;
72+
}
73+
74+
/**
75+
* Sample attribute to use for the sampling of logs going through this exclusion filter. When set,
76+
* only the logs with the specified attribute are sampled.
77+
*
78+
* @return sampleAttribute
79+
*/
80+
@jakarta.annotation.Nullable
81+
@JsonProperty(JSON_PROPERTY_SAMPLE_ATTRIBUTE)
82+
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
83+
public String getSampleAttribute() {
84+
return sampleAttribute;
85+
}
86+
87+
public void setSampleAttribute(String sampleAttribute) {
88+
this.sampleAttribute = sampleAttribute;
89+
}
90+
6591
public LogsExclusionFilter sampleRate(Double sampleRate) {
6692
this.sampleRate = sampleRate;
6793
return this;
@@ -140,20 +166,22 @@ public boolean equals(Object o) {
140166
}
141167
LogsExclusionFilter logsExclusionFilter = (LogsExclusionFilter) o;
142168
return Objects.equals(this.query, logsExclusionFilter.query)
169+
&& Objects.equals(this.sampleAttribute, logsExclusionFilter.sampleAttribute)
143170
&& Objects.equals(this.sampleRate, logsExclusionFilter.sampleRate)
144171
&& Objects.equals(this.additionalProperties, logsExclusionFilter.additionalProperties);
145172
}
146173

147174
@Override
148175
public int hashCode() {
149-
return Objects.hash(query, sampleRate, additionalProperties);
176+
return Objects.hash(query, sampleAttribute, sampleRate, additionalProperties);
150177
}
151178

152179
@Override
153180
public String toString() {
154181
StringBuilder sb = new StringBuilder();
155182
sb.append("class LogsExclusionFilter {\n");
156183
sb.append(" query: ").append(toIndentedString(query)).append("\n");
184+
sb.append(" sampleAttribute: ").append(toIndentedString(sampleAttribute)).append("\n");
157185
sb.append(" sampleRate: ").append(toIndentedString(sampleRate)).append("\n");
158186
sb.append(" additionalProperties: ")
159187
.append(toIndentedString(additionalProperties))

src/test/resources/com/datadog/api/client/v1/api/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)