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

PoC asyncio batch span processor

Open aabmass opened this issue 2 years ago • 1 comments

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()

aabmass avatar Oct 30 '23 21:10 aabmass

Hello, is there a way that I can help with this? It will be really nice to have async exporter.

mastizada avatar Aug 13 '24 15:08 mastizada

This is absolutely critical. Id love to help push this forward. Can we get someone from the OTEL python community to review this with us?

From my perspective, OTEL export will never run in production on an event loop until this solution is established

cpvandehey avatar Feb 20 '25 21:02 cpvandehey