We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"@opentelemetry/api": "0.18.0" "@opentelemetry/core": "0.18.0" "@opentelemetry/instrumentation-mongodb": "0.14.0"
12.20.0
import { SimpleSpanProcessor } from '@opentelemetry/tracing'; import { NodeTracerProvider } from '@opentelemetry/node'; import { ZipkinExporter } from '@opentelemetry/exporter-zipkin'; import { registerInstrumentations } from '@opentelemetry/instrumentation'; import { HttpInstrumentation } from '@opentelemetry/instrumentation-http'; import { MongoDBInstrumentation } from '@opentelemetry/instrumentation-mongodb'; const serviceName = 'otel-mongodb-test'; const provider = new NodeTracerProvider(); registerInstrumentations({ instrumentations: [ new HttpInstrumentation(), new MongoDBInstrumentation(), ], tracerProvider: provider, }); const zipkinExporter = new ZipkinExporter({ serviceName, url: 'http://localhost:9411/api/v2/spans' }); provider.addSpanProcessor(new SimpleSpanProcessor(zipkinExporter)); provider.register(); const tracer = provider.getTracer(serviceName); import * as http from 'http'; import * as mongodb from 'mongodb'; let collection; const mongodbConnect = async () => { try { const client = await mongodb.MongoClient.connect('mongodb://localhost:27017'); collection = client.db('test-db').collection('users'); console.log('\nSuccessfully connected to mongoDB!\n'); } catch (err) { console.log(`Error while connecting to mongoDB ${err}`, err); throw err; } }; mongodbConnect(); http.createServer(function (_, res) { const doc = { name: 'Rick' }; collection.insertOne(doc, function () { collection.findOne({}, function () { res.end(); }); }); }).listen(9090);
The new mongodb.find span being generated as a child of the mongodb.insert span.
mongodb.find
mongodb.insert
It happens when a callback for a parent mongodb.insert operation is used.
When I'm using Promise.then instead of a callback a span for a find operation is generated as expected.
Promise.then
find
The following example works fine:
collection.insertOne(doc).then(function () { collection.findOne({}, function () { res.end(); }); });
The text was updated successfully, but these errors were encountered:
obecny
Successfully merging a pull request may close this issue.
What version of OpenTelemetry are you using?
What version of Node are you using?
12.20.0
What did you do?
What did you expect to see?
The new
mongodb.find
span being generated as a child of themongodb.insert
span.What did you see instead?
Additional context
It happens when a callback for a parent
mongodb.insert
operation is used.When I'm using
Promise.then
instead of a callback a span for afind
operation is generated as expected.The following example works fine:
The text was updated successfully, but these errors were encountered: