From e2d387feb3380ec0565d2e12cc94c6931488e391 Mon Sep 17 00:00:00 2001 From: simon-id Date: Thu, 19 Dec 2024 13:51:27 +0100 Subject: [PATCH 1/3] Update app.js --- utils/build/docker/nodejs/express/app.js | 1 + 1 file changed, 1 insertion(+) diff --git a/utils/build/docker/nodejs/express/app.js b/utils/build/docker/nodejs/express/app.js index 5f765627b7..f770147cd1 100644 --- a/utils/build/docker/nodejs/express/app.js +++ b/utils/build/docker/nodejs/express/app.js @@ -440,6 +440,7 @@ require('./auth')(app, passport, tracer) // try to flush as much stuff as possible from the library app.get('/flush', (req, res) => { + // TODO make a try catch here // doesn't have a callback :( // tracer._tracer?._dataStreamsProcessor?.writer?.flush?.() tracer.dogstatsd?.flush?.() From 5e0cc95d8e6dcd7ee131d9be9ceb7f4b3890a63e Mon Sep 17 00:00:00 2001 From: simon-id Date: Fri, 27 Dec 2024 18:02:42 +0100 Subject: [PATCH 2/3] add try catch --- utils/build/docker/nodejs/express/app.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/utils/build/docker/nodejs/express/app.js b/utils/build/docker/nodejs/express/app.js index f770147cd1..eef04e9182 100644 --- a/utils/build/docker/nodejs/express/app.js +++ b/utils/build/docker/nodejs/express/app.js @@ -440,7 +440,6 @@ require('./auth')(app, passport, tracer) // try to flush as much stuff as possible from the library app.get('/flush', (req, res) => { - // TODO make a try catch here // doesn't have a callback :( // tracer._tracer?._dataStreamsProcessor?.writer?.flush?.() tracer.dogstatsd?.flush?.() @@ -449,10 +448,12 @@ app.get('/flush', (req, res) => { // does have a callback :) const promises = [] - const { profiler } = require('dd-trace/packages/dd-trace/src/profiling/') - if (profiler?._collect) { - promises.push(profiler._collect('on_shutdown')) - } + try { + const { profiler } = require('dd-trace/packages/dd-trace/src/profiling/') + if (profiler?._collect) { + promises.push(profiler._collect('on_shutdown')) + } + } catch {} if (tracer._tracer?._exporter?._writer?.flush) { promises.push(promisify((err) => tracer._tracer._exporter._writer.flush(err))) From 9198212d75c06cbcd826e14a94acab6fc79d8e31 Mon Sep 17 00:00:00 2001 From: simon-id Date: Mon, 30 Dec 2024 11:07:20 +0100 Subject: [PATCH 3/3] Update utils/build/docker/nodejs/express/app.js --- utils/build/docker/nodejs/express/app.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/utils/build/docker/nodejs/express/app.js b/utils/build/docker/nodejs/express/app.js index eef04e9182..c294838692 100644 --- a/utils/build/docker/nodejs/express/app.js +++ b/utils/build/docker/nodejs/express/app.js @@ -453,7 +453,9 @@ app.get('/flush', (req, res) => { if (profiler?._collect) { promises.push(profiler._collect('on_shutdown')) } - } catch {} + } catch (err) { + console.error('Unable to flush profiler:', err) + } if (tracer._tracer?._exporter?._writer?.flush) { promises.push(promisify((err) => tracer._tracer._exporter._writer.flush(err)))