chore: cargo fmt

Signed-off-by: Dennis Zhuang <killme2008@gmail.com>
This commit is contained in:
Dennis Zhuang
2026-08-17 22:38:20 +08:00
parent fe6f2c7433
commit 9e2bf8781a
5 changed files with 29 additions and 19 deletions
+8 -3
View File
@@ -986,7 +986,13 @@ mod tests {
.collect();
assert_eq!(
types,
vec!["container", "host", "k8s.pod", "service", "service.instance"]
vec![
"container",
"host",
"k8s.pod",
"service",
"service.instance"
]
);
// host identity is host.id only; host.name stays descriptive
assert_eq!(declarations[1].id_columns, vec!["host.id"]);
@@ -1027,8 +1033,7 @@ mod tests {
let mut stamps = OTEL_STAMPS.to_vec();
stamps.push((PHYSICAL_TABLE_METADATA_KEY, "true"));
assert!(
sorted_declarations(&prom_table_info("otel_resource_info", labels, &stamps))
.is_empty()
sorted_declarations(&prom_table_info("otel_resource_info", labels, &stamps)).is_empty()
);
// drift guard: the ingestion-side table name must stay whitelisted
assert!(
+9 -3
View File
@@ -129,8 +129,12 @@ impl OpenTelemetryProtocolHandler for Instance {
self.check_row_insert_permission(&requests, &ctx, PermissionReq::Action(OTLP_WRITE))
.context(AuthSnafu)?;
if let Some(resource_info) = &resource_info {
self.check_row_insert_permission(resource_info, &ctx, PermissionReq::Action(OTLP_WRITE))
.context(AuthSnafu)?;
self.check_row_insert_permission(
resource_info,
&ctx,
PermissionReq::Action(OTLP_WRITE),
)
.context(AuthSnafu)?;
}
self.cache_otlp_legacy(&input_names, &ctx, is_legacy)?;
OTLP_METRICS_ROWS.inc_by(rows as u64);
@@ -175,7 +179,9 @@ impl OpenTelemetryProtocolHandler for Instance {
// warning.
let mut warning = None;
if let Some(resource_info) = resource_info
&& let Err(e) = self.handle_row_inserts(resource_info, ctx, false, false).await
&& let Err(e) = self
.handle_row_inserts(resource_info, ctx, false, false)
.await
{
OTLP_RESOURCE_INFO_WRITE_ERRORS.inc();
common_telemetry::warn!(e; "Failed to write the OTLP resource descriptor table");
@@ -291,9 +291,7 @@ mod tests {
.contains("descriptive_rest")
);
// the otel map runs through the same per-table validation
assert!(
err("", "", "t: [{entity: hosts, id: [x]}]").contains("unknown entity type")
);
assert!(err("", "", "t: [{entity: hosts, id: [x]}]").contains("unknown entity type"));
// Unknown YAML keys are rejected, catching typos in the embedded file.
assert!(
parse(&broken(
+7 -9
View File
@@ -1004,8 +1004,7 @@ mod tests {
vec![keyvalue("service.name", "api"), keyvalue("host.id", "h-1")],
"my_gauge",
);
let conversion =
to_grpc_insert_requests(request, &mut OtlpMetricCtx::default()).unwrap();
let conversion = to_grpc_insert_requests(request, &mut OtlpMetricCtx::default()).unwrap();
// descriptor keeps raw OTel keys while the metric table's labels went
// through the (default underscore-escaping) translation strategy
@@ -1022,7 +1021,10 @@ mod tests {
let decoded = decode(&conversion.semantic_index);
let t = &decoded[OTEL_RESOURCE_INFO_TABLE_NAME];
assert_eq!(t.get(SEMANTIC_METRIC_TYPE).map(String::as_str), Some("info"));
assert_eq!(
t.get(SEMANTIC_METRIC_TYPE).map(String::as_str),
Some("info")
);
assert_eq!(
t.get(SEMANTIC_METRIC_METADATA_QUALITY).map(String::as_str),
Some("declared")
@@ -1048,8 +1050,7 @@ mod tests {
vec![keyvalue("service.name", "api")],
OTEL_RESOURCE_INFO_TABLE_NAME,
);
let conversion =
to_grpc_insert_requests(request, &mut OtlpMetricCtx::default()).unwrap();
let conversion = to_grpc_insert_requests(request, &mut OtlpMetricCtx::default()).unwrap();
assert!(conversion.resource_info.is_none());
// the metric itself still goes through the main path
assert!(
@@ -1112,10 +1113,7 @@ mod tests {
is_legacy: true,
..Default::default()
};
let mut attrs = vec![
keyvalue("service.name", "api"),
keyvalue("host.id", "h-1"),
];
let mut attrs = vec![keyvalue("service.name", "api"), keyvalue("host.id", "h-1")];
process_resource_attrs(&mut attrs, &ctx);
assert_eq!(attr_value(&attrs, "job"), None);
assert_eq!(attr_value(&attrs, "host.id").as_deref(), Some("h-1"));
@@ -92,7 +92,10 @@ impl ResourceInfoData {
return;
}
let entry = self.rows.entry(tags.into_iter().collect()).or_insert(i64::MIN);
let entry = self
.rows
.entry(tags.into_iter().collect())
.or_insert(i64::MIN);
*entry = (*entry).max(max_ts_nanos);
}