Unable to get transaction on APM server

I am using running service on local on docker container, Also my APM is running on docker. Locally it is working fine and population transactions entry for every API in the service but when I am deploying my service on the server (also docker) and APM on server also runs on docker but unable to populate transactions for API. It shows nothing.

Strangely, I am able to create service on the server.

this is how I am starting APM. TIA

const config = require('../globals/config');

let apm = {};

// start APM
module.exports = ({logger}) => {
    if (typeof config.get('server:apm_server') !== 'undefined') {
        apm = require('elastic-apm-node').start({
            serviceName: config.get('server:apm_server:apm_service_name'),
            serverUrl: `${config.get('server:apm_server:host')}:${config.get('server:apm_server:port')}`, // set custom APM Server URL (default: http://localhost:8200)
            serviceVersion: config.get('app:version'),
            captureBody: 'all',
            metricsInterval: '60s'
        logger.info(' [\u2713] APM [ready]');
        return apm
    } else
        logger.info(' [\u2a2f] APM not enabled');

Hi @Zain_Ul_Abideen,

It's hard to say what could be the issue only with the code snippet so I'm going to ask some questions about it.

  • I see this module is exporting a function which will be used to start the APM agent. Is that function called in the main JS file? Is it called before an other require in the file?
  • It's config just a getter around a specific configuration format or is it capable to differentiate between development/production environments?
  • Are you using any kind of bundler for production builds?
  • Could you add logLevel:'trace' to the start options of the APM agent and get the logs of the container and attach them here?


Thanks for response David, I understand it's difficult but cannot share much code here.

  • It is being called after fastify server has created in the main JS file but points are:

    • If ordering is an issue, it should not work on local but it is working.

    • On server, it is creating services, again if ordering the issue, how is it able to create a service in APM

  • yes it is

  • No

  • already done but no clue.

Issues was resolved. Ordering was the issue, when I moved APM initialization at the top before everything it worked! but still I am confused that with previous ordering how come it was working on local?

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