opencensus-python icon indicating copy to clipboard operation
opencensus-python copied to clipboard

[azure exporter] Manual flushing of Tracer exporter

Open Willem-J-an opened this issue 2 years ago • 1 comments

Is your feature request related to a problem? When running in specific contexts, e.g. databricks; the atexit flush is not reliable. It only flushes the spans around 60% of the time.

Describe the solution you'd like. I would like to be able to manually flush the tracer exporter to ensure my spans are exported before letting my application exit.

Describe alternatives you've considered. tracer.finish() - Will not block until flushing has occured Retrieving active exporter threads and stopping them; thread.stop(timeout=x) Calling private _stop method on the tracer.exporter

Additional context. Discussed here

Willem-J-an avatar May 03 '23 11:05 Willem-J-an

The way this currently works relies on the opencensus.common.schedule.Queue object and specifically the _gets method. Here's what I have found. The _gets is always operating in the worker thread. It only exits when either the count reaches the max_batch_size, export_interval time has elapsed, or a QueueEvent is queued. I tried flushing the queue with exporter._queue.flush(). This inserts a SYNC queue event, but still does not interrupt the _gets for some reason. Will continue to explore options.

jeremydvoss avatar Jun 20 '23 23:06 jeremydvoss