opentelemetry-python
opentelemetry-python copied to clipboard
PoC asyncio batch span processor
Quick concept of BatchSpanProcessor implemented with asyncio https://github.com/open-telemetry/opentelemetry-python/issues/3274. Not nearly as fleshed out as https://github.com/open-telemetry/opentelemetry-python/pull/3485 but could be offered in addition to that
This would work as a drop in for the current implementation and is thread safe. We could expose async functions on TracerProvider and an async SpanExporter which would could work entirely in one thread. Benefits of using asyncio:
- Queueing and exporting are all happening in a single thread, so handling concurrency is simplified
- Every BSP instance uses the same thread which may be less resource intensive. I think this is debatable without testing. Note
SpanExporter.export()
is run in a shared ThreadPoolExecutor, although we could introduce AsyncSpanExporter to avoid this (#3273) - Couroutines can be cancelled/timed out as opposed to threads, which is a big issue with the current BSP blocking shutdown. Again won't work great with existing blocking
SpanExporter.export()