Skip to content

Commit 420b51a

Browse files
api-clients-generation-pipeline[bot]ci.datadog-api-spec
andauthored
Add support for span id remapper in logs pipelines processors (#2256)
Co-authored-by: ci.datadog-api-spec <[email protected]>
1 parent 88f0bf4 commit 420b51a

File tree

10 files changed

+310
-6
lines changed

10 files changed

+310
-6
lines changed

.apigentools-info

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
"spec_versions": {
55
"v1": {
66
"apigentools_version": "1.6.6",
7-
"regenerated": "2025-02-21 08:00:33.138734",
8-
"spec_repo_commit": "8f2d39c3"
7+
"regenerated": "2025-02-21 18:16:33.413992",
8+
"spec_repo_commit": "5de91bd6"
99
},
1010
"v2": {
1111
"apigentools_version": "1.6.6",
12-
"regenerated": "2025-02-21 08:00:33.154333",
13-
"spec_repo_commit": "8f2d39c3"
12+
"regenerated": "2025-02-21 18:16:33.429413",
13+
"spec_repo_commit": "5de91bd6"
1414
}
1515
}
1616
}

.generator/schemas/v1/openapi.yaml

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6049,6 +6049,7 @@ components:
60496049
- $ref: '#/components/schemas/LogsLookupProcessor'
60506050
- $ref: '#/components/schemas/ReferenceTableLogsLookupProcessor'
60516051
- $ref: '#/components/schemas/LogsTraceRemapper'
6052+
- $ref: '#/components/schemas/LogsSpanRemapper'
60526053
LogsQueryCompute:
60536054
description: Define computation for a log query.
60546055
properties:
@@ -6160,6 +6161,43 @@ components:
61606161
x-enum-varnames:
61616162
- TIME_ASCENDING
61626163
- TIME_DESCENDING
6164+
LogsSpanRemapper:
6165+
description: "There are two ways to define correlation between application spans
6166+
and logs:\n\n 1. Follow the documentation on [how to inject a span ID in
6167+
the application logs](https://docs.datadoghq.com/tracing/connect_logs_and_traces).\n
6168+
\ Log integrations automatically handle all remaining setup steps by default.\n\n
6169+
\ 2. Use the span remapper processor to define a log attribute as its associated
6170+
span ID."
6171+
properties:
6172+
is_enabled:
6173+
default: false
6174+
description: Whether or not the processor is enabled.
6175+
type: boolean
6176+
name:
6177+
description: Name of the processor.
6178+
type: string
6179+
sources:
6180+
default:
6181+
- dd.span_id
6182+
description: Array of source attributes.
6183+
items:
6184+
description: Attribute to extract the span ID from.
6185+
type: string
6186+
type: array
6187+
type:
6188+
$ref: '#/components/schemas/LogsSpanRemapperType'
6189+
required:
6190+
- type
6191+
type: object
6192+
LogsSpanRemapperType:
6193+
default: span-id-remapper
6194+
description: Type of logs span remapper.
6195+
enum:
6196+
- span-id-remapper
6197+
example: span-id-remapper
6198+
type: string
6199+
x-enum-varnames:
6200+
- SPAN_ID_REMAPPER
61636201
LogsStatusRemapper:
61646202
description: "Use this Processor if you want to assign some attributes as the
61656203
official status.\n\nEach incoming status value is mapped as follows.\n\n -
@@ -6275,7 +6313,7 @@ components:
62756313
- dd.trace_id
62766314
description: Array of source attributes.
62776315
items:
6278-
description: Attribute to extract the Trace ID from.
6316+
description: Attribute to extract the trace ID from.
62796317
type: string
62806318
type: array
62816319
type:
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
2025-02-20T15:44:02.905Z

cassettes/features/v1/logs_pipelines/Create-a-pipeline-with-Span-Id-Remapper-returns-OK-response.yml

Lines changed: 46 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Create a pipeline with Span Id Remapper returns "OK" response
2+
3+
require "datadog_api_client"
4+
api_instance = DatadogAPIClient::V1::LogsPipelinesAPI.new
5+
6+
body = DatadogAPIClient::V1::LogsPipeline.new({
7+
filter: DatadogAPIClient::V1::LogsFilter.new({
8+
query: "source:python",
9+
}),
10+
name: "testPipeline",
11+
processors: [
12+
DatadogAPIClient::V1::LogsSpanRemapper.new({
13+
type: DatadogAPIClient::V1::LogsSpanRemapperType::SPAN_ID_REMAPPER,
14+
is_enabled: true,
15+
name: "test_filter",
16+
sources: [
17+
"dd.span_id",
18+
],
19+
}),
20+
],
21+
tags: [],
22+
})
23+
p api_instance.create_logs_pipeline(body)

features/v1/logs_pipelines.feature

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,13 @@ Feature: Logs Pipelines
3535
When the request is sent
3636
Then the response status is 200 OK
3737

38+
@team:DataDog/event-platform-experience
39+
Scenario: Create a pipeline with Span Id Remapper returns "OK" response
40+
Given new "CreateLogsPipeline" request
41+
And body with value {"filter": {"query": "source:python"}, "name": "testPipeline", "processors": [{"type": "span-id-remapper", "is_enabled" : true, "name" : "test_filter", "sources" : [ "dd.span_id"] }], "tags": []}
42+
When the request is sent
43+
Then the response status is 200 OK
44+
3845
@generated @skip @team:DataDog/event-platform-experience
3946
Scenario: Delete a pipeline returns "Bad Request" response
4047
Given new "DeleteLogsPipeline" request

lib/datadog_api_client/inflector.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,8 @@ def overrides
269269
"v1.logs_service_remapper" => "LogsServiceRemapper",
270270
"v1.logs_service_remapper_type" => "LogsServiceRemapperType",
271271
"v1.logs_sort" => "LogsSort",
272+
"v1.logs_span_remapper" => "LogsSpanRemapper",
273+
"v1.logs_span_remapper_type" => "LogsSpanRemapperType",
272274
"v1.logs_status_remapper" => "LogsStatusRemapper",
273275
"v1.logs_status_remapper_type" => "LogsStatusRemapperType",
274276
"v1.logs_string_builder_processor" => "LogsStringBuilderProcessor",

lib/datadog_api_client/v1/models/logs_processor.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ def openapi_one_of
4141
:'LogsGeoIPParser',
4242
:'LogsLookupProcessor',
4343
:'ReferenceTableLogsLookupProcessor',
44-
:'LogsTraceRemapper'
44+
:'LogsTraceRemapper',
45+
:'LogsSpanRemapper'
4546
]
4647
end
4748
# Builds the object
Lines changed: 160 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
1+
=begin
2+
#Datadog API V1 Collection
3+
4+
#Collection of all Datadog Public endpoints.
5+
6+
The version of the OpenAPI document: 1.0
7+
8+
Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator
9+
10+
Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
11+
This product includes software developed at Datadog (https://www.datadoghq.com/).
12+
Copyright 2020-Present Datadog, Inc.
13+
14+
=end
15+
16+
require 'date'
17+
require 'time'
18+
19+
module DatadogAPIClient::V1
20+
# There are two ways to define correlation between application spans and logs:
21+
#
22+
# 1. Follow the documentation on [how to inject a span ID in the application logs](https://docs.datadoghq.com/tracing/connect_logs_and_traces).
23+
# Log integrations automatically handle all remaining setup steps by default.
24+
#
25+
# 2. Use the span remapper processor to define a log attribute as its associated span ID.
26+
class LogsSpanRemapper
27+
include BaseGenericModel
28+
29+
# Whether or not the processor is enabled.
30+
attr_accessor :is_enabled
31+
32+
# Name of the processor.
33+
attr_accessor :name
34+
35+
# Array of source attributes.
36+
attr_accessor :sources
37+
38+
# Type of logs span remapper.
39+
attr_reader :type
40+
41+
attr_accessor :additional_properties
42+
43+
# Attribute mapping from ruby-style variable name to JSON key.
44+
# @!visibility private
45+
def self.attribute_map
46+
{
47+
:'is_enabled' => :'is_enabled',
48+
:'name' => :'name',
49+
:'sources' => :'sources',
50+
:'type' => :'type'
51+
}
52+
end
53+
54+
# Attribute type mapping.
55+
# @!visibility private
56+
def self.openapi_types
57+
{
58+
:'is_enabled' => :'Boolean',
59+
:'name' => :'String',
60+
:'sources' => :'Array<String>',
61+
:'type' => :'LogsSpanRemapperType'
62+
}
63+
end
64+
65+
# Initializes the object
66+
# @param attributes [Hash] Model attributes in the form of hash
67+
# @!visibility private
68+
def initialize(attributes = {})
69+
if (!attributes.is_a?(Hash))
70+
fail ArgumentError, "The input argument (attributes) must be a hash in `DatadogAPIClient::V1::LogsSpanRemapper` initialize method"
71+
end
72+
73+
self.additional_properties = {}
74+
# check to see if the attribute exists and convert string to symbol for hash key
75+
attributes = attributes.each_with_object({}) { |(k, v), h|
76+
if (!self.class.attribute_map.key?(k.to_sym))
77+
self.additional_properties[k.to_sym] = v
78+
else
79+
h[k.to_sym] = v
80+
end
81+
}
82+
83+
if attributes.key?(:'is_enabled')
84+
self.is_enabled = attributes[:'is_enabled']
85+
end
86+
87+
if attributes.key?(:'name')
88+
self.name = attributes[:'name']
89+
end
90+
91+
if attributes.key?(:'sources')
92+
if (value = attributes[:'sources']).is_a?(Array)
93+
self.sources = value
94+
end
95+
end
96+
97+
if attributes.key?(:'type')
98+
self.type = attributes[:'type']
99+
end
100+
end
101+
102+
# Check to see if the all the properties in the model are valid
103+
# @return true if the model is valid
104+
# @!visibility private
105+
def valid?
106+
return false if @type.nil?
107+
true
108+
end
109+
110+
# Custom attribute writer method with validation
111+
# @param type [Object] Object to be assigned
112+
# @!visibility private
113+
def type=(type)
114+
if type.nil?
115+
fail ArgumentError, 'invalid value for "type", type cannot be nil.'
116+
end
117+
@type = type
118+
end
119+
120+
# Returns the object in the form of hash, with additionalProperties support.
121+
# @return [Hash] Returns the object in the form of hash
122+
# @!visibility private
123+
def to_hash
124+
hash = {}
125+
self.class.attribute_map.each_pair do |attr, param|
126+
value = self.send(attr)
127+
if value.nil?
128+
is_nullable = self.class.openapi_nullable.include?(attr)
129+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
130+
end
131+
132+
hash[param] = _to_hash(value)
133+
end
134+
self.additional_properties.each_pair do |attr, value|
135+
hash[attr] = value
136+
end
137+
hash
138+
end
139+
140+
# Checks equality by comparing each attribute.
141+
# @param o [Object] Object to be compared
142+
# @!visibility private
143+
def ==(o)
144+
return true if self.equal?(o)
145+
self.class == o.class &&
146+
is_enabled == o.is_enabled &&
147+
name == o.name &&
148+
sources == o.sources &&
149+
type == o.type &&
150+
additional_properties == o.additional_properties
151+
end
152+
153+
# Calculates hash code according to all attributes.
154+
# @return [Integer] Hash code
155+
# @!visibility private
156+
def hash
157+
[is_enabled, name, sources, type, additional_properties].hash
158+
end
159+
end
160+
end
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
=begin
2+
#Datadog API V1 Collection
3+
4+
#Collection of all Datadog Public endpoints.
5+
6+
The version of the OpenAPI document: 1.0
7+
8+
Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator
9+
10+
Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
11+
This product includes software developed at Datadog (https://www.datadoghq.com/).
12+
Copyright 2020-Present Datadog, Inc.
13+
14+
=end
15+
16+
require 'date'
17+
require 'time'
18+
19+
module DatadogAPIClient::V1
20+
# Type of logs span remapper.
21+
class LogsSpanRemapperType
22+
include BaseEnumModel
23+
24+
SPAN_ID_REMAPPER = "span-id-remapper".freeze
25+
end
26+
end

0 commit comments

Comments
 (0)