Hello
I have a distributed trace that is basically a main transaction that calls an external endpoint that is responsible for some Mongo DB integration. The thing is, I'm trying to understand why currently my main transaction's trace is ending before the call to the external endpoint comes back (see image).
That could be because of some javascript-promises-async-await error in my code, but I did some debugging and I think things are chained correctly. Anyway here is my code:
Controller:
exports.generateDistributedTransaction = async (req, res, next) => {
const simulationRequest = res.locals.simulationRequest;
const simulation = new Simulation();
await simulation.generateDistributedTransaction(simulationRequest);
res.status(200).send();
};
Service:
async generateDistributedTransaction(simulationRequest) {
const datasets = ['users', 'todos', 'comments', 'albuns', 'photos'];
const randomIndex = Math.floor(Math.random() * (datasets.length));
const usersFetchAndSaveEndpoint = `http://external-service:3000/api/${datasets[randomIndex]}/fetch`;
await this.init(simulationRequest, false);
return await axios.get(usersFetchAndSaveEndpoint);
}
Should I insert the traceparent in some header when calling the external service?
Should I wrap the externa call in a manually created transaction or span?
Here is what it looks like currently:
Thank you for your help.