No code spans in Node app


(Shanly Suepaul) #1

Hi! I set up an APM agent (v1.7) for my Node.JS/Express app. I'm seeing my service and transactions in Kibana APM, but I'm only seeing DB and ext spans in transaction traces. I confirmed I'm running supported versions (Node 6.14.3/Express 4.16). I even stripped down the code to a bare minimum to try to get any JS spans to appear, but nothing is working. Can someone help me spot any obvious errors?

const apm = require('elastic-apm-node');
apm.start();

const _ = require('lodash');
const express = require('express')
const app = express()
const https = require('https');
const config = require('./config');
const request = require('request');

app.get('/', (req, res) => {
    _.forEach(['a','b'], () => {
        for (let i = 0; i < 1000000; i++) {
                let j = i;
        }
    })
    Object.keys({foo: 'bar'})
    res.send('Hello World!')
})
app.get('/foo', (req, res) => request('http://example.com').pipe(res));
const server = https.createServer(config.httpsOptions, app);
server.listen(process.env.PORT);

(Thomas Watson) #2

I'm not entirely sure what you mean by "code spans", but Elastic APM doesn't generate spans for each function call, as that would create too big of an overhead and slow down your application.

What kind of spans besides db and external spans would you expect to see in an app like yours?


(Shanly Suepaul) #3

Sorry about the late reply - I was ill for a while and not working. I might expect to see an external span for the lodash calls, for example. I don't think it's necessary though. I think I'll just add spans to my middleware.


(system) #4

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.