Skip to content

Commit

Permalink
metrics-exporter-prometheus: use hyper-rustls (#489)
Browse files Browse the repository at this point in the history
  • Loading branch information
tessus committed Jun 18, 2024
1 parent 4c002c4 commit 654c3a1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
4 changes: 2 additions & 2 deletions metrics-exporter-prometheus/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ async-runtime = ["tokio", "hyper-util/tokio"]
http-listener = ["async-runtime", "ipnet", "tracing", "_hyper-server"]
push-gateway = ["async-runtime", "tracing", "_hyper-client"]
_hyper-server = ["http-body-util", "hyper/server", "hyper-util/server-auto"]
_hyper-client = ["http-body-util", "hyper/client", "hyper-util/client", "hyper-util/http1", "hyper-util/client-legacy", "hyper-tls"]
_hyper-client = ["http-body-util", "hyper/client", "hyper-util/client", "hyper-util/http1", "hyper-util/client-legacy", "hyper-rustls"]

[dependencies]
metrics = { version = "^0.23", path = "../metrics" }
Expand All @@ -39,7 +39,7 @@ http-body-util = { version = "0.1.0", optional = true }
ipnet = { version = "2", optional = true }
tokio = { version = "1", features = ["rt", "net", "time", "rt-multi-thread"], optional = true }
tracing = { version = "0.1.26", optional = true }
hyper-tls = { version = "0.6.0", optional = true }
hyper-rustls = { version = "0.27.2", optional = true }

[dev-dependencies]
tracing = "0.1"
Expand Down
8 changes: 6 additions & 2 deletions metrics-exporter-prometheus/src/exporter/push_gateway.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ use std::time::Duration;
use http_body_util::{BodyExt, Collected, Full};
use hyper::body::Bytes;
use hyper::{header::HeaderValue, Method, Request, Uri};
use hyper_tls::HttpsConnector;
use hyper_util::{client::legacy::Client, rt::TokioExecutor};
use tracing::error;

Expand All @@ -19,7 +18,12 @@ pub(super) fn new_push_gateway(
handle: PrometheusHandle,
) -> ExporterFuture {
Box::pin(async move {
let https = HttpsConnector::new();
let https = hyper_rustls::HttpsConnectorBuilder::new()
.with_native_roots()
.expect("no native root CA certificates found")
.https_or_http()
.enable_http1()
.build();
let client: Client<_, Full<Bytes>> = Client::builder(TokioExecutor::new())
.pool_idle_timeout(Duration::from_secs(30))
.build(https);
Expand Down

0 comments on commit 654c3a1

Please sign in to comment.