Open MarckK opened 6 years ago
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();
The issue is this one, I think - https://github.com/jaegertracing/jaeger-client-node/issues/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.
The nodejs tutorial should more closely match the python tutorial, which is excellent.
See WIP.