I am using https://typeorm.io/#/ in my nodejs project to connect to Postgresql. My app is running in AWS lambda and I'd like to enable xray for performance analysis. With xray sdk, I can do something like below code:
var AWSXRay = require('aws-xray-sdk');
var pg = AWSXRay.capturePostgres(require('pg'));
var client = new pg.Client();
the above code will send query trace data to xray for instrumenting. However, I don't know how to make it work with typeorm
since it hides the pg
client from my code. Is there a way to capturePostgres inside typeorm
?
I have a pretty smooth workaround using webpack (already have it in the project):
webpack.config.js
bootstrapMysql.ts
I'm using TS, and mysql but it works in vanilla js and other dbs(replace imports by require)
I'm also applying this trick to inject xray on http call (using axios), and on aws-sdk