Skip to content

Processor test suite gaps: no coverage for tokio-dependent exporters or runtime deadlock scenarios #3381

@bryantbiggs

Description

@bryantbiggs

Summary

While working on #3380 (fix for #2802), I noticed that the existing test suite for BatchSpanProcessor, BatchLogProcessor, and PeriodicReader has significant coverage gaps around tokio runtime interactions. The deadlock bug in #2802 went undetected because no tests exercise exporters that depend on tokio internals.

Gaps identified

1. All runtime-flavor tests use simple exporters

The existing #[tokio::test(flavor = "current_thread")] and #[tokio::test(flavor = "multi_thread", worker_threads = 1)] tests use MockSpanExporter, InMemoryLogExporter, and InMemoryMetricExporter — none of which call tokio::spawn, use tokio I/O, or otherwise depend on the tokio runtime context. These tests pass regardless of whether the runtime context is available on the processor's worker thread, so they cannot catch deadlocks like #2802.

PR #3380 adds initial regression tests with TokioSpawn*Exporter mocks for multi_thread(1), but coverage is still limited.

2. No shutdown() tests with tokio-dependent exporters

The original issue (#2802, reproduction in #3356 (comment)) documented deadlocks on both force_flush() and shutdown(). The regression tests in #3380 only cover force_flush(). The shutdown() path goes through similar code but has different timeout behavior (5s timeout vs. infinite hang) that should be verified.

3. No timeout or cancellation tests

  • force_flush() on current_thread runtime with tonic-like exporters hangs forever (recv() has no timeout)
  • shutdown() returns Err(Timeout(5s)) but the worker thread stays stuck
  • These scenarios aren't tested or documented

4. SimpleLogProcessor has ignored async exporter tests

Two tests in simple_log_processor are #[ignore]d:

  • test_simple_processor_async_exporter_with_all_runtime_worker_threads_blocked
  • test_simple_processor_async_exporter_with_current_thread_runtime

These suggest known but unaddressed issues with async exporters on constrained runtimes in the simple processor path.

5. No integration tests with real exporters

All processor tests use in-memory or mock exporters. There are no integration tests that exercise the actual OTLP/tonic export path against a mock collector, which is where deadlocks manifest in practice.

Suggested improvements

  • Add shutdown() regression tests with TokioSpawn*Exporter mocks for all three processors
  • Add tests verifying timeout behavior when export hangs (both force_flush and shutdown)
  • Investigate and un-ignore the SimpleLogProcessor async exporter tests
  • Consider adding integration tests with tonic exporter against a mock/in-process OTLP collector
  • Document the current_thread runtime limitation (exporters using tokio::spawn will deadlock when force_flush/shutdown blocks the only runtime thread)

Context

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions