mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2026-01-04 12:22:55 +00:00
fix: normalize otlp string keys (#2168)
This commit is contained in:
@@ -108,7 +108,7 @@ fn write_attribute(lines: &mut LinesWriter, attr: &KeyValue) -> Result<()> {
|
||||
if let Some(val) = attr.value.as_ref().and_then(|v| v.value.as_ref()) {
|
||||
match val {
|
||||
any_value::Value::StringValue(s) => lines
|
||||
.write_tag(&attr.key, s)
|
||||
.write_tag(&normalize_otlp_name(&attr.key), s)
|
||||
.context(error::OtlpMetricsWriteSnafu)?,
|
||||
|
||||
any_value::Value::IntValue(v) => lines
|
||||
|
||||
@@ -79,12 +79,12 @@ mod test {
|
||||
assert_eq!(
|
||||
recordbatches.pretty_print().unwrap(),
|
||||
"\
|
||||
+------------+-------+------------+---------------------+----------------+
|
||||
| resource | scope | host | greptime_timestamp | greptime_value |
|
||||
+------------+-------+------------+---------------------+----------------+
|
||||
| greptimedb | otel | testserver | 1970-01-01T00:00:00 | 105.0 |
|
||||
| greptimedb | otel | testsevrer | 1970-01-01T00:00:00 | 100.0 |
|
||||
+------------+-------+------------+---------------------+----------------+",
|
||||
+------------+-------+--------------------+------------+---------------------+----------------+
|
||||
| resource | scope | telemetry_sdk_name | host | greptime_timestamp | greptime_value |
|
||||
+------------+-------+--------------------+------------+---------------------+----------------+
|
||||
| greptimedb | otel | java | testserver | 1970-01-01T00:00:00 | 105.0 |
|
||||
| greptimedb | otel | java | testsevrer | 1970-01-01T00:00:00 | 100.0 |
|
||||
+------------+-------+--------------------+------------+---------------------+----------------+",
|
||||
);
|
||||
}
|
||||
|
||||
@@ -115,7 +115,10 @@ mod test {
|
||||
data: Some(metric::Data::Gauge(gauge)),
|
||||
}],
|
||||
scope: Some(InstrumentationScope {
|
||||
attributes: vec![keyvalue("scope", "otel")],
|
||||
attributes: vec![
|
||||
keyvalue("scope", "otel"),
|
||||
keyvalue("telemetry.sdk.name", "java"),
|
||||
],
|
||||
..Default::default()
|
||||
}),
|
||||
..Default::default()
|
||||
|
||||
Reference in New Issue
Block a user