Skip to content

Commit 6b42264

Browse files
committed
Use HttpClient from opentelemetry-http crate
1 parent 7c6acb8 commit 6b42264

File tree

3 files changed

+19
-94
lines changed

3 files changed

+19
-94
lines changed

Cargo.toml

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,32 +19,32 @@ exclude = [
1919
]
2020

2121
[features]
22-
reqwest-blocking-client = ["reqwest", "reqwest/native-tls", "reqwest/blocking"]
23-
reqwest-blocking-client-rustls = ["reqwest", "reqwest/rustls-tls", "reqwest/blocking"]
24-
reqwest-client = ["reqwest", "reqwest/native-tls"]
25-
reqwest-client-rustls = ["reqwest", "reqwest/rustls-tls"]
26-
surf-client = ["surf"]
22+
reqwest-blocking-client = ["reqwest-client"]
23+
reqwest-blocking-client-rustls = ["reqwest-client-rustls"]
24+
reqwest-client = ["opentelemetry-http/reqwest", "reqwest/native-tls"]
25+
reqwest-client-rustls = ["opentelemetry-http/reqwest", "reqwest/rustls-tls"]
26+
surf-client = ["opentelemetry-http/surf"]
2727

2828
[dependencies]
2929
async-trait = "0.1"
30-
bytes = "1"
3130
chrono = "0.4"
3231
http = "0.2"
33-
thiserror = "1"
32+
once_cell = "1"
3433
opentelemetry = "0.14"
34+
opentelemetry-http = "0.3"
3535
opentelemetry-semantic-conventions = "0.6"
36-
reqwest = { version = "0.11", optional = true, default-features = false }
36+
reqwest = { version = "0.11", default-features = false, features = ["blocking"], optional = true }
3737
serde = { version = "1", features = ["derive"] }
3838
serde_json = "1"
39-
surf = { version = "2", optional = true }
40-
once_cell = "1"
39+
thiserror = "1"
4140

4241
[dev-dependencies]
4342
async-std = { version = "1.9.0", features = ["attributes"] }
4443
backtrace = "0.3.56"
4544
env_logger = "0.8.3"
4645
opentelemetry = { version = "0.14.0", features = ["rt-tokio"] }
4746
opentelemetry-application-insights = { path = ".", features = ["reqwest-client", "reqwest-blocking-client"] }
47+
surf = "2"
4848
test-case = "1.1.0"
4949
tokio = { version = "1.6.0", features = ["rt", "macros", "process", "time"] }
5050
version-sync = "0.9.2"
@@ -57,15 +57,15 @@ github = { repository = "frigus02/opentelemetry-application-insights", workflow
5757

5858
[[example]]
5959
name = "attributes"
60-
required-features = ["reqwest-blocking-client"]
60+
required-features = ["reqwest-client"]
6161

6262
[[example]]
6363
name = "http_client_reqwest"
6464
required-features = ["reqwest-client", "opentelemetry/rt-tokio"]
6565

6666
[[example]]
6767
name = "http_client_reqwest_blocking"
68-
required-features = ["reqwest-blocking-client"]
68+
required-features = ["reqwest-client"]
6969

7070
[[example]]
7171
name = "http_client_surf"

src/http_client.rs

Lines changed: 0 additions & 75 deletions
This file was deleted.

src/lib.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,16 +55,17 @@
5555
//! ## Features
5656
//!
5757
//! In order to support different async runtimes, the exporter requires you to specify an HTTP
58-
//! client that works with your chosen runtime. This crate comes with support for:
58+
//! client that works with your chosen runtime. The [`opentelemetry-http`] crate comes with support
59+
//! for:
5960
//!
6061
//! - [`surf`] for [`async-std`]: enable the **surf-client** and **opentelemetry/rt-async-std**
6162
//! features and configure the exporter with `with_client(surf::Client::new())`.
62-
//! - [`reqwest`] for [`tokio`]: enable the **reqwest-client** and **opentelemetry/rt-tokio** features
63-
//! and configure the exporter with `with_client(reqwest::Client::new())`.
64-
//! - [`reqwest`] for synchronous exports: enable the **reqwest-blocking-client** feature and
65-
//! configure the exporter with `with_client(reqwest::blocking::Client::new())`.
63+
//! - [`reqwest`] for [`tokio`]: enable the **reqwest-client** and **opentelemetry/rt-tokio**
64+
//! features and configure the exporter with either `with_client(reqwest::Client::new())` or
65+
//! `with_client(reqwest::blocking::Client::new())`.
6666
//!
6767
//! [`async-std`]: https://crates.io/crates/async-std
68+
//! [`opentelemetry-http`]: https://crates.io/crates/opentelemetry-http
6869
//! [`reqwest`]: https://crates.io/crates/reqwest
6970
//! [`surf`]: https://crates.io/crates/surf
7071
//! [`tokio`]: https://crates.io/crates/tokio
@@ -151,14 +152,12 @@
151152
#![cfg_attr(test, deny(warnings))]
152153

153154
mod convert;
154-
mod http_client;
155155
mod models;
156156
mod tags;
157157
mod uploader;
158158

159159
use async_trait::async_trait;
160160
use convert::{attrs_to_properties, duration_to_string, span_id_to_string, time_to_string};
161-
pub use http_client::HttpClient;
162161
pub use models::context_tag_keys::attrs;
163162
use models::{
164163
Data, Envelope, ExceptionData, ExceptionDetails, LimitedLenString1024, MessageData, Properties,
@@ -177,6 +176,7 @@ use opentelemetry::{
177176
trace::{Event, SpanKind, StatusCode, TracerProvider},
178177
Key, Value,
179178
};
179+
pub use opentelemetry_http::HttpClient;
180180
use opentelemetry_semantic_conventions as semcov;
181181
use std::{borrow::Cow, collections::HashMap, convert::TryInto, error::Error as StdError};
182182
use tags::{get_tags_for_event, get_tags_for_span};

0 commit comments

Comments
 (0)