Skip to content

Commit 357f56e

Browse files
author
ci.datadog-api-spec
committed
Regenerate client from commit 3d369787 of spec repo
1 parent 83170df commit 357f56e

10 files changed

+362
-4
lines changed

.apigentools-info

+4-4
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-20 13:35:02.579691",
8-
"spec_repo_commit": "c64543d0"
7+
"regenerated": "2025-02-20 17:54:02.168895",
8+
"spec_repo_commit": "3d369787"
99
},
1010
"v2": {
1111
"apigentools_version": "1.6.6",
12-
"regenerated": "2025-02-20 13:35:02.595038",
13-
"spec_repo_commit": "c64543d0"
12+
"regenerated": "2025-02-20 17:54:02.188615",
13+
"spec_repo_commit": "3d369787"
1414
}
1515
}
1616
}

.generator/schemas/v1/openapi.yaml

+38
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 -
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// Create a pipeline with Span Id Remapper returns "OK" response
2+
use datadog_api_client::datadog;
3+
use datadog_api_client::datadogV1::api_logs_pipelines::LogsPipelinesAPI;
4+
use datadog_api_client::datadogV1::model::LogsFilter;
5+
use datadog_api_client::datadogV1::model::LogsPipeline;
6+
use datadog_api_client::datadogV1::model::LogsProcessor;
7+
use datadog_api_client::datadogV1::model::LogsSpanRemapper;
8+
use datadog_api_client::datadogV1::model::LogsSpanRemapperType;
9+
10+
#[tokio::main]
11+
async fn main() {
12+
let body = LogsPipeline::new("testPipeline".to_string())
13+
.filter(LogsFilter::new().query("source:python".to_string()))
14+
.processors(vec![LogsProcessor::LogsSpanRemapper(Box::new(
15+
LogsSpanRemapper::new(LogsSpanRemapperType::SPAN_ID_REMAPPER)
16+
.is_enabled(true)
17+
.name("test_filter".to_string())
18+
.sources(vec!["dd.span_id".to_string()]),
19+
))])
20+
.tags(vec![]);
21+
let configuration = datadog::Configuration::new();
22+
let api = LogsPipelinesAPI::with_config(configuration);
23+
let resp = api.create_logs_pipeline(body).await;
24+
if let Ok(value) = resp {
25+
println!("{:#?}", value);
26+
} else {
27+
println!("{:#?}", resp.unwrap_err());
28+
}
29+
}

src/datadogV1/model/mod.rs

+4
Original file line numberDiff line numberDiff line change
@@ -894,6 +894,10 @@ pub mod model_logs_trace_remapper;
894894
pub use self::model_logs_trace_remapper::LogsTraceRemapper;
895895
pub mod model_logs_trace_remapper_type;
896896
pub use self::model_logs_trace_remapper_type::LogsTraceRemapperType;
897+
pub mod model_logs_span_remapper;
898+
pub use self::model_logs_span_remapper::LogsSpanRemapper;
899+
pub mod model_logs_span_remapper_type;
900+
pub use self::model_logs_span_remapper_type::LogsSpanRemapperType;
897901
pub mod model_logs_processor;
898902
pub use self::model_logs_processor::LogsProcessor;
899903
pub mod model_logs_pipeline_processor_type;

src/datadogV1/model/model_logs_processor.rs

+8
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ pub enum LogsProcessor {
2626
Box<crate::datadogV1::model::ReferenceTableLogsLookupProcessor>,
2727
),
2828
LogsTraceRemapper(Box<crate::datadogV1::model::LogsTraceRemapper>),
29+
LogsSpanRemapper(Box<crate::datadogV1::model::LogsSpanRemapper>),
2930
UnparsedObject(crate::datadog::UnparsedObject),
3031
}
3132

@@ -150,6 +151,13 @@ impl<'de> Deserialize<'de> for LogsProcessor {
150151
return Ok(LogsProcessor::LogsTraceRemapper(_v));
151152
}
152153
}
154+
if let Ok(_v) =
155+
serde_json::from_value::<Box<crate::datadogV1::model::LogsSpanRemapper>>(value.clone())
156+
{
157+
if !_v._unparsed {
158+
return Ok(LogsProcessor::LogsSpanRemapper(_v));
159+
}
160+
}
153161

154162
return Ok(LogsProcessor::UnparsedObject(
155163
crate::datadog::UnparsedObject { value },
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
2+
// This product includes software developed at Datadog (https://www.datadoghq.com/).
3+
// Copyright 2019-Present Datadog, Inc.
4+
use serde::de::{Error, MapAccess, Visitor};
5+
use serde::{Deserialize, Deserializer, Serialize};
6+
use serde_with::skip_serializing_none;
7+
use std::fmt::{self, Formatter};
8+
9+
/// There are two ways to define correlation between application spans and logs:
10+
///
11+
/// 1. Follow the documentation on [how to inject a span ID in the application logs](<https://docs.datadoghq.com/tracing/connect_logs_and_traces>).
12+
/// Log integrations automatically handle all remaining setup steps by default.
13+
///
14+
/// 2. Use the span remapper processor to define a log attribute as its associated span ID.
15+
#[non_exhaustive]
16+
#[skip_serializing_none]
17+
#[derive(Clone, Debug, PartialEq, Serialize)]
18+
pub struct LogsSpanRemapper {
19+
/// Whether or not the processor is enabled.
20+
#[serde(rename = "is_enabled")]
21+
pub is_enabled: Option<bool>,
22+
/// Name of the processor.
23+
#[serde(rename = "name")]
24+
pub name: Option<String>,
25+
/// Array of source attributes.
26+
#[serde(rename = "sources")]
27+
pub sources: Option<Vec<String>>,
28+
/// Type of logs span remapper.
29+
#[serde(rename = "type")]
30+
pub type_: crate::datadogV1::model::LogsSpanRemapperType,
31+
#[serde(flatten)]
32+
pub additional_properties: std::collections::BTreeMap<String, serde_json::Value>,
33+
#[serde(skip)]
34+
#[serde(default)]
35+
pub(crate) _unparsed: bool,
36+
}
37+
38+
impl LogsSpanRemapper {
39+
pub fn new(type_: crate::datadogV1::model::LogsSpanRemapperType) -> LogsSpanRemapper {
40+
LogsSpanRemapper {
41+
is_enabled: None,
42+
name: None,
43+
sources: None,
44+
type_,
45+
additional_properties: std::collections::BTreeMap::new(),
46+
_unparsed: false,
47+
}
48+
}
49+
50+
pub fn is_enabled(mut self, value: bool) -> Self {
51+
self.is_enabled = Some(value);
52+
self
53+
}
54+
55+
pub fn name(mut self, value: String) -> Self {
56+
self.name = Some(value);
57+
self
58+
}
59+
60+
pub fn sources(mut self, value: Vec<String>) -> Self {
61+
self.sources = Some(value);
62+
self
63+
}
64+
65+
pub fn additional_properties(
66+
mut self,
67+
value: std::collections::BTreeMap<String, serde_json::Value>,
68+
) -> Self {
69+
self.additional_properties = value;
70+
self
71+
}
72+
}
73+
74+
impl<'de> Deserialize<'de> for LogsSpanRemapper {
75+
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
76+
where
77+
D: Deserializer<'de>,
78+
{
79+
struct LogsSpanRemapperVisitor;
80+
impl<'a> Visitor<'a> for LogsSpanRemapperVisitor {
81+
type Value = LogsSpanRemapper;
82+
83+
fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result {
84+
f.write_str("a mapping")
85+
}
86+
87+
fn visit_map<M>(self, mut map: M) -> Result<Self::Value, M::Error>
88+
where
89+
M: MapAccess<'a>,
90+
{
91+
let mut is_enabled: Option<bool> = None;
92+
let mut name: Option<String> = None;
93+
let mut sources: Option<Vec<String>> = None;
94+
let mut type_: Option<crate::datadogV1::model::LogsSpanRemapperType> = None;
95+
let mut additional_properties: std::collections::BTreeMap<
96+
String,
97+
serde_json::Value,
98+
> = std::collections::BTreeMap::new();
99+
let mut _unparsed = false;
100+
101+
while let Some((k, v)) = map.next_entry::<String, serde_json::Value>()? {
102+
match k.as_str() {
103+
"is_enabled" => {
104+
if v.is_null() {
105+
continue;
106+
}
107+
is_enabled = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
108+
}
109+
"name" => {
110+
if v.is_null() {
111+
continue;
112+
}
113+
name = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
114+
}
115+
"sources" => {
116+
if v.is_null() {
117+
continue;
118+
}
119+
sources = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
120+
}
121+
"type" => {
122+
type_ = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
123+
if let Some(ref _type_) = type_ {
124+
match _type_ {
125+
crate::datadogV1::model::LogsSpanRemapperType::UnparsedObject(_type_) => {
126+
_unparsed = true;
127+
},
128+
_ => {}
129+
}
130+
}
131+
}
132+
&_ => {
133+
if let Ok(value) = serde_json::from_value(v.clone()) {
134+
additional_properties.insert(k, value);
135+
}
136+
}
137+
}
138+
}
139+
let type_ = type_.ok_or_else(|| M::Error::missing_field("type_"))?;
140+
141+
let content = LogsSpanRemapper {
142+
is_enabled,
143+
name,
144+
sources,
145+
type_,
146+
additional_properties,
147+
_unparsed,
148+
};
149+
150+
Ok(content)
151+
}
152+
}
153+
154+
deserializer.deserialize_any(LogsSpanRemapperVisitor)
155+
}
156+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
2+
// This product includes software developed at Datadog (https://www.datadoghq.com/).
3+
// Copyright 2019-Present Datadog, Inc.
4+
5+
use serde::{Deserialize, Deserializer, Serialize, Serializer};
6+
7+
#[non_exhaustive]
8+
#[derive(Clone, Debug, Eq, PartialEq)]
9+
pub enum LogsSpanRemapperType {
10+
SPAN_ID_REMAPPER,
11+
UnparsedObject(crate::datadog::UnparsedObject),
12+
}
13+
14+
impl ToString for LogsSpanRemapperType {
15+
fn to_string(&self) -> String {
16+
match self {
17+
Self::SPAN_ID_REMAPPER => String::from("span-id-remapper"),
18+
Self::UnparsedObject(v) => v.value.to_string(),
19+
}
20+
}
21+
}
22+
23+
impl Serialize for LogsSpanRemapperType {
24+
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
25+
where
26+
S: Serializer,
27+
{
28+
match self {
29+
Self::UnparsedObject(v) => v.serialize(serializer),
30+
_ => serializer.serialize_str(self.to_string().as_str()),
31+
}
32+
}
33+
}
34+
35+
impl<'de> Deserialize<'de> for LogsSpanRemapperType {
36+
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
37+
where
38+
D: Deserializer<'de>,
39+
{
40+
let s: String = String::deserialize(deserializer)?;
41+
Ok(match s.as_str() {
42+
"span-id-remapper" => Self::SPAN_ID_REMAPPER,
43+
_ => Self::UnparsedObject(crate::datadog::UnparsedObject {
44+
value: serde_json::Value::String(s.into()),
45+
}),
46+
})
47+
}
48+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
2025-02-20T15:44:02.905Z

0 commit comments

Comments
 (0)