Skip to content

Commit 650ac18

Browse files
committed
docs: clarify OTLP HTTP client runtime compatibility
1 parent dfdc478 commit 650ac18

6 files changed

Lines changed: 61 additions & 7 deletions

File tree

opentelemetry-otlp/Cargo.toml

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,25 @@ http-proto = ["prost", "opentelemetry-http", "opentelemetry-proto/gen-tonic-mess
9797
experimental-http-retry = ["opentelemetry_sdk/experimental_async_runtime", "opentelemetry_sdk/rt-tokio", "tokio", "httpdate"]
9898

9999
http-json = ["serde_json", "prost", "opentelemetry-http", "opentelemetry-proto/gen-tonic-messages", "opentelemetry-proto/with-serde", "http", "trace", "metrics"]
100+
101+
#
102+
# HTTP clients
103+
#
104+
# Most users should use the default reqwest-blocking-client. It is compatible
105+
# with the SDK's default BatchSpanProcessor, BatchLogProcessor, and
106+
# PeriodicReader, including applications that run on Tokio.
100107
reqwest-blocking-client = ["reqwest/blocking", "opentelemetry-http/reqwest-blocking"]
108+
109+
# Async HTTP clients. Do not enable these for the default SDK
110+
# processors/readers; they require an export path that is driven by a Tokio
111+
# runtime, such as the experimental async-runtime processors/readers.
101112
reqwest-client = ["reqwest", "opentelemetry-http/reqwest"]
113+
hyper-client = ["opentelemetry-http/hyper"]
114+
115+
# TLS options for reqwest-based HTTP clients, both blocking and async. Combine
116+
# these with either reqwest-blocking-client or reqwest-client.
102117
reqwest-rustls = ["reqwest", "opentelemetry-http/reqwest-rustls"]
103118
reqwest-rustls-webpki-roots = ["reqwest", "opentelemetry-http/reqwest-rustls-webpki-roots"]
104-
hyper-client = ["opentelemetry-http/hyper"]
105119

106120
# test
107121
integration-testing = ["tonic", "prost", "tokio/full", "trace", "logs"]

opentelemetry-otlp/src/lib.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,8 @@
287287
//! * `gzip-http`: Use gzip compression for HTTP transport.
288288
//! * `zstd-http`: Use zstd compression for HTTP transport.
289289
//! * `reqwest-blocking-client`: Use reqwest blocking http client. This feature is enabled by default.
290-
//! * `reqwest-client`: Use reqwest http client.
290+
//! * `reqwest-client`: Use reqwest async http client.
291+
//! * `hyper-client`: Use hyper async http client.
291292
//! * `reqwest-rustls`: Use reqwest with TLS with system trust roots via `rustls-native-certs` crate.
292293
//! * `reqwest-rustls-webpki-roots`: Use reqwest with TLS with Mozilla's trust roots via `webpki-roots` crate.
293294
//!
@@ -510,6 +511,16 @@
510511
//! enabled by default). Supply your own client to control TLS, proxies, connection pooling, etc.
511512
//! The client must implement the [`opentelemetry_http::HttpClient`] trait.
512513
//!
514+
//! The standard SDK path uses the default `BatchSpanProcessor`,
515+
//! `BatchLogProcessor`, and `PeriodicReader`. These components run exports on
516+
//! SDK-owned background threads, so OTLP/HTTP should use the default
517+
//! `reqwest-blocking-client` with them.
518+
//!
519+
//! HTTP client selection is based on enabled crate features and is not aware of
520+
//! the SDK processor or metric reader that will drive the exporter. If you enable
521+
//! async HTTP clients such as `reqwest-client` or `hyper-client`, do not use them
522+
//! with the default batch processors or periodic reader.
523+
//!
513524
//! ```no_run
514525
//! # #[cfg(all(feature = "trace", feature = "http-proto", feature = "reqwest-client"))]
515526
//! # {

opentelemetry-sdk/src/logs/batch_log_processor.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,12 @@ type LogsData = Box<(SdkLogRecord, InstrumentationScope)>;
8787
/// - `grpc-tonic`: Requires `LoggerProvider` to be created within a tokio runtime.
8888
/// - `reqwest-blocking-client`: Works with a regular `main` or `tokio::main`.
8989
///
90-
/// In other words, other clients like `reqwest` and `hyper` are not supported.
90+
/// In other words, async HTTP clients like `reqwest-client` and `hyper-client`
91+
/// are not supported by this default processor. The OTLP HTTP exporter chooses
92+
/// its default HTTP client from enabled crate features and cannot tell which
93+
/// processor will drive it. If your dependency graph enables async HTTP client
94+
/// features, either pass an explicit blocking client for this processor or use
95+
/// the experimental async-runtime batch log processor.
9196
///
9297
/// `BatchLogProcessor` buffers logs in memory and exports them in batches. An
9398
/// export is triggered when `max_export_batch_size` is reached or every

opentelemetry-sdk/src/metrics/periodic_reader.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,13 @@ where
9090
/// - **`grpc-tonic`**: Requires [`MeterProvider`] to be initialized within a `tokio` runtime.
9191
/// - **`reqwest-blocking-client`**: Works with both a standard (`main`) function and `tokio::main`.
9292
///
93+
/// Async HTTP clients such as `reqwest-client` and `hyper-client` are not
94+
/// supported by this default reader. The OTLP HTTP exporter chooses its default
95+
/// HTTP client from enabled crate features and cannot tell which reader will
96+
/// drive it. If your dependency graph enables async HTTP client features, either
97+
/// pass an explicit blocking client for this reader or use the experimental
98+
/// async-runtime periodic reader.
99+
///
93100
/// [`PeriodicReader`] does **not** enforce a timeout for exports either. Instead,
94101
/// the configured exporter is responsible for enforcing timeouts. If an export operation
95102
/// never returns, [`PeriodicReader`] will **stop exporting new metrics**, stalling

opentelemetry-sdk/src/metrics/periodic_reader_with_async_runtime.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,8 @@ where
162162
/// The [runtime] can be selected based on feature flags set for this crate.
163163
///
164164
/// The exporter can be any exporter that implements [PushMetricExporter] such
165-
/// as [opentelemetry-otlp].
165+
/// as [opentelemetry-otlp]. Exporters that require a runtime should be used
166+
/// with a compatible [runtime].
166167
///
167168
/// [collect]: MetricReader::collect
168169
/// [runtime]: crate::runtime

opentelemetry-sdk/src/trace/span_processor.rs

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,11 @@ pub trait SpanProcessor: Send + Sync + std::fmt::Debug {
148148
/// spans must be emitted from a non-tokio runtime thread.
149149
/// - `reqwest-client`: TracerProvider may be created anywhere, but spans must be
150150
/// emitted from a tokio runtime thread.
151+
///
152+
/// The OTLP HTTP exporter chooses its default HTTP client from enabled crate
153+
/// features. That choice is not processor-aware. If you enable async HTTP
154+
/// clients such as `reqwest-client` or `hyper-client`, ensure this processor is
155+
/// only used from a thread where those clients can run.
151156
#[derive(Debug)]
152157
pub struct SimpleSpanProcessor<T: SpanExporter> {
153158
exporter: Mutex<T>,
@@ -222,8 +227,14 @@ impl<T: SpanExporter> SpanProcessor for SimpleSpanProcessor<T> {
222227
/// runtime.
223228
/// - `reqwest-blocking-client`: Works with a regular `main` or `tokio::main`.
224229
///
225-
/// In other words, other clients like `reqwest` and `hyper` are not supported.
226-
/// /// # Example
230+
/// In other words, async HTTP clients like `reqwest-client` and `hyper-client`
231+
/// are not supported by this default processor. The OTLP HTTP exporter chooses
232+
/// its default HTTP client from enabled crate features and cannot tell which
233+
/// processor will drive it. If your dependency graph enables async HTTP client
234+
/// features, either pass an explicit blocking client for this processor or use
235+
/// the experimental async-runtime batch span processor.
236+
///
237+
/// # Example
227238
///
228239
/// This example demonstrates how to configure and use the `BatchSpanProcessor`
229240
/// with a custom configuration. Note that a dedicated thread is used internally
@@ -301,7 +312,12 @@ enum BatchMessage {
301312
/// - `grpc-tonic`: Requires `TracerProvider` to be created within a tokio runtime.
302313
/// - `reqwest-blocking-client`: Works with a regular `main` or `tokio::main`.
303314
///
304-
/// In other words, other clients like `reqwest` and `hyper` are not supported.
315+
/// In other words, async HTTP clients like `reqwest-client` and `hyper-client`
316+
/// are not supported by this default processor. The OTLP HTTP exporter chooses
317+
/// its default HTTP client from enabled crate features and cannot tell which
318+
/// processor will drive it. If your dependency graph enables async HTTP client
319+
/// features, either pass an explicit blocking client for this processor or use
320+
/// the experimental async-runtime batch span processor.
305321
///
306322
/// `BatchSpanProcessor` buffers spans in memory and exports them in batches. An
307323
/// export is triggered when `max_export_batch_size` is reached or every

0 commit comments

Comments
 (0)