fix: OTEL HTTP exporter panic and mTLS support #7651
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This fixes two issues with the OTEL HTTP exporter:
The
opentelemetry_sdkBatchLogProcessorspawns a dedicated OS thread that usesfutures_executor::block_on()rather than tokio's runtime. When the async reqwest client's timeout mechanism callstokio::time::sleep(), it panics with "there is no reactor running, must be called from the context of a Tokio 1.x runtime".The fix is to use
reqwest::blocking::Clientinstead, which doesn't depend on tokio for timeouts. However, the blocking client creates its own internal tokio runtime during construction, which would panic if built from within an async context. We wrap the construction intokio::task::block_in_place()to handle this.The HTTP client wasn't properly configured for mTLS, matching the fixes previously done for the model provider client:
.tls_built_in_root_certs(false)when using a custom CA certificate to ensure only our CA is trusted.https_only(true)when using client identityrustls-tlsfeature to ensure rustls is used (required forIdentity::from_pem()to work correctly)