Skip to content

Add support for span id remapper in logs pipelines processors #2064

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .apigentools-info
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
"spec_versions": {
"v1": {
"apigentools_version": "1.6.6",
"regenerated": "2025-02-21 08:00:34.875274",
"spec_repo_commit": "8f2d39c3"
"regenerated": "2025-02-21 18:16:32.473757",
"spec_repo_commit": "5de91bd6"
},
"v2": {
"apigentools_version": "1.6.6",
"regenerated": "2025-02-21 08:00:34.890789",
"spec_repo_commit": "8f2d39c3"
"regenerated": "2025-02-21 18:16:32.489570",
"spec_repo_commit": "5de91bd6"
}
}
}
40 changes: 39 additions & 1 deletion .generator/schemas/v1/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6049,6 +6049,7 @@ components:
- $ref: '#/components/schemas/LogsLookupProcessor'
- $ref: '#/components/schemas/ReferenceTableLogsLookupProcessor'
- $ref: '#/components/schemas/LogsTraceRemapper'
- $ref: '#/components/schemas/LogsSpanRemapper'
LogsQueryCompute:
description: Define computation for a log query.
properties:
Expand Down Expand Up @@ -6160,6 +6161,43 @@ components:
x-enum-varnames:
- TIME_ASCENDING
- TIME_DESCENDING
LogsSpanRemapper:
description: "There are two ways to define correlation between application spans
and logs:\n\n 1. Follow the documentation on [how to inject a span ID in
the application logs](https://docs.datadoghq.com/tracing/connect_logs_and_traces).\n
\ Log integrations automatically handle all remaining setup steps by default.\n\n
\ 2. Use the span remapper processor to define a log attribute as its associated
span ID."
properties:
is_enabled:
default: false
description: Whether or not the processor is enabled.
type: boolean
name:
description: Name of the processor.
type: string
sources:
default:
- dd.span_id
description: Array of source attributes.
items:
description: Attribute to extract the span ID from.
type: string
type: array
type:
$ref: '#/components/schemas/LogsSpanRemapperType'
required:
- type
type: object
LogsSpanRemapperType:
default: span-id-remapper
description: Type of logs span remapper.
enum:
- span-id-remapper
example: span-id-remapper
type: string
x-enum-varnames:
- SPAN_ID_REMAPPER
LogsStatusRemapper:
description: "Use this Processor if you want to assign some attributes as the
official status.\n\nEach incoming status value is mapped as follows.\n\n -
Expand Down Expand Up @@ -6275,7 +6313,7 @@ components:
- dd.trace_id
description: Array of source attributes.
items:
description: Attribute to extract the Trace ID from.
description: Attribute to extract the trace ID from.
type: string
type: array
type:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"2025-02-20T15:44:02.905Z"
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
{
"log": {
"_recordingName": "Logs Pipelines/Create a pipeline with Span Id Remapper returns \"OK\" response",
"creator": {
"comment": "persister:fs",
"name": "Polly.JS",
"version": "6.0.5"
},
"entries": [
{
"_id": "ff199a6ef822fafe3c9d8e4c5427da4e",
"_order": 0,
"cache": {},
"request": {
"bodySize": 175,
"cookies": [],
"headers": [
{
"_fromType": "array",
"name": "accept",
"value": "application/json"
},
{
"_fromType": "array",
"name": "content-type",
"value": "application/json"
}
],
"headersSize": 574,
"httpVersion": "HTTP/1.1",
"method": "POST",
"postData": {
"mimeType": "application/json",
"params": [],
"text": "{\"filter\":{\"query\":\"source:python\"},\"name\":\"testPipeline\",\"processors\":[{\"is_enabled\":true,\"name\":\"test_filter\",\"sources\":[\"dd.span_id\"],\"type\":\"span-id-remapper\"}],\"tags\":[]}"
},
"queryString": [],
"url": "https://api.datadoghq.com/api/v1/logs/config/pipelines"
},
"response": {
"bodySize": 264,
"content": {
"mimeType": "application/json",
"size": 264,
"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"
},
"cookies": [],
"headers": [
{
"name": "content-type",
"value": "application/json"
}
],
"headersSize": 671,
"httpVersion": "HTTP/1.1",
"redirectURL": "",
"status": 200,
"statusText": "OK"
},
"startedDateTime": "2025-02-20T15:44:02.911Z",
"time": 516
},
{
"_id": "a339ab27e5bf3993c7b2ede49178b2e4",
"_order": 0,
"cache": {},
"request": {
"bodySize": 0,
"cookies": [],
"headers": [
{
"_fromType": "array",
"name": "accept",
"value": "*/*"
}
],
"headersSize": 533,
"httpVersion": "HTTP/1.1",
"method": "DELETE",
"queryString": [],
"url": "https://api.datadoghq.com/api/v1/logs/config/pipelines/duWU4bc3ROq5nz7GVi5TzA"
},
"response": {
"bodySize": 3,
"content": {
"mimeType": "application/json",
"size": 3,
"text": "{}\n"
},
"cookies": [],
"headers": [
{
"name": "content-type",
"value": "application/json"
}
],
"headersSize": 646,
"httpVersion": "HTTP/1.1",
"redirectURL": "",
"status": 200,
"statusText": "OK"
},
"startedDateTime": "2025-02-20T15:44:03.436Z",
"time": 466
}
],
"pages": [],
"version": "1.2"
}
}
35 changes: 35 additions & 0 deletions examples/v1/logs-pipelines/CreateLogsPipeline_2707101123.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/**
* Create a pipeline with Span Id Remapper returns "OK" response
*/

import { client, v1 } from "@datadog/datadog-api-client";

const configuration = client.createConfiguration();
const apiInstance = new v1.LogsPipelinesApi(configuration);

const params: v1.LogsPipelinesApiCreateLogsPipelineRequest = {
body: {
filter: {
query: "source:python",
},
name: "testPipeline",
processors: [
{
type: "span-id-remapper",
isEnabled: true,
name: "test_filter",
sources: ["dd.span_id"],
},
],
tags: [],
},
};

apiInstance
.createLogsPipeline(params)
.then((data: v1.LogsPipeline) => {
console.log(
"API called successfully. Returned data: " + JSON.stringify(data)
);
})
.catch((error: any) => console.error(error));
7 changes: 7 additions & 0 deletions features/v1/logs_pipelines.feature
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,13 @@ Feature: Logs Pipelines
When the request is sent
Then the response status is 200 OK

@team:DataDog/event-platform-experience
Scenario: Create a pipeline with Span Id Remapper returns "OK" response
Given new "CreateLogsPipeline" request
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": []}
When the request is sent
Then the response status is 200 OK

@generated @skip @team:DataDog/event-platform-experience
Scenario: Delete a pipeline returns "Bad Request" response
Given new "DeleteLogsPipeline" request
Expand Down
2 changes: 2 additions & 0 deletions packages/datadog-api-client-v1/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -590,6 +590,8 @@ export { LogsRetentionSumUsage } from "./models/LogsRetentionSumUsage";
export { LogsServiceRemapper } from "./models/LogsServiceRemapper";
export { LogsServiceRemapperType } from "./models/LogsServiceRemapperType";
export { LogsSort } from "./models/LogsSort";
export { LogsSpanRemapper } from "./models/LogsSpanRemapper";
export { LogsSpanRemapperType } from "./models/LogsSpanRemapperType";
export { LogsStatusRemapper } from "./models/LogsStatusRemapper";
export { LogsStatusRemapperType } from "./models/LogsStatusRemapperType";
export { LogsStringBuilderProcessor } from "./models/LogsStringBuilderProcessor";
Expand Down
2 changes: 2 additions & 0 deletions packages/datadog-api-client-v1/models/LogsProcessor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { LogsLookupProcessor } from "./LogsLookupProcessor";
import { LogsMessageRemapper } from "./LogsMessageRemapper";
import { LogsPipelineProcessor } from "./LogsPipelineProcessor";
import { LogsServiceRemapper } from "./LogsServiceRemapper";
import { LogsSpanRemapper } from "./LogsSpanRemapper";
import { LogsStatusRemapper } from "./LogsStatusRemapper";
import { LogsStringBuilderProcessor } from "./LogsStringBuilderProcessor";
import { LogsTraceRemapper } from "./LogsTraceRemapper";
Expand Down Expand Up @@ -43,4 +44,5 @@ export type LogsProcessor =
| LogsLookupProcessor
| ReferenceTableLogsLookupProcessor
| LogsTraceRemapper
| LogsSpanRemapper
| UnparsedObject;
83 changes: 83 additions & 0 deletions packages/datadog-api-client-v1/models/LogsSpanRemapper.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
/**
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
* This product includes software developed at Datadog (https://www.datadoghq.com/).
* Copyright 2020-Present Datadog, Inc.
*/
import { LogsSpanRemapperType } from "./LogsSpanRemapperType";

import { AttributeTypeMap } from "../../datadog-api-client-common/util";

/**
* There are two ways to define correlation between application spans and logs:
*
* 1. Follow the documentation on [how to inject a span ID in the application logs](https://docs.datadoghq.com/tracing/connect_logs_and_traces).
* Log integrations automatically handle all remaining setup steps by default.
*
* 2. Use the span remapper processor to define a log attribute as its associated span ID.
*/
export class LogsSpanRemapper {
/**
* Whether or not the processor is enabled.
*/
"isEnabled"?: boolean;
/**
* Name of the processor.
*/
"name"?: string;
/**
* Array of source attributes.
*/
"sources"?: Array<string>;
/**
* Type of logs span remapper.
*/
"type": LogsSpanRemapperType;

/**
* A container for additional, undeclared properties.
* This is a holder for any undeclared properties as specified with
* the 'additionalProperties' keyword in the OAS document.
*/
"additionalProperties"?: { [key: string]: any };

/**
* @ignore
*/
"_unparsed"?: boolean;

/**
* @ignore
*/
static readonly attributeTypeMap: AttributeTypeMap = {
isEnabled: {
baseName: "is_enabled",
type: "boolean",
},
name: {
baseName: "name",
type: "string",
},
sources: {
baseName: "sources",
type: "Array<string>",
},
type: {
baseName: "type",
type: "LogsSpanRemapperType",
required: true,
},
additionalProperties: {
baseName: "additionalProperties",
type: "any",
},
};

/**
* @ignore
*/
static getAttributeTypeMap(): AttributeTypeMap {
return LogsSpanRemapper.attributeTypeMap;
}

public constructor() {}
}
14 changes: 14 additions & 0 deletions packages/datadog-api-client-v1/models/LogsSpanRemapperType.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/**
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
* This product includes software developed at Datadog (https://www.datadoghq.com/).
* Copyright 2020-Present Datadog, Inc.
*/

import { UnparsedObject } from "../../datadog-api-client-common/util";

/**
* Type of logs span remapper.
*/

export type LogsSpanRemapperType = typeof SPAN_ID_REMAPPER | UnparsedObject;
export const SPAN_ID_REMAPPER = "span-id-remapper";
4 changes: 4 additions & 0 deletions packages/datadog-api-client-v1/models/ObjectSerializer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ import { LogsQueryCompute } from "./LogsQueryCompute";
import { LogsRetentionAggSumUsage } from "./LogsRetentionAggSumUsage";
import { LogsRetentionSumUsage } from "./LogsRetentionSumUsage";
import { LogsServiceRemapper } from "./LogsServiceRemapper";
import { LogsSpanRemapper } from "./LogsSpanRemapper";
import { LogsStatusRemapper } from "./LogsStatusRemapper";
import { LogsStringBuilderProcessor } from "./LogsStringBuilderProcessor";
import { LogsTraceRemapper } from "./LogsTraceRemapper";
Expand Down Expand Up @@ -924,6 +925,7 @@ const enumsMap: { [key: string]: any[] } = {
LogsPipelineProcessorType: ["pipeline"],
LogsServiceRemapperType: ["service-remapper"],
LogsSort: ["asc", "desc"],
LogsSpanRemapperType: ["span-id-remapper"],
LogsStatusRemapperType: ["status-remapper"],
LogsStringBuilderProcessorType: ["string-builder-processor"],
LogsTraceRemapperType: ["trace-id-remapper"],
Expand Down Expand Up @@ -1851,6 +1853,7 @@ const typeMap: { [index: string]: any } = {
LogsRetentionAggSumUsage: LogsRetentionAggSumUsage,
LogsRetentionSumUsage: LogsRetentionSumUsage,
LogsServiceRemapper: LogsServiceRemapper,
LogsSpanRemapper: LogsSpanRemapper,
LogsStatusRemapper: LogsStatusRemapper,
LogsStringBuilderProcessor: LogsStringBuilderProcessor,
LogsTraceRemapper: LogsTraceRemapper,
Expand Down Expand Up @@ -2373,6 +2376,7 @@ const oneOfMap: { [index: string]: string[] } = {
"LogsLookupProcessor",
"ReferenceTableLogsLookupProcessor",
"LogsTraceRemapper",
"LogsSpanRemapper",
],
MonitorFormulaAndFunctionQueryDefinition: [
"MonitorFormulaAndFunctionEventQueryDefinition",
Expand Down