I need to send span to elastic-apm after sending express response.
In my code example, i use setInterval. First express response, after 1 second, i try use startspan, but i got error: Cannot read property 'end' of null
const apm = require('elastic-apm-node').start();
const app = require('express')(); app.get('/', (req, res) => {
setTimeout(() => {
span = apm.startSpan("My span");
span.end();
}, 100)
res.json({"teste": "TESTE"});
});
My elastic stack version is 7.6.2