Skip to content

Commit 97274ea

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

6 files changed

Lines changed: 27 additions & 8 deletions

File tree

.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.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
DatadogAPIClient::V1::LogsExclusion.new({
1515
filter: DatadogAPIClient::V1::LogsExclusionFilter.new({
1616
query: "*",
17+
sample_attribute: "@ci.job_id",
1718
sample_rate: 1.0,
1819
}),
1920
name: "payment",

examples/v1/logs-indexes/UpdateLogsIndex.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
DatadogAPIClient::V1::LogsExclusion.new({
1616
filter: DatadogAPIClient::V1::LogsExclusionFilter.new({
1717
query: "*",
18+
sample_attribute: "@ci.job_id",
1819
sample_rate: 1.0,
1920
}),
2021
name: "payment",

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

lib/datadog_api_client/v1/api/logs_indexes_api.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ def update_logs_index(name, body, opts = {})
355355
# Update an index as identified by its name.
356356
# Returns the Index object passed in the request body when the request is successful.
357357
#
358-
# Using the `PUT` method updates your indexs configuration by **replacing**
358+
# Using the `PUT` method updates your index's configuration by **replacing**
359359
# your current configuration with the new one sent to your Datadog organization.
360360
#
361361
# @param name [String] Name of the log index.

lib/datadog_api_client/v1/models/logs_exclusion_filter.rb

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ class LogsExclusionFilter
2525
# Scope down exclusion filter to only a subset of logs with a log query.
2626
attr_accessor :query
2727

28+
# Sample attribute to use for the sampling of logs going through this exclusion filter.
29+
# When set, only the logs with the specified attribute are sampled.
30+
attr_accessor :sample_attribute
31+
2832
# Sample rate to apply to logs going through this exclusion filter,
2933
# a value of 1.0 excludes all logs matching the query.
3034
attr_reader :sample_rate
@@ -36,6 +40,7 @@ class LogsExclusionFilter
3640
def self.attribute_map
3741
{
3842
:'query' => :'query',
43+
:'sample_attribute' => :'sample_attribute',
3944
:'sample_rate' => :'sample_rate'
4045
}
4146
end
@@ -45,6 +50,7 @@ def self.attribute_map
4550
def self.openapi_types
4651
{
4752
:'query' => :'String',
53+
:'sample_attribute' => :'String',
4854
:'sample_rate' => :'Float'
4955
}
5056
end
@@ -71,6 +77,10 @@ def initialize(attributes = {})
7177
self.query = attributes[:'query']
7278
end
7379

80+
if attributes.key?(:'sample_attribute')
81+
self.sample_attribute = attributes[:'sample_attribute']
82+
end
83+
7484
if attributes.key?(:'sample_rate')
7585
self.sample_rate = attributes[:'sample_rate']
7686
end
@@ -121,6 +131,7 @@ def ==(o)
121131
return true if self.equal?(o)
122132
self.class == o.class &&
123133
query == o.query &&
134+
sample_attribute == o.sample_attribute &&
124135
sample_rate == o.sample_rate &&
125136
additional_properties == o.additional_properties
126137
end
@@ -129,7 +140,7 @@ def ==(o)
129140
# @return [Integer] Hash code
130141
# @!visibility private
131142
def hash
132-
[query, sample_rate, additional_properties].hash
143+
[query, sample_attribute, sample_rate, additional_properties].hash
133144
end
134145
end
135146
end

0 commit comments

Comments
 (0)