-
Type: New Feature
-
Resolution: Unresolved
-
Priority: Minor - P4
-
None
-
Affects Version/s: None
-
Component/s: CMAP
How are you using Mongo? What version of the server and driver are you using?
MongoDb is used as a storage for an application which is instrumented to get APM data.
Server version: 5 (via docker image)
Driver version: 5.9.0
What is the feature/improvement you would like?
The driver queues the commands to be sent to the server until a connection is available into the connection_pool. That queue is flushed in the same context which, for most of the commands, is not the same context where the command was created.
As a consequence APM spans produced by agents like Elastic or Opentelemetry get the wrong parent ID. There is a repo which explains the issue and proposes a fix
https://github.com/david-luna/node-mongodb-native-async-resource
The issue has been already reported for Elastic APM agent
https://github.com/elastic/apm-agent-nodejs/issues/3161
What use case would this feature/improvement enable?
By binding the execution context to the callbacks queued in the connection pool APM tools will get the that context right and will be able to properly trace MongoDB commands. This will enable observability on NodeJS apps using MongoDB driver.
- related to
-
DRIVERS-719 Client Side Support for OpenTelemetry
- Defining
-
NODE-5556 Async Stack Traces
- Development Complete