While I can’t speak for v3 nor the actual configuration of the dd-trace package. For the v4 you should be able to do something like this:
// path: `./src/index.js`
module.exports = {
/**
* An asynchronous register function that runs before
* your application is initialized.
*
* This gives you an opportunity to extend code.
*/
register(/*{ strapi }*/) {
const tracer = require('dd-trace').init({
debug: true,
runtimeMetrics: true,
logInjection: true
});
},
/**
* An asynchronous bootstrap function that runs before
* your application gets started.
*
* This gives you an opportunity to set up your data model,
* run jobs, or perform some special logic.
*/
bootstrap(/*{ strapi }*/) {},
};
At least this is dumping a bunch of debug messages about it being unable to connect to 127.0.0.1:8126 so I assume there is some config you need to do to point it at DataDog
Has anyone else been able to get dd-trace to work for APM metrics in Strapi 4?
In Strapi 3 I had it working with a simple require(“dd-trace”).init(); at the top of the bootstrap.js file, but the code above in src/index.js in register() in Strapi 4 doesn’t seem to be working
I was facing the same problem here and I’ve found a way to make it work using strapi v4.
No need to insert the init() function inside src/index.js → register(), we can place it as a new file following the Datadog docs.
I wasn’t able to check the tracer information on the Datadog APM tab because I didn’t have a Datalog Agent running.
When we use the dd-trace library, it assumes by default that we’re running this agent on localhost:8125 (We can modify it inside the init() function).
All I had to do was follow the steps to install this agent listed on the Datadog guide(Datadog: Log In) and after setting up this agent I was able to check the APM metrics.