From e62298e199867975bf694455d6ac2963588463bd Mon Sep 17 00:00:00 2001 From: Sam Rose Date: Wed, 31 Jul 2024 15:38:26 +0100 Subject: [PATCH 1/2] Record SQS queries in DataDog. --- packages/server/src/sdk/app/rows/search/sqs.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/server/src/sdk/app/rows/search/sqs.ts b/packages/server/src/sdk/app/rows/search/sqs.ts index 5da2a7bcfb..5b743d18c6 100644 --- a/packages/server/src/sdk/app/rows/search/sqs.ts +++ b/packages/server/src/sdk/app/rows/search/sqs.ts @@ -43,6 +43,7 @@ import { } from "./filters" import { dataFilters, PROTECTED_INTERNAL_COLUMNS } from "@budibase/shared-core" import { isSearchingByRowID } from "./utils" +import tracer from "dd-trace" const builder = new sql.Sql(SqlClient.SQL_LITE) const MISSING_COLUMN_REGEX = new RegExp(`no such column: .+`) @@ -225,7 +226,11 @@ async function runSqlQuery( } const db = context.getAppDB() - return await db.sql(sql, bindings) + + return await tracer.trace( + "sqs.runSqlQuery", + async () => await db.sql(sql, bindings) + ) } const response = await alias.queryWithAliasing(json, processSQLQuery) if (opts?.countTotalRows) { From f0dbaa5eae0867cd8c1f109b7b24a9588b33d021 Mon Sep 17 00:00:00 2001 From: Sam Rose Date: Wed, 31 Jul 2024 15:40:54 +0100 Subject: [PATCH 2/2] Add query to span as a tag. --- packages/server/src/sdk/app/rows/search/sqs.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/server/src/sdk/app/rows/search/sqs.ts b/packages/server/src/sdk/app/rows/search/sqs.ts index 5b743d18c6..8a61684020 100644 --- a/packages/server/src/sdk/app/rows/search/sqs.ts +++ b/packages/server/src/sdk/app/rows/search/sqs.ts @@ -227,10 +227,10 @@ async function runSqlQuery( const db = context.getAppDB() - return await tracer.trace( - "sqs.runSqlQuery", - async () => await db.sql(sql, bindings) - ) + return await tracer.trace("sqs.runSqlQuery", async span => { + span?.addTags({ sql }) + return await db.sql(sql, bindings) + }) } const response = await alias.queryWithAliasing(json, processSQLQuery) if (opts?.countTotalRows) {