zipkin-js icon indicating copy to clipboard operation
zipkin-js copied to clipboard

context lost when tracing mongodb?

Open hafeyang opened this issue 7 years ago • 6 comments

i focked this repo at https://github.com/hafeyang/zipkin-js/tree/master/packages/zipkin-instrumentation-mongodb

    ctxImpl.letContext(ctx, () => {
      const url = 'mongodb://localhost:27017/zipkin_test';
      MongoClient.connect(url, function(err, db) {
        const col = db.collection('somecollection');
        ctxImpl.letContext(ctx, () => {
          col.deleteMany({}, {}, function() {
            ctxImpl.letContext(ctx, () => {
              col.insertMany([{a: 1}, {a: 2}, {a: 3}], function() {
                db.close();
                const annotations = record.args.map(args => args[0]);
                annotations.forEach(a => console.log(a.traceId.traceId+" "+a.traceId.spanId+" "+a.traceId.parentId));
                console.log(annotations);
                done();
              });
            });
          });
        });
      });
    });

here is my test code , annotations logged and i found traceId changed,and i got 2 traceId.

may caused by context losing

detailed err description and code pls check https://github.com/hafeyang/zipkin-js/tree/master/packages/zipkin-instrumentation-mongodb

Thanks!

hafeyang avatar Apr 13 '17 10:04 hafeyang

anyone can pr mongodb instrumentation ? I am confused.

hafeyang avatar Apr 14 '17 16:04 hafeyang

Maybe do a github search to see if anyone else is making custom tracing for mongo using zipkin-js?

On 15 Apr 2017 12:03 am, "阳衡锋" [email protected] wrote:

anyone can pr mongodb instruments ? I am confused.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/openzipkin/zipkin-js/issues/101#issuecomment-294180518, or mute the thread https://github.com/notifications/unsubscribe-auth/AAD616TgJUWkWFu4UQ_e9c2uYl3LhdKcks5rv5i2gaJpZM4M8iNL .

codefromthecrypt avatar Apr 15 '17 06:04 codefromthecrypt

I looked around and found almost universally people are instrumenting mongodb with a shimmer of some sort.

codefromthecrypt avatar Apr 16 '17 05:04 codefromthecrypt

@adriancole

  1. what do you mean by a shimmer of some sort?
  2. do you think this project would be a good option for zipkin-mongo instrumentation? https://github.com/abesto/zipkin-mongodb

Thanks!

embs avatar Nov 13 '17 14:11 embs

Worth to revisit this @adriancole ?

jcchavezs avatar Jul 21 '19 17:07 jcchavezs

keep open for now as I have another topic we need to resolve which is explicit use of contexts inside instrumentation (ex tracer.record(id, annotation)) which can help guarantee less loss of events.

codefromthecrypt avatar Jul 21 '19 23:07 codefromthecrypt