ELK version: 7.5.0
APM Agent: elastic-apm-node 3.6.1
Language: TypeScript 3.7.2
Environment: node 13.3
Install: npm install (fresh)
I'm trying leverage apm agent on my node/nest server, to monitor http requests coming into the server.
I set active,instrument, instrumentIncomingHTTPRequests to true, so I expect the agent to automatically start new transactions whenever an http request comes in.
However, I can't seem to access the transactions from the currentTransaction getter, I always get null. So I delved into the library code, and saw that when a transaction is created it sets currentTransaction = this. I also see that doing actions on the transaction through the agent object, uses the currentTransaction getter to access the transaction.
This does not make any sense to me, since the agent is a singleton, and so is the instrumentation object, which holds the currentTransaction. This means that if a 2nd http request comes in, its transaction overwrites the reference to the transaction started by the 1st http request, so now for example setting context by the 1st request will actually write that context to the transaction of the 2nd request.
So am I missing anything?
In a node server, is it wiser to only use custom transactions for http requests?
Otherwise, what is the correct way to make sure my labels, context, and response go on the correct transaction?