mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2026-09-08 14:39:10 +00:00
@@ -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!(
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user