Skip to content
This repository was archived by the owner on Jul 11, 2022. It is now read-only.

Commit d83b7b1

Browse files
obatakuyurishkuro
andauthored
Ensure Tracer.close() properly flushes finished but unsent spans (#294)
* assigning to Reporter._stopped in _flush() instead of close() avoids dropping those spans passed to report_span just _prior_ to Reporter.close() for which _report_span_from_ioloop will execute only *afterwards*; this way those scheduled callbacks will get a chance to run before _flush stops the reporter and those pending spans make it into the queue before the reporter shuts down. Signed-off-by: obataku <[email protected]> Co-authored-by: Yuri Shkuro <[email protected]>
1 parent 0e6beca commit d83b7b1

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

jaeger_client/reporter.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -215,13 +215,13 @@ def close(self):
215215
Ensure that all spans from the queue are submitted.
216216
Returns Future that will be completed once the queue is empty.
217217
"""
218-
with self.stop_lock:
219-
self.stopped = True
220-
221218
return ioloop_util.submit(self._flush, io_loop=self.io_loop)
222219

223220
@tornado.gen.coroutine
224221
def _flush(self):
222+
# stopping here ensures we don't lose spans from pending _report_span_from_ioloop callbacks
223+
with self.stop_lock:
224+
self.stopped = True
225225
yield self.queue.put(self.stop)
226226
yield self.queue.join()
227227

0 commit comments

Comments
 (0)