span.is_recording() — to avoid unnecessary work on non-recording spans.

-
SimpleSpanProcessor
- Forwards each finished span immediately to the configured exporter.
- Great for local development and debugging because spans appear right away.
- Not ideal for high-volume production workloads: every finished span triggers an export call.
-
BatchSpanProcessor
- Buffers spans in memory and exports them as batches (on a timer or when buffer thresholds are met).
- Much more efficient for production and recommended as the default.
BatchSpanProcessor is generally recommended for production because it minimizes export overhead. Use SimpleSpanProcessor for learning, debugging, or when you need immediate visibility of spans.
| Exporter | Purpose / Use case | Notes / Examples |
|---|---|---|
| ConsoleSpanExporter | Print spans to stdout for debugging | Quick feedback during development |
| OTLP exporters | Send spans using the OTLP protocol | Use with OpenTelemetry Collector or OTLP-compatible backends (OTLP protocol) |
| JaegerExporter | Send spans to Jaeger | Use when your observability backend is Jaeger (Jaeger) |
| ZipkinExporter | Send spans to Zipkin | Use when your backend is Zipkin (Zipkin) |
- export(spans): Send a batch of spans to the configured destination (BatchSpanProcessor calls this automatically).
- shutdown(): Stop exporting and release resources. Call during application termination to avoid losing telemetry.
- force_flush() / forceFlush(): Attempt to immediately export any buffered spans, bypassing normal batching.

- Tracer: creates spans as your application instrumentations run.
- Processor: observes span lifecycle events (onStart/onEnd). SimpleSpanProcessor exports immediately; BatchSpanProcessor buffers and exports in batches (recommended for production).
- Exporter: formats and transmits spans to a destination (console, OTLP, Jaeger, Zipkin, etc.). Use
force_flush()andshutdown()to ensure reliable delivery at shutdown.

- Use BatchSpanProcessor for production to reduce network and CPU overhead.
- Configure exporter timeouts and retry policies (when supported) to handle transient failures.
- Always call
shutdown()(or ensure the SDK does so) during graceful shutdown to minimize data loss. - If you need telemetry routing, enrichment, or buffering across services, send spans to an OpenTelemetry Collector using OTLP and let the Collector forward to your backends.
Be sure to call exporter
shutdown() or use force_flush() on application shutdown. Failing to flush buffered spans can result in lost telemetry.- OpenTelemetry Collector
- OTLP protocol
- Kubernetes Observability patterns and the OpenTelemetry Collector
- Jaeger Tracing
- Zipkin