'no data in elastic apm for nodejs application

I am trying to setup elastic apm for nodejs application. I followed the example explained in integration page of elk.

var apm = require('elastic-apm-node').start({

// Override the service name from package.json
// Allowed characters: a-z, A-Z, 0-9, -, _, and space
    serviceName: 'pv-server',

// Use if APM Server requires a secret token
    secretToken: '',
    logLevel:"debug",
// Set the custom APM Server URL (default: http://localhost:8200)
    serverUrl: 'http://localhost:8200',
    captureBody: 'all',
    active: true,
    usePathAsTransactionName: true,

// Set the service environment
    environment: 'dev'
})

When my service starts elastic apm is showing data for CPU usages only, there is no data in transaction/traces. I am using express web framework.

enter image description here

enter image description here



Solution 1:[1]

I was having the same problem. The solution was to put the amp config before the dependencies import.

ex:

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

const express = require('express');
const { Sequelize, Model, DataTypes } = require('sequelize');

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Tyler2P