From c2b84d224fe787b73adc735b54977c2184475f19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Kol=C3=A1rik?= Date: Wed, 15 Jan 2025 18:25:28 +0100 Subject: [PATCH] misc: filter out short SPUBLISH APM spans --- src/lib/http/server.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/lib/http/server.ts b/src/lib/http/server.ts index 0d35373f..ed618389 100644 --- a/src/lib/http/server.ts +++ b/src/lib/http/server.ts @@ -35,6 +35,19 @@ apmAgent.addTransactionFilter(apmUtils.transactionFilter({ keepResponse: [ 'location' ], })); +// Filter out short SPUBLISH spans. +apmAgent.addSpanFilter((payload) => { + if (payload['type'] !== 'db' || payload['subtype'] !== 'redis' || [ 'SPUBLISH' ].includes(payload['name'] as string)) { + return payload; + } + + if (payload['duration'] > 10) { + return payload; + } + + return false; +}); + const app = new Koa({ proxy: true }); const publicPath = url.fileURLToPath(new URL('.', import.meta.url)) + '/../../../public'; const docsHost = config.get('server.docsHost');