Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion opentelemetry-appender-log/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -687,7 +687,7 @@
) -> Result<(), Self::Error> {
let key = match key.serialize(ValueSerializer)? {
Some(AnyValue::String(key)) => Key::from(String::from(key)),
key => Key::from(format!("{:?}", key)),
key => Key::from(format!("{key:?}")),

Check warning on line 690 in opentelemetry-appender-log/src/lib.rs

View check run for this annotation

Codecov / codecov/patch

opentelemetry-appender-log/src/lib.rs#L690

Added line #L690 was not covered by tests
};

self.key = Some(key);
Expand Down
2 changes: 1 addition & 1 deletion opentelemetry-appender-tracing/benches/log-attributes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ fn create_benchmark(c: &mut Criterion, num_attributes: usize) {
let subscriber = Registry::default().with(ot_layer);

tracing::subscriber::with_default(subscriber, || {
c.bench_function(&format!("otel_{}_attributes", num_attributes), |b| {
c.bench_function(&format!("otel_{num_attributes}_attributes"), |b| {
b.iter(|| {
// Dynamically generate the error! macro call based on the number of attributes
match num_attributes {
Expand Down
2 changes: 1 addition & 1 deletion opentelemetry-appender-tracing/src/layer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ impl<LR: LogRecord> tracing::field::Visit for EventVisitor<'_, LR> {
return;
}
if field.name() == "message" {
self.log_record.set_body(format!("{:?}", value).into());
self.log_record.set_body(format!("{value:?}").into());
} else {
self.log_record
.add_attribute(Key::new(field.name()), AnyValue::from(format!("{value:?}")));
Expand Down
21 changes: 9 additions & 12 deletions opentelemetry-jaeger-propagator/src/propagator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ mod tests {
true,
TraceState::default(),
),
format!("{}:{}:0:1", LONG_TRACE_ID_STR, SPAN_ID_STR),
format!("{LONG_TRACE_ID_STR}:{SPAN_ID_STR}:0:1"),
),
(
SpanContext::new(
Expand All @@ -335,7 +335,7 @@ mod tests {
true,
TraceState::default(),
),
format!("{}:{}:0:0", LONG_TRACE_ID_STR, SPAN_ID_STR),
format!("{LONG_TRACE_ID_STR}:{SPAN_ID_STR}:0:0"),
),
(
SpanContext::new(
Expand All @@ -345,7 +345,7 @@ mod tests {
true,
TraceState::default(),
),
format!("{}:{}:0:3", LONG_TRACE_ID_STR, SPAN_ID_STR),
format!("{LONG_TRACE_ID_STR}:{SPAN_ID_STR}:0:3"),
),
]
}
Expand All @@ -356,7 +356,7 @@ mod tests {
let propagator = Propagator::with_custom_header(construct_header);
for (trace_id, span_id, flag, expected) in get_extract_data() {
let mut map: HashMap<String, String> = HashMap::new();
map.set(context_key, format!("{}:{}:0:{}", trace_id, span_id, flag));
map.set(context_key, format!("{trace_id}:{span_id}:0:{flag}"));
let context = propagator.extract(&map);
assert_eq!(context.span().span_context(), &expected);
}
Expand Down Expand Up @@ -392,7 +392,7 @@ mod tests {

// Propagators implement debug
assert_eq!(
format!("{:?}", default_propagator),
format!("{default_propagator:?}"),
format!(
"Propagator {{ baggage_prefix: \"{}\", header_name: \"{}\", fields: [\"{}\"] }}",
JAEGER_BAGGAGE_PREFIX, JAEGER_HEADER, JAEGER_HEADER
Expand Down Expand Up @@ -641,10 +641,7 @@ mod tests {
}
for (trace_id, span_id, flag, expected) in get_extract_data() {
let mut map: HashMap<String, String> = HashMap::new();
map.set(
JAEGER_HEADER,
format!("{}:{}:0:{}", trace_id, span_id, flag),
);
map.set(JAEGER_HEADER, format!("{trace_id}:{span_id}:0:{flag}"));
let context = propagator.extract(&map);
assert_eq!(context.span().span_context(), &expected);
}
Expand All @@ -655,7 +652,7 @@ mod tests {
let mut map: HashMap<String, String> = HashMap::new();
map.set(
JAEGER_HEADER,
format!("{}:{}:0:1:aa", LONG_TRACE_ID_STR, SPAN_ID_STR),
format!("{LONG_TRACE_ID_STR}:{SPAN_ID_STR}:0:1:aa"),
);
let propagator = Propagator::new();
let context = propagator.extract(&map);
Expand All @@ -667,7 +664,7 @@ mod tests {
let mut map: HashMap<String, String> = HashMap::new();
map.set(
JAEGER_HEADER,
format!("{}:{}:0:aa", LONG_TRACE_ID_STR, SPAN_ID_STR),
format!("{LONG_TRACE_ID_STR}:{SPAN_ID_STR}:0:aa"),
);
let propagator = Propagator::new();
let context = propagator.extract(&map);
Expand All @@ -679,7 +676,7 @@ mod tests {
let mut map: HashMap<String, String> = HashMap::new();
map.set(
JAEGER_HEADER,
format!("{}%3A{}%3A0%3A1", LONG_TRACE_ID_STR, SPAN_ID_STR),
format!("{LONG_TRACE_ID_STR}%3A{SPAN_ID_STR}%3A0%3A1"),
);
let propagator = Propagator::new();
let context = propagator.extract(&map);
Expand Down
6 changes: 3 additions & 3 deletions opentelemetry-otlp/examples/basic-otlp-http/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,15 +169,15 @@ async fn main() -> Result<(), Box<dyn Error + Send + Sync + 'static>> {
// Collect all shutdown errors
let mut shutdown_errors = Vec::new();
if let Err(e) = tracer_provider.shutdown() {
shutdown_errors.push(format!("tracer provider: {}", e));
shutdown_errors.push(format!("tracer provider: {e}"));
}

if let Err(e) = meter_provider.shutdown() {
shutdown_errors.push(format!("meter provider: {}", e));
shutdown_errors.push(format!("meter provider: {e}"));
}

if let Err(e) = logger_provider.shutdown() {
shutdown_errors.push(format!("logger provider: {}", e));
shutdown_errors.push(format!("logger provider: {e}"));
}

// Return an error if any shutdown failed
Expand Down
6 changes: 3 additions & 3 deletions opentelemetry-otlp/examples/basic-otlp/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,15 +162,15 @@ async fn main() -> Result<(), Box<dyn Error + Send + Sync + 'static>> {
// Collect all shutdown errors
let mut shutdown_errors = Vec::new();
if let Err(e) = tracer_provider.shutdown() {
shutdown_errors.push(format!("tracer provider: {}", e));
shutdown_errors.push(format!("tracer provider: {e}"));
}

if let Err(e) = meter_provider.shutdown() {
shutdown_errors.push(format!("meter provider: {}", e));
shutdown_errors.push(format!("meter provider: {e}"));
}

if let Err(e) = logger_provider.shutdown() {
shutdown_errors.push(format!("logger provider: {}", e));
shutdown_errors.push(format!("logger provider: {e}"));
}

// Return an error if any shutdown failed
Expand Down
4 changes: 2 additions & 2 deletions opentelemetry-otlp/src/exporter/http/logs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
let client = self
.client
.lock()
.map_err(|e| OTelSdkError::InternalFailure(format!("Mutex lock failed: {}", e)))?
.map_err(|e| OTelSdkError::InternalFailure(format!("Mutex lock failed: {e}")))?

Check warning on line 13 in opentelemetry-otlp/src/exporter/http/logs.rs

View check run for this annotation

Codecov / codecov/patch

opentelemetry-otlp/src/exporter/http/logs.rs#L13

Added line #L13 was not covered by tests
.clone()
.ok_or(OTelSdkError::AlreadyShutdown)?;

Expand Down Expand Up @@ -53,7 +53,7 @@

fn shutdown_with_timeout(&self, _timeout: time::Duration) -> OTelSdkResult {
let mut client_guard = self.client.lock().map_err(|e| {
OTelSdkError::InternalFailure(format!("Failed to acquire client lock: {}", e))
OTelSdkError::InternalFailure(format!("Failed to acquire client lock: {e}"))

Check warning on line 56 in opentelemetry-otlp/src/exporter/http/logs.rs

View check run for this annotation

Codecov / codecov/patch

opentelemetry-otlp/src/exporter/http/logs.rs#L56

Added line #L56 was not covered by tests
})?;

if client_guard.take().is_none() {
Expand Down
2 changes: 1 addition & 1 deletion opentelemetry-otlp/src/exporter/http/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
fn shutdown(&self) -> OTelSdkResult {
self.client
.lock()
.map_err(|e| OTelSdkError::InternalFailure(format!("Failed to acquire lock: {}", e)))?
.map_err(|e| OTelSdkError::InternalFailure(format!("Failed to acquire lock: {e}")))?

Check warning on line 65 in opentelemetry-otlp/src/exporter/http/metrics.rs

View check run for this annotation

Codecov / codecov/patch

opentelemetry-otlp/src/exporter/http/metrics.rs#L65

Added line #L65 was not covered by tests
.take();

Ok(())
Expand Down
14 changes: 4 additions & 10 deletions opentelemetry-otlp/src/exporter/http/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -615,17 +615,14 @@
assert_eq!(
headers.len(),
expected_headers.len(),
"Failed on input: {}",
input_str
"Failed on input: {input_str}"

Check warning on line 618 in opentelemetry-otlp/src/exporter/http/mod.rs

View check run for this annotation

Codecov / codecov/patch

opentelemetry-otlp/src/exporter/http/mod.rs#L618

Added line #L618 was not covered by tests
);

for (expected_key, expected_value) in expected_headers {
assert_eq!(
headers.get(&HeaderName::from_static(expected_key)),
Some(&HeaderValue::from_static(expected_value)),
"Failed on key: {} with input: {}",
expected_key,
input_str
"Failed on key: {expected_key} with input: {input_str}"

Check warning on line 625 in opentelemetry-otlp/src/exporter/http/mod.rs

View check run for this annotation

Codecov / codecov/patch

opentelemetry-otlp/src/exporter/http/mod.rs#L625

Added line #L625 was not covered by tests
);
}
}
Expand Down Expand Up @@ -665,17 +662,14 @@
assert_eq!(
headers.len(),
expected_headers.len(),
"Failed on input: {}",
input_str
"Failed on input: {input_str}"

Check warning on line 665 in opentelemetry-otlp/src/exporter/http/mod.rs

View check run for this annotation

Codecov / codecov/patch

opentelemetry-otlp/src/exporter/http/mod.rs#L665

Added line #L665 was not covered by tests
);

for (expected_key, expected_value) in expected_headers {
assert_eq!(
headers.get(&HeaderName::from_static(expected_key)),
Some(&HeaderValue::from_static(expected_value)),
"Failed on key: {} with input: {}",
expected_key,
input_str
"Failed on key: {expected_key} with input: {input_str}"

Check warning on line 672 in opentelemetry-otlp/src/exporter/http/mod.rs

View check run for this annotation

Codecov / codecov/patch

opentelemetry-otlp/src/exporter/http/mod.rs#L672

Added line #L672 was not covered by tests
);
}
}
Expand Down
4 changes: 2 additions & 2 deletions opentelemetry-otlp/src/exporter/http/trace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
let client = match self
.client
.lock()
.map_err(|e| OTelSdkError::InternalFailure(format!("Mutex lock failed: {}", e)))
.map_err(|e| OTelSdkError::InternalFailure(format!("Mutex lock failed: {e}")))

Check warning on line 16 in opentelemetry-otlp/src/exporter/http/trace.rs

View check run for this annotation

Codecov / codecov/patch

opentelemetry-otlp/src/exporter/http/trace.rs#L16

Added line #L16 was not covered by tests
.and_then(|g| match &*g {
Some(client) => Ok(Arc::clone(client)),
_ => Err(OTelSdkError::AlreadyShutdown),
Expand Down Expand Up @@ -65,7 +65,7 @@

fn shutdown(&mut self) -> OTelSdkResult {
let mut client_guard = self.client.lock().map_err(|e| {
OTelSdkError::InternalFailure(format!("Failed to acquire client lock: {}", e))
OTelSdkError::InternalFailure(format!("Failed to acquire client lock: {e}"))

Check warning on line 68 in opentelemetry-otlp/src/exporter/http/trace.rs

View check run for this annotation

Codecov / codecov/patch

opentelemetry-otlp/src/exporter/http/trace.rs#L68

Added line #L68 was not covered by tests
})?;

if client_guard.take().is_none() {
Expand Down
3 changes: 1 addition & 2 deletions opentelemetry-otlp/src/exporter/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -396,8 +396,7 @@
exporter_result,
Err(crate::exporter::ExporterBuildError::InvalidUri(_, _))
),
"Expected InvalidUri error, but got {:?}",
exporter_result
"Expected InvalidUri error, but got {exporter_result:?}"

Check warning on line 399 in opentelemetry-otlp/src/exporter/mod.rs

View check run for this annotation

Codecov / codecov/patch

opentelemetry-otlp/src/exporter/mod.rs#L399

Added line #L399 was not covered by tests
);
}

Expand Down
4 changes: 2 additions & 2 deletions opentelemetry-otlp/src/exporter/tonic/logs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
let (m, e, _) = inner
.interceptor
.call(Request::new(()))
.map_err(|e| OTelSdkError::InternalFailure(format!("error: {:?}", e)))?
.map_err(|e| OTelSdkError::InternalFailure(format!("error: {e:?}")))?

Check warning on line 66 in opentelemetry-otlp/src/exporter/tonic/logs.rs

View check run for this annotation

Codecov / codecov/patch

opentelemetry-otlp/src/exporter/tonic/logs.rs#L66

Added line #L66 was not covered by tests
.into_parts();
(inner.client.clone(), m, e)
}
Expand All @@ -88,7 +88,7 @@
Ok(())
}
Err(e) => {
let error = format!("export error: {:?}", e);
let error = format!("export error: {e:?}");

Check warning on line 91 in opentelemetry-otlp/src/exporter/tonic/logs.rs

View check run for this annotation

Codecov / codecov/patch

opentelemetry-otlp/src/exporter/tonic/logs.rs#L91

Added line #L91 was not covered by tests
otel_debug!(name: "TonicLogsClient.ExportFailed", error = &error);
Err(OTelSdkError::InternalFailure(error))
}
Expand Down
2 changes: 1 addition & 1 deletion opentelemetry-otlp/src/exporter/tonic/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@
fn shutdown(&self) -> OTelSdkResult {
self.inner
.lock()
.map_err(|e| OTelSdkError::InternalFailure(format!("Failed to acquire lock: {}", e)))?
.map_err(|e| OTelSdkError::InternalFailure(format!("Failed to acquire lock: {e}")))?

Check warning on line 104 in opentelemetry-otlp/src/exporter/tonic/metrics.rs

View check run for this annotation

Codecov / codecov/patch

opentelemetry-otlp/src/exporter/tonic/metrics.rs#L104

Added line #L104 was not covered by tests
.take();

Ok(())
Expand Down
2 changes: 1 addition & 1 deletion opentelemetry-otlp/src/exporter/tonic/trace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
.lock()
.await // tokio::sync::Mutex doesn't return a poisoned error, so we can safely use the interceptor here
.call(Request::new(()))
.map_err(|e| OTelSdkError::InternalFailure(format!("error: {:?}", e)))?
.map_err(|e| OTelSdkError::InternalFailure(format!("error: {e:?}")))?

Check warning on line 70 in opentelemetry-otlp/src/exporter/tonic/trace.rs

View check run for this annotation

Codecov / codecov/patch

opentelemetry-otlp/src/exporter/tonic/trace.rs#L70

Added line #L70 was not covered by tests
.into_parts();
(inner.client.clone(), m, e)
}
Expand Down
21 changes: 6 additions & 15 deletions opentelemetry-otlp/tests/integration_test/src/metric_helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,7 @@ pub fn assert_metrics_results_contains(expected_content: &str) -> Result<()> {
reader.read_to_string(&mut contents)?;
assert!(
contents.contains(expected_content),
"Expected content {} not found in actual content {}",
expected_content,
contents
"Expected content {expected_content} not found in actual content {contents}"
);
Ok(())
}
Expand Down Expand Up @@ -162,12 +160,7 @@ pub fn fetch_latest_metrics_for_scope(scope_name: &str) -> Result<Value> {
None
})
})
.with_context(|| {
format!(
"No valid JSON line containing scope `{}` found.",
scope_name
)
})?;
.with_context(|| format!("No valid JSON line containing scope `{scope_name}` found."))?;

Ok(json_line)
}
Expand All @@ -178,18 +171,16 @@ pub fn fetch_latest_metrics_for_scope(scope_name: &str) -> Result<Value> {
///
pub fn validate_metrics_against_results(scope_name: &str) -> Result<()> {
// Define the results file path
let results_file_path = format!("./expected/metrics/{}.json", scope_name);
let results_file_path = format!("./expected/metrics/{scope_name}.json");

// Fetch the actual metrics for the given scope
let actual_metrics = fetch_latest_metrics_for_scope(scope_name)
.context(format!("Failed to fetch metrics for scope: {}", scope_name))?;
.context(format!("Failed to fetch metrics for scope: {scope_name}"))?;

// Read the expected metrics from the results file
let expected_metrics = {
let file = File::open(&results_file_path).context(format!(
"Failed to open results file: {}",
results_file_path
))?;
let file = File::open(&results_file_path)
.context(format!("Failed to open results file: {results_file_path}"))?;
read_metrics_from_json(file)
}?;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ impl SpanForest {
}

if !spans.is_empty() {
panic!("found spans with invalid parent: {:?}", spans);
panic!("found spans with invalid parent: {spans:?}");
}

forest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ mod metrictests_roundtrip {
let metrics: MetricsData = serde_json::from_str(metrics_in)?;
let metrics_out = serde_json::to_string(&metrics)?;

println!("{:}", metrics_out);
println!("{metrics_out:}");

let metrics_in_json: Value = serde_json::from_str(metrics_in)?;
let metrics_out_json: Value = serde_json::from_str(&metrics_out)?;
Expand Down
2 changes: 1 addition & 1 deletion opentelemetry-otlp/tests/smoke.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ async fn smoke_tracer() {
opentelemetry_otlp::SpanExporter::builder()
.with_tonic()
.with_compression(opentelemetry_otlp::Compression::Gzip)
.with_endpoint(format!("http://{}", addr))
.with_endpoint(format!("http://{addr}"))
.with_metadata(metadata)
.build()
.expect("gzip-tonic SpanExporter failed to build"),
Expand Down
4 changes: 2 additions & 2 deletions opentelemetry-prometheus/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ pub(crate) fn get_unit_suffixes(unit: &str) -> Option<Cow<'static, str>> {
get_prom_per_unit(second),
) {
(true, _, Some(second_part)) | (false, None, Some(second_part)) => {
Some(Cow::Owned(format!("per_{}", second_part)))
Some(Cow::Owned(format!("per_{second_part}")))
}
(false, Some(first_part), Some(second_part)) => {
Some(Cow::Owned(format!("{}_per_{}", first_part, second_part)))
Some(Cow::Owned(format!("{first_part}_per_{second_part}")))
}
_ => None,
};
Expand Down
2 changes: 1 addition & 1 deletion opentelemetry-sdk/benches/batch_span_processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ fn criterion_benchmark(c: &mut Criterion) {

for task_num in [1, 2, 4, 8, 16, 32].iter() {
group.bench_with_input(
BenchmarkId::from_parameter(format!("with {} concurrent task", task_num)),
BenchmarkId::from_parameter(format!("with {task_num} concurrent task")),
task_num,
|b, &task_num| {
b.iter(|| {
Expand Down
Loading