Skip to content

Commit

Permalink
[nodejs] Try catch the /flush endpoint (#3727)
Browse files Browse the repository at this point in the history
  • Loading branch information
simon-id authored Jan 6, 2025
1 parent 587906e commit 2454953
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions utils/build/docker/nodejs/express/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -448,9 +448,13 @@ 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 (err) {
console.error('Unable to flush profiler:', err)
}

if (tracer._tracer?._exporter?._writer?.flush) {
Expand Down

0 comments on commit 2454953

Please sign in to comment.