Skip to content

Commit 460861a

Browse files
api-clients-generation-pipeline[bot]ci.datadog-api-spec
andauthored
Add support for span id remapper in logs pipelines processors (#2064)
Co-authored-by: ci.datadog-api-spec <[email protected]>
1 parent 17e7165 commit 460861a

File tree

11 files changed

+301
-5
lines changed

11 files changed

+301
-5
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:34.875274",
8-
"spec_repo_commit": "8f2d39c3"
7+
"regenerated": "2025-02-21 18:16:32.473757",
8+
"spec_repo_commit": "5de91bd6"
99
},
1010
"v2": {
1111
"apigentools_version": "1.6.6",
12-
"regenerated": "2025-02-21 08:00:34.890789",
13-
"spec_repo_commit": "8f2d39c3"
12+
"regenerated": "2025-02-21 18:16:32.489570",
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:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
"2025-02-20T15:44:02.905Z"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
{
2+
"log": {
3+
"_recordingName": "Logs Pipelines/Create a pipeline with Span Id Remapper returns \"OK\" response",
4+
"creator": {
5+
"comment": "persister:fs",
6+
"name": "Polly.JS",
7+
"version": "6.0.5"
8+
},
9+
"entries": [
10+
{
11+
"_id": "ff199a6ef822fafe3c9d8e4c5427da4e",
12+
"_order": 0,
13+
"cache": {},
14+
"request": {
15+
"bodySize": 175,
16+
"cookies": [],
17+
"headers": [
18+
{
19+
"_fromType": "array",
20+
"name": "accept",
21+
"value": "application/json"
22+
},
23+
{
24+
"_fromType": "array",
25+
"name": "content-type",
26+
"value": "application/json"
27+
}
28+
],
29+
"headersSize": 574,
30+
"httpVersion": "HTTP/1.1",
31+
"method": "POST",
32+
"postData": {
33+
"mimeType": "application/json",
34+
"params": [],
35+
"text": "{\"filter\":{\"query\":\"source:python\"},\"name\":\"testPipeline\",\"processors\":[{\"is_enabled\":true,\"name\":\"test_filter\",\"sources\":[\"dd.span_id\"],\"type\":\"span-id-remapper\"}],\"tags\":[]}"
36+
},
37+
"queryString": [],
38+
"url": "https://api.datadoghq.com/api/v1/logs/config/pipelines"
39+
},
40+
"response": {
41+
"bodySize": 264,
42+
"content": {
43+
"mimeType": "application/json",
44+
"size": 264,
45+
"text": "{\"id\":\"duWU4bc3ROq5nz7GVi5TzA\",\"type\":\"pipeline\",\"name\":\"testPipeline\",\"is_enabled\":false,\"is_read_only\":false,\"filter\":{\"query\":\"source:python\"},\"processors\":[{\"name\":\"test_filter\",\"is_enabled\":true,\"sources\":[\"dd.span_id\"],\"type\":\"span-id-remapper\"}],\"tags\":[]}\n"
46+
},
47+
"cookies": [],
48+
"headers": [
49+
{
50+
"name": "content-type",
51+
"value": "application/json"
52+
}
53+
],
54+
"headersSize": 671,
55+
"httpVersion": "HTTP/1.1",
56+
"redirectURL": "",
57+
"status": 200,
58+
"statusText": "OK"
59+
},
60+
"startedDateTime": "2025-02-20T15:44:02.911Z",
61+
"time": 516
62+
},
63+
{
64+
"_id": "a339ab27e5bf3993c7b2ede49178b2e4",
65+
"_order": 0,
66+
"cache": {},
67+
"request": {
68+
"bodySize": 0,
69+
"cookies": [],
70+
"headers": [
71+
{
72+
"_fromType": "array",
73+
"name": "accept",
74+
"value": "*/*"
75+
}
76+
],
77+
"headersSize": 533,
78+
"httpVersion": "HTTP/1.1",
79+
"method": "DELETE",
80+
"queryString": [],
81+
"url": "https://api.datadoghq.com/api/v1/logs/config/pipelines/duWU4bc3ROq5nz7GVi5TzA"
82+
},
83+
"response": {
84+
"bodySize": 3,
85+
"content": {
86+
"mimeType": "application/json",
87+
"size": 3,
88+
"text": "{}\n"
89+
},
90+
"cookies": [],
91+
"headers": [
92+
{
93+
"name": "content-type",
94+
"value": "application/json"
95+
}
96+
],
97+
"headersSize": 646,
98+
"httpVersion": "HTTP/1.1",
99+
"redirectURL": "",
100+
"status": 200,
101+
"statusText": "OK"
102+
},
103+
"startedDateTime": "2025-02-20T15:44:03.436Z",
104+
"time": 466
105+
}
106+
],
107+
"pages": [],
108+
"version": "1.2"
109+
}
110+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/**
2+
* Create a pipeline with Span Id Remapper returns "OK" response
3+
*/
4+
5+
import { client, v1 } from "@datadog/datadog-api-client";
6+
7+
const configuration = client.createConfiguration();
8+
const apiInstance = new v1.LogsPipelinesApi(configuration);
9+
10+
const params: v1.LogsPipelinesApiCreateLogsPipelineRequest = {
11+
body: {
12+
filter: {
13+
query: "source:python",
14+
},
15+
name: "testPipeline",
16+
processors: [
17+
{
18+
type: "span-id-remapper",
19+
isEnabled: true,
20+
name: "test_filter",
21+
sources: ["dd.span_id"],
22+
},
23+
],
24+
tags: [],
25+
},
26+
};
27+
28+
apiInstance
29+
.createLogsPipeline(params)
30+
.then((data: v1.LogsPipeline) => {
31+
console.log(
32+
"API called successfully. Returned data: " + JSON.stringify(data)
33+
);
34+
})
35+
.catch((error: any) => console.error(error));

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

packages/datadog-api-client-v1/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -590,6 +590,8 @@ export { LogsRetentionSumUsage } from "./models/LogsRetentionSumUsage";
590590
export { LogsServiceRemapper } from "./models/LogsServiceRemapper";
591591
export { LogsServiceRemapperType } from "./models/LogsServiceRemapperType";
592592
export { LogsSort } from "./models/LogsSort";
593+
export { LogsSpanRemapper } from "./models/LogsSpanRemapper";
594+
export { LogsSpanRemapperType } from "./models/LogsSpanRemapperType";
593595
export { LogsStatusRemapper } from "./models/LogsStatusRemapper";
594596
export { LogsStatusRemapperType } from "./models/LogsStatusRemapperType";
595597
export { LogsStringBuilderProcessor } from "./models/LogsStringBuilderProcessor";

packages/datadog-api-client-v1/models/LogsProcessor.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import { LogsLookupProcessor } from "./LogsLookupProcessor";
1313
import { LogsMessageRemapper } from "./LogsMessageRemapper";
1414
import { LogsPipelineProcessor } from "./LogsPipelineProcessor";
1515
import { LogsServiceRemapper } from "./LogsServiceRemapper";
16+
import { LogsSpanRemapper } from "./LogsSpanRemapper";
1617
import { LogsStatusRemapper } from "./LogsStatusRemapper";
1718
import { LogsStringBuilderProcessor } from "./LogsStringBuilderProcessor";
1819
import { LogsTraceRemapper } from "./LogsTraceRemapper";
@@ -43,4 +44,5 @@ export type LogsProcessor =
4344
| LogsLookupProcessor
4445
| ReferenceTableLogsLookupProcessor
4546
| LogsTraceRemapper
47+
| LogsSpanRemapper
4648
| UnparsedObject;
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
/**
2+
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
3+
* This product includes software developed at Datadog (https://www.datadoghq.com/).
4+
* Copyright 2020-Present Datadog, Inc.
5+
*/
6+
import { LogsSpanRemapperType } from "./LogsSpanRemapperType";
7+
8+
import { AttributeTypeMap } from "../../datadog-api-client-common/util";
9+
10+
/**
11+
* There are two ways to define correlation between application spans and logs:
12+
*
13+
* 1. Follow the documentation on [how to inject a span ID in the application logs](https://docs.datadoghq.com/tracing/connect_logs_and_traces).
14+
* Log integrations automatically handle all remaining setup steps by default.
15+
*
16+
* 2. Use the span remapper processor to define a log attribute as its associated span ID.
17+
*/
18+
export class LogsSpanRemapper {
19+
/**
20+
* Whether or not the processor is enabled.
21+
*/
22+
"isEnabled"?: boolean;
23+
/**
24+
* Name of the processor.
25+
*/
26+
"name"?: string;
27+
/**
28+
* Array of source attributes.
29+
*/
30+
"sources"?: Array<string>;
31+
/**
32+
* Type of logs span remapper.
33+
*/
34+
"type": LogsSpanRemapperType;
35+
36+
/**
37+
* A container for additional, undeclared properties.
38+
* This is a holder for any undeclared properties as specified with
39+
* the 'additionalProperties' keyword in the OAS document.
40+
*/
41+
"additionalProperties"?: { [key: string]: any };
42+
43+
/**
44+
* @ignore
45+
*/
46+
"_unparsed"?: boolean;
47+
48+
/**
49+
* @ignore
50+
*/
51+
static readonly attributeTypeMap: AttributeTypeMap = {
52+
isEnabled: {
53+
baseName: "is_enabled",
54+
type: "boolean",
55+
},
56+
name: {
57+
baseName: "name",
58+
type: "string",
59+
},
60+
sources: {
61+
baseName: "sources",
62+
type: "Array<string>",
63+
},
64+
type: {
65+
baseName: "type",
66+
type: "LogsSpanRemapperType",
67+
required: true,
68+
},
69+
additionalProperties: {
70+
baseName: "additionalProperties",
71+
type: "any",
72+
},
73+
};
74+
75+
/**
76+
* @ignore
77+
*/
78+
static getAttributeTypeMap(): AttributeTypeMap {
79+
return LogsSpanRemapper.attributeTypeMap;
80+
}
81+
82+
public constructor() {}
83+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/**
2+
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
3+
* This product includes software developed at Datadog (https://www.datadoghq.com/).
4+
* Copyright 2020-Present Datadog, Inc.
5+
*/
6+
7+
import { UnparsedObject } from "../../datadog-api-client-common/util";
8+
9+
/**
10+
* Type of logs span remapper.
11+
*/
12+
13+
export type LogsSpanRemapperType = typeof SPAN_ID_REMAPPER | UnparsedObject;
14+
export const SPAN_ID_REMAPPER = "span-id-remapper";

0 commit comments

Comments
 (0)