I'm using elastic apm
to profiling my NestJS
application and my apm agent is elastic-apm-node
.
My ORM is typeOrm
and my database is Oracle
.
My problem is apm agent does not record database query spans and I can't see database query spans in kibana ui. Can anyone help me?
unfortunately oracle is not supported by elastic apm agent. you should wrap your oracleQueryRunner
in order to start and end agent spans manually. put this code in your main.ts
file:
import { OracleQueryRunner } from 'typeorm/driver/oracle/OracleQueryRunner';
const query = OracleQueryRunner.prototype.query;
OracleQueryRunner.prototype.query = async function (...args) {
const span = apm.startSpan('query');
if (span) {
span.type = 'db';
span.action = args[0];
}
const result = await query.bind(this)(...args);
if (span) { span.end(); }
return result;
};