Error while using Elastic node APM with database transactions

Description:
I am using elastic-apm-node to instrument a nestjs API it works perfectly, some weeks ago I needed to added database transactions using sequelize and I got the following error

I tested and If I remove database transactions it works correctly and not show this error.

I tried to search on the forums and and tried a lot of ways to solve this problem, but nothing works.

Thank you in advance!!

Hi @David_Souza ,

the API to start manual spans belongs to the transaction class as shown in Transaction API | APM Node.js Agent Reference [4.x] | Elastic. So you need to use such API in the ongoing transaction and the way of getting it is via apm.currentTransaction property.

By the code snippet given and knowing you're using NestJS I guess you're passing the apm instance through the injector by wrapping it with a module or service, right? If so I would ask

  • How you're starting the NestJS app
  • what exactly is the property Apm.context?
  • Could you share the apm wrapper module?

Cheers,
David

@David_Luna_Bistuer