Skip to content
This repository has been archived by the owner on Dec 8, 2022. It is now read-only.

Edit nodejs tutorial #7

Open
MarckK opened this issue Dec 13, 2017 · 2 comments
Open

Edit nodejs tutorial #7

MarckK opened this issue Dec 13, 2017 · 2 comments

Comments

@MarckK
Copy link
Contributor

MarckK commented Dec 13, 2017

The nodejs tutorial should more closely match the python tutorial, which is excellent.

See WIP.

@MarckK
Copy link
Contributor Author

MarckK commented Jan 2, 2018

As discussed with @pavolloffay, it would be great to have a context manager in js. As a step in that direction, I am trying to wrap the function in lesson01 in a promise and then close the tracer when the promise settles -- instead of having a 12 sec timeout at the end, which is a bit much.

But both of the implementations I've come up with are problematic:

const makePromise = (func, ...args) => {
  return new Promise(function(resolve, reject) {
    resolve(func(...args));
  });
};
makePromise(sayHello, helloTo).then(closeTracer);

The above closes the tracer right away; the logs show, but the data is not being sent to the Jaeger backend as no traces show in the UI.

const manageTracer = (func, ...args) => {
  return new Promise(function(resolve, reject) {
    return func(...args, function(err, result) {
      return err ? reject(err) : resolve();
    });
  });
};
manageTracer(sayHello, helloTo)
  .then(closeTracer)
  .catch(console.log);

The above never closes the tracer. The logs show and the trace displays in the UI.

For both, const closeTracer = () => tracer.close();

@yurishkuro
Copy link
Owner

The issue is this one, I think - jaegertracing/jaeger-client-node#157.

Simply calling tracer.Close() is not going to work, you need to call it in an async manner, with a callback, but because of the above issue even when reporter.close() is called with a callback it does not guarantee that the sender has flushed the spans.

# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants