Skip to content

Commit

Permalink
feat(rustls): support for rustls (#6)
Browse files Browse the repository at this point in the history
Adds the ability to use `rustls` for the `reqwest` internal dependency

fix Use rustls for reqwest #5
  • Loading branch information
robertohuertasm authored Nov 23, 2024
1 parent 315ae65 commit eea7f2f
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 6 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,7 @@ jobs:
run: cargo make format
- name: Run cargo clippy
run: cargo make clippy
- name: Run cargo test
- name: Run cargo test (default)
run: cargo test
- name: Run cargo test (tls)
run: cargo test -F tls --no-default-features
5 changes: 4 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
{
"cSpell.words": ["ddsource", "ddtags"]
"cSpell.words": ["ddsource", "ddtags"],
"rust-analyzer.cargo.features": []
// "rust-analyzer.cargo.features": ["tls"],
// "rust-analyzer.cargo.noDefaultFeatures": true
}
13 changes: 11 additions & 2 deletions dd-tracing-layer/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "dd-tracing-layer"
version = "0.4.0"
version = "0.5.0"
authors = ["Roberto Huertas <[email protected]>"]
description = "Send your logs to Datadog"
edition = "2021"
Expand All @@ -13,12 +13,21 @@ keywords = ["tracing", "log", "datadog", "layer", "tracing-subscriber"]
maintenance = { status = "actively-developed" }

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[features]
default = ["reqwest-default"]
tls = ["reqwest-tls"]

[dependencies]
log-tracing-layer = { path = "../log-tracing-layer", version = "0.4.0" }
tracing-subscriber = "0.3"
tracing = "0.1"
reqwest = { version = "0.12", features = ["gzip"] }
reqwest-default = { package = "reqwest", version = "0.12", features = [
"gzip",
], optional = true }
reqwest-tls = { package = "reqwest", version = "0.12", default-features = false, features = [
"gzip",
"rustls-tls",
], optional = true }
tokio = { version = "1", features = ["sync", "rt-multi-thread", "time"] }
serde_json = "1"
chrono = "0.4"
Expand Down
7 changes: 7 additions & 0 deletions dd-tracing-layer/src/datadog_ingestor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@ use async_recursion::async_recursion;
use async_trait::async_trait;
use chrono::Utc;
use log_tracing_layer::{Log, LogEvent, LogIngestor};

#[cfg(not(feature = "tls"))]
use reqwest_default as reqwest;

#[cfg(feature = "tls")]
use reqwest_tls as reqwest;

use serde_json::json;
use std::{collections::VecDeque, error::Error, io::Write, sync::Arc, time::Duration};
use tokio::sync::RwLock;
Expand Down
15 changes: 13 additions & 2 deletions nr-tracing-layer/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "nr-tracing-layer"
version = "0.4.0"
version = "0.5.0"
authors = ["Roberto Huertas <[email protected]>"]
description = "Send your logs to New Relic"
edition = "2021"
Expand All @@ -13,12 +13,23 @@ keywords = ["tracing", "log", "new-relic", "layer", "tracing-subscriber"]
maintenance = { status = "actively-developed" }

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[features]
default = ["reqwest-default"]
tls = ["reqwest-tls"]

[dependencies]
log-tracing-layer = { path = "../log-tracing-layer", version = "0.4.0" }
tracing-subscriber = "0.3"
tracing = "0.1"
reqwest = { version = "0.12", features = ["gzip"] }

reqwest-default = { package = "reqwest", version = "0.12", features = [
"gzip",
], optional = true }
reqwest-tls = { package = "reqwest", version = "0.12", default-features = false, features = [
"gzip",
"rustls-tls",
], optional = true }

tokio = { version = "1", features = ["sync", "rt-multi-thread", "time"] }
serde_json = "1"
chrono = "0.4"
Expand Down
6 changes: 6 additions & 0 deletions nr-tracing-layer/src/new_relic_ingestor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ use serde_json::json;
use std::{collections::VecDeque, error::Error, io::Write, sync::Arc, time::Duration};
use tokio::sync::RwLock;

#[cfg(not(feature = "tls"))]
use reqwest_default as reqwest;

#[cfg(feature = "tls")]
use reqwest_tls as reqwest;

const NR_SOURCE: &str = "nr-tracing-layer";
const MAX_BATCH_SIZE: usize = 1000;
const MAX_BATCH_DURATION_SECS: i64 = 5;
Expand Down

0 comments on commit eea7f2f

Please sign in to comment.