Skip to content

Commit d67c052

Browse files
committed
fix(otlp): move resource host into metric context
Consume the resource-derived OTLP host String into MetaString instead of copying from a borrowed str before metric translation. This keeps default host cloning cheap and avoids one allocation for explicit resource hosts.
1 parent 0fb949b commit d67c052

1 file changed

Lines changed: 6 additions & 8 deletions

File tree

lib/saluki-components/src/sources/otlp/metrics/translator.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -419,14 +419,12 @@ impl OtlpMetricsTranslator {
419419
let attribute_tags = self.attribute_translator.tags_from_attributes(&resource.attributes);
420420

421421
// TODO: https://github.com/DataDog/datadog-agent/blob/main/pkg/opentelemetry-mapping-go/otlp/metrics/metrics_translator.go#L736-L753
422-
let host = if let Some(Source {
423-
kind: SourceKind::HostnameKind,
424-
identifier,
425-
}) = &source
426-
{
427-
MetaString::from(identifier.as_str())
428-
} else {
429-
self.default_hostname.clone()
422+
let host = match source {
423+
Some(Source {
424+
kind: SourceKind::HostnameKind,
425+
identifier,
426+
}) => MetaString::from(identifier),
427+
_ => self.default_hostname.clone(),
430428
};
431429

432430
for scope_metrics in resource_metrics.scope_metrics {

0 commit comments

Comments
 (0)