feat: make jaeger-debug-id configurable

pull/24376/head
Marco Neumann 2021-12-01 15:02:15 +01:00
parent c961454dcd
commit 4bbe756b52
3 changed files with 16 additions and 15 deletions

View File

@ -100,10 +100,13 @@ pub struct Client {
pub url: String,
auth_header: Option<String>,
reqwest: reqwest::Client,
jaeger_debug: bool,
jaeger_debug_header: Option<String>,
}
impl Client {
/// Default [jaeger debug header](Self::with_jaeger_debug) that should work in many environments.
pub const DEFAULT_JAEGER_DEBUG_HEADER: &'static str = "jaeger-debug-id";
/// Create a new client pointing to the URL specified in
/// `protocol://server:port` format and using the specified token for
/// authorization.
@ -125,14 +128,14 @@ impl Client {
url: url.into(),
auth_header,
reqwest: reqwest::Client::new(),
jaeger_debug: false,
jaeger_debug_header: None,
}
}
/// Enable generation of `jaeger-debug-id` headers.
pub fn with_jaeger_debug(self) -> Self {
/// Enable generation of jaeger debug headers with the given header name.
pub fn with_jaeger_debug(self, header: String) -> Self {
Self {
jaeger_debug: true,
jaeger_debug_header: Some(header),
..self
}
}
@ -144,11 +147,8 @@ impl Client {
if let Some(auth) = &self.auth_header {
req = req.header("Authorization", auth);
}
if self.jaeger_debug {
req = req.header(
"jaeger-debug-id",
format!("influxdb_client-{}", uuid::Uuid::new_v4()),
);
if let Some(header) = &self.jaeger_debug_header {
req = req.header(header, format!("influxdb_client-{}", uuid::Uuid::new_v4()));
}
req

View File

@ -142,7 +142,8 @@ Logging:
.arg(
Arg::with_name("jaeger_debug")
.long("jaeger_debug")
.help("Generate `jaeger-debug-id` headers during write")
.help("Generate jaeger debug header with given key during write")
.takes_value(true)
)
.get_matches();
@ -203,7 +204,7 @@ Logging:
token,
create_bucket,
org_id,
matches.is_present("jaeger_debug"),
matches.value_of("jaeger_debug"),
)
.await?
} else if matches.is_present("PRINT") {

View File

@ -118,7 +118,7 @@ impl PointsWriterBuilder {
token: impl Into<String> + Send,
create_bucket: bool,
org_id: Option<&str>,
jaeger_debug: bool,
jaeger_debug: Option<&str>,
) -> Result<Self> {
let host = host.into();
@ -132,8 +132,8 @@ impl PointsWriterBuilder {
};
let mut client = influxdb2_client::Client::new(host, token.into());
if jaeger_debug {
client = client.with_jaeger_debug();
if let Some(header) = jaeger_debug {
client = client.with_jaeger_debug(header.to_string());
}
let org = org.into();
let bucket = bucket.into();