From 96f64b4344f5c24c7c1991425ea0b0d5af297953 Mon Sep 17 00:00:00 2001 From: Sam Rose Date: Tue, 19 Dec 2023 11:47:41 +0000 Subject: [PATCH] Manually inject DataDog trace context to log messages. --- packages/backend-core/src/logging/pino/logger.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/packages/backend-core/src/logging/pino/logger.ts b/packages/backend-core/src/logging/pino/logger.ts index 7c444a3a59..7a051e7f12 100644 --- a/packages/backend-core/src/logging/pino/logger.ts +++ b/packages/backend-core/src/logging/pino/logger.ts @@ -5,6 +5,8 @@ import { IdentityType } from "@budibase/types" import env from "../../environment" import * as context from "../../context" import * as correlation from "../correlation" +import tracer from "dd-trace" +import { formats } from "dd-trace/ext" import { localFileDestination } from "../system" @@ -115,6 +117,11 @@ if (!env.DISABLE_PINO_LOGGER) { correlationId: correlation.getId(), } + const span = tracer.scope().active() + if (span) { + tracer.inject(span.context(), formats.LOG, contextObject) + } + const mergingObject: any = { err: error, pid: process.pid,