opentelemetry-js-contrib
opentelemetry-js-contrib copied to clipboard
`@opentelemetry/instrumentation-mongoose` does not instrument `insertMany` method
What version of OpenTelemetry are you using?
"@opentelemetry/api": "^1.9.0", "@opentelemetry/context-async-hooks": "^1.26.0", "@opentelemetry/exporter-metrics-otlp-grpc": "^0.53.0", "@opentelemetry/exporter-trace-otlp-grpc": "^0.53.0", "@opentelemetry/instrumentation-mongodb": "^0.47.0", "@opentelemetry/instrumentation-mongoose": "^0.42.0", "@opentelemetry/sdk-metrics": "^1.26.0", "@opentelemetry/sdk-node": "^0.53.0", "@opentelemetry/sdk-trace-node": "^1.26.0",
What version of Node are you using?
Node 20.18.0
What did you do?
SDK configuration
const sdk = new opentelemetry.NodeSDK({
autoDetectResources: false,
serviceName: process.env.SERVICE_NAME,
traceExporter: new OTLPTraceExporter(),
metricReader: new PeriodicExportingMetricReader({
exporter: new OTLPMetricExporter(),
}),
contextManager: new AsyncLocalStorageContextManager(),
instrumentations: [
new MongooseInstrumentation({
suppressInternalInstrumentation: true,
}),
new MongoDBInstrumentation({
dbStatementSerializer: () => 'omitted',
}),
],
resource: new Resource({
[ATTR_DEPLOYMENT_ENVIRONMENT]: process.env.ENVIRONMENT,
}),
resourceDetectors: [envDetector, hostDetector],
});
sdk.start();
Mongoose code
Model.insertMany(data);
What did you expect to see?
insertMany is instrumented by @opentelemetry/instrumentation-mongoose.
What did you see instead?
@opentelemetry/instrumentation-mongoose ignores insertMany and instead span is created by @opentelemetry/instrumentation-mongodb.
If @opentelemetry/instrumentation-mongodb is not used I don't see any traces from insertMany operation.
Additional context
I believe some other methods are also not instrumented but I have not encountered them yet.
cc @blumamir (component owner)
@blumamir Any updates on this?
@blumamir It looks like only static methods are not instrumented. I found these to be missing from spans.
Model.insertMany()
Model.bulkWrite()
Model.bulkSave()
Can you look at them?