I've got a NestJS monorepo and i'm loading in the elastic-apm-node at the top of the main.ts file:
require('elastic-apm-node').start({
// Override the service name from package.json
// Allowed characters: a-z, A-Z, 0-9, -, _, and space
serviceName: 'api',
// Use if APM Server requires a secret token
secretToken: '<token>',
// Set the custom APM Server URL (default: http://localhost:8200)
serverUrl:
'<server_url>',
// Set the service environment
environment: process.env.NODE_ENV,
cloudProvider: 'none',
captureBody: 'all',
});
I can see the HTTP requests properly labelled however the traces are missing the SQL spans
Elastic APM Logs:
{"log.level":"debug","@timestamp":"2021-12-08T13:25:03.456Z","log":{"logger":"elastic-apm-node"},"ecs":{"version":"1.6.0"},"message":"intercepted request event call to http.Server.prototype.emit for /stock/inventory/9823"}
{"log.level":"debug","@timestamp":"2021-12-08T13:25:03.457Z","log":{"logger":"elastic-apm-node"},"ecs":{"version":"1.6.0"},"message":"start trace {\"trans\":\"7b1bae9fb898237a\",\"trace\":\"54a93045decc466de194252e06b0f62c\",\"name\":\"unnamed\",\"type\":null,\"subtype\":null,\"action\":null}"}
{"log.level":"debug","@timestamp":"2021-12-08T13:25:03.458Z","log":{"logger":"elastic-apm-node"},"ecs":{"version":"1.6.0"},"message":"setting default transaction name: GET /stock/inventory/:id {\"trans\":\"7b1bae9fb898237a\",\"trace\":\"54a93045decc466de194252e06b0f62c\"}"}
{"log.level":"debug","@timestamp":"2021-12-08T13:25:03.494Z","log":{"logger":"elastic-apm-node"},"ecs":{"version":"1.6.0"},"message":"setting transaction result {\"trans\":\"7b1bae9fb898237a\",\"trace\":\"54a93045decc466de194252e06b0f62c\",\"result\":\"HTTP 2xx\"}"}
{"log.level":"debug","@timestamp":"2021-12-08T13:25:03.495Z","log":{"logger":"elastic-apm-node"},"ecs":{"version":"1.6.0"},"message":"sending transaction {\"trans\":\"7b1bae9fb898237a\",\"trace\":\"54a93045decc466de194252e06b0f62c\"}"}
{"log.level":"debug","@timestamp":"2021-12-08T13:25:03.496Z","log":{"logger":"elastic-apm-node"},"ecs":{"version":"1.6.0"},"message":"ended transaction {\"trans\":\"7b1bae9fb898237a\",\"trace\":\"54a93045decc466de194252e06b0f62c\",\"type\":\"request\",\"result\":\"HTTP 2xx\",\"name\":\"GET /stock/inventory/:id\"}"}
{"log.level":"trace","@timestamp":"2021-12-08T13:25:03.528Z","log":{"logger":"elastic-apm-node"},"event.module":"apmclient","fullTimeMs":0.1722,"numEvents":1,"numBytes":1178,"ecs":{"version":"1.6.0"},"message":"_write: encode object"}
{"log.level":"trace","@timestamp":"2021-12-08T13:25:05.044Z","log":{"logger":"elastic-apm-node"},"event.module":"apmclient","reqId":"e8984bbe9c64f05cf884605429016425","ecs":{"version":"1.6.0"},"message":"gzipStream \"finish\""}
{"log.level":"trace","@timestamp":"2021-12-08T13:25:05.045Z","log":{"logger":"elastic-apm-node"},"event.module":"apmclient","reqId":"e8984bbe9c64f05cf884605429016425","timeout":10000,"ecs":{"version":"1.6.0"},"message":"start intakeResTimer"}
{"log.level":"trace","@timestamp":"2021-12-08T13:25:05.045Z","log":{"logger":"elastic-apm-node"},"event.module":"apmclient","reqId":"e8984bbe9c64f05cf884605429016425","ecs":{"version":"1.6.0"},"message":"gzipStream \"end\""}
{"log.level":"trace","@timestamp":"2021-12-08T13:25:05.045Z","log":{"logger":"elastic-apm-node"},"event.module":"apmclient","reqId":"e8984bbe9c64f05cf884605429016425","concluded":false,"ecs":{"version":"1.6.0"},"message":"completePart gzipStream"}
{"log.level":"trace","@timestamp":"2021-12-08T13:25:05.046Z","log":{"logger":"elastic-apm-node"},"event.module":"apmclient","reqId":"e8984bbe9c64f05cf884605429016425","ecs":{"version":"1.6.0"},"message":"intakeReq \"finish\""}
{"log.level":"trace","@timestamp":"2021-12-08T13:25:05.046Z","log":{"logger":"elastic-apm-node"},"event.module":"apmclient","reqId":"e8984bbe9c64f05cf884605429016425","concluded":false,"ecs":{"version":"1.6.0"},"message":"completePart intakeReq"}
{"log.level":"trace","@timestamp":"2021-12-08T13:25:05.092Z","log":{"logger":"elastic-apm-node"},"event.module":"apmclient","reqId":"e8984bbe9c64f05cf884605429016425","statusCode":202,"reqFinished":true,"ecs":{"version":"1.6.0"},"message":"intakeReq \"response\""}
{"log.level":"trace","@timestamp":"2021-12-08T13:25:05.093Z","log":{"logger":"elastic-apm-node"},"event.module":"apmclient","reqId":"e8984bbe9c64f05cf884605429016425","ecs":{"version":"1.6.0"},"message":"intakeRes \"end\""}
{"log.level":"trace","@timestamp":"2021-12-08T13:25:05.093Z","log":{"logger":"elastic-apm-node"},"event.module":"apmclient","reqId":"e8984bbe9c64f05cf884605429016425","concluded":false,"ecs":{"version":"1.6.0"},"message":"completePart intakeRes"}
{"log.level":"trace","@timestamp":"2021-12-08T13:25:05.093Z","log":{"logger":"elastic-apm-node"},"event.module":"apmclient","reqId":"e8984bbe9c64f05cf884605429016425","timeline":[[10008.921,"completePart gzipStream",null],[10009.3674,"completePart intakeReq",null],[10056.5654,"completePart intakeRes",null]],"bytesWritten":2811,"backoffDelayMs":0,"ecs":{"version":"1.6.0"},"message":"conclude intake request: success"}
{"log.level":"trace","@timestamp":"2021-12-08T13:25:11.819Z","log":{"logger":"elastic-apm-node"},"event.module":"apmclient","reqId":"d84003da4f1d0be521db52785e14f80c","ecs":{"version":"1.6.0"},"message":"intake request start"}
{"log.level":"trace","@timestamp":"2021-12-08T13:25:11.819Z","log":{"logger":"elastic-apm-node"},"event.module":"apmclient","encodeTimeMs":0.5345,"fullTimeMs":1.5251,"numEvents":7,"numBytes":2520,"ecs":{"version":"1.6.0"},"message":"_writeBatch"}
{"log.level":"trace","@timestamp":"2021-12-08T13:25:11.819Z","log":{"logger":"elastic-apm-node"},"event.module":"apmclient","reqId":"d84003da4f1d0be521db52785e14f80c","ecs":{"version":"1.6.0"},"message":"intakeReq \"socket\": unref it"}