Hello,
What is the status of the MongoDB native driver APM functionality on Node.js?
In the 3.6 docs, you can find it here, but it no longer appears in the docs for 4.x. Will it be removed?
Also, the docs for APM in 3.6 seem very wrong. For instance, there is this snippet of code:
const listener = require('mongodb').instrument({
operationIdGenerator: {
operationId: 1,
next: function() {
return this.operationId++;
}
},
timestampGenerator: {
current: function() {
return new Date().getTime();
},
duration: function(start, end) {
return end - start;
}
}
}, function(err, instrumentations) {
// Instrument the driver
});
But if you check at the driver code here, the options
argument isn’t used at all.
Also, the docs show that you can iterate over the instrumentations
argument … but that isn’t the case because instrumentations
is the Instrumentation Class instance which extends an EventEmitter
which doesn’t have a forEach
.
The code in 4.0 branch is the same but written in TS. Is this a work in progress? can we reliably use this? I’m currently using this for monitoring but I’m not quite sure if this APM will continue to exist in next versions. The alternative is overwrite prototype of internal MongoDB classes to get these commands which is something I want to avoid doing (but it’s something that some monitoring services actually do).