I'm using Typeorm with SQL Server, which i believe uses node-mssql with the Tedious driver
I thought the issue might be because i'm building the monorepo with webpack, so i changed it to just use tsc for built and still doesn't seem to work.
The other spans for redis and Elasticsearch work, just seems to be the SQL Server that's not being picked up.
Not sure what code to share that would be helpful, as above i'm requiring the elastic-apm-node in my main.ts file and then within my app.module.ts file i'm setting up TypeORM like this:
TypeOrmModule.forRootAsync({
imports: [ConfigModule],
useFactory: async (configService: ConfigService) => ({
type: 'mssql',
host: configService.get('database.host'),
port: parseInt(configService.get('database.port')),
username: configService.get('database.username'),
password: configService.get('database.password'),
options: {
enableArithAbort: true,
trustServerCertificate: true,
},
pool: {
min: 0,
max: 100,
},
maxQueryExecutionTime: 500,
logger: 'advanced-console',
autoLoadEntities: true,
}),
inject: [ConfigService],
}),
Then an example of an actual SQL query within the service:
async getById(clientId: number, pageId: number): Promise<Navigation> {
return await this.navigationRepository
.createQueryBuilder('navigation')
.where('navigation.id = :pageId', { pageId: pageId })
.andWhere('navigation.status = :status', { status: Status.ACTIVE })
.andWhere('navigation.clientId = :clientId', { clientId: clientId })
.getOne();
}
An example of a controller calling the service:
@Version('1')
@Get(':id')
async getById(
@ClientId() clientId,
@Param() params,
): Promise<PageResponseWrapperDTO> {
const navigation = await this.navigationService.getById(
clientId,
params.id,
);
if (navigation) {
const markup = await this.markupService.getById(
params.id,
RelatedType.Navigation,
clientId,
);
const content = await this.contentService.getById(
params.id,
RelatedType.Navigation,
);
const assets = await this.assetService.getById(
clientId,
params.id,
RelatedType.Navigation,
);
return new PageResponseWrapperDTO(navigation, markup, content, assets);
} else {
throw new NotFoundException();
}
}