Skip to content

feat(otlp): Allow to provide http client wrapped in Arc for user#3468

Open
DoumanAsh wants to merge 4 commits intoopen-telemetry:mainfrom
DoumanAsh:improve_exporter_config
Open

feat(otlp): Allow to provide http client wrapped in Arc for user#3468
DoumanAsh wants to merge 4 commits intoopen-telemetry:mainfrom
DoumanAsh:improve_exporter_config

Conversation

@DoumanAsh
Copy link
Copy Markdown
Contributor

Fixes #3467

Changes

This allows user to provide Arc wrapped client directly.
I initially thought it would be better to allow HttpClient to be Clone-able, but seeing as internally it is wrapped into Arc, I decided to allow user to do it himself so that it is possible for user to re-use this client when setting up multiple exporters

Merge requirement checklist

  • CONTRIBUTING guidelines followed
  • Unit tests added/updated (if applicable)
  • Appropriate CHANGELOG.md files updated for non-trivial, user-facing changes
  • Changes in public API reviewed (if applicable)

@DoumanAsh DoumanAsh requested a review from a team as a code owner April 23, 2026 12:58
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 23, 2026

Codecov Report

❌ Patch coverage is 92.30769% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 83.6%. Comparing base (146376f) to head (fce0ada).

Files with missing lines Patch % Lines
opentelemetry-zipkin/src/exporter/mod.rs 0.0% 2 Missing ⚠️
Additional details and impacted files
@@          Coverage Diff          @@
##            main   #3468   +/-   ##
=====================================
  Coverage   83.5%   83.6%           
=====================================
  Files        127     127           
  Lines      25241   25255   +14     
=====================================
+ Hits       21091   21123   +32     
+ Misses      4150    4132   -18     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@DoumanAsh DoumanAsh force-pushed the improve_exporter_config branch from 137b17c to 05851cc Compare April 23, 2026 13:08
@scottgerring
Copy link
Copy Markdown
Member

scottgerring commented Apr 29, 2026

Hey @DoumanAsh thanks for raising this; it is a nice improvement to be able to re-use a HTTP client.

Could you:

  • add an entry in the changelog in opentelemetry-otlp
  • add a brief test that shows that the Arc<MyClient> is accepted, as well as MyClient

This is technically a breaking change, but I had a hunt for other impls of WithHttpClient external to this project and came up empty handed.

I note that zipkin has a similar-shaped with_http_client too but I think small PRs are the goal so we should leave it be.

@@ -771,7 +771,10 @@ impl HasHttpConfig for HttpExporterBuilder {
/// ```
pub trait WithHttpConfig {
/// Assign client implementation
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be good to clarify that this can now take an Arc (or not), allowing the user to re-use HTTP clients if they so desire

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated documentation adding doc test that illustrates both usages (which also serves as way to verify it is not breaking change)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that since I didn't want to break interface, it would require Arc with concrete HttpClient

Having Arc<dyn HttpClient> would be better, but it would not be compatible with just passing HttpClient instance

@DoumanAsh DoumanAsh force-pushed the improve_exporter_config branch from 05851cc to c903548 Compare April 29, 2026 11:46
@DoumanAsh
Copy link
Copy Markdown
Contributor Author

It seems codecov doesn't count coverage from doc tests, so I guess I can create just unit test for it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Modify OTLP's WithHttpConfig to accept Into<Arc> to allow users to re-use HttpClients

2 participants