From 72db55233efc36b120807b31f899199226630227 Mon Sep 17 00:00:00 2001 From: Pratik Mankawde <3397372+pratikmankawde@users.noreply.github.com> Date: Tue, 14 Jul 2026 18:28:39 +0100 Subject: [PATCH] fix(telemetry): guard legend-group build against empty-string attributes The transform/legendgroups guards checked only != nil. The perf-iac collector stamps xrpl.branch / xrpl.node.role / xrpl.work.item with an empty-string default (work_item | default('')) when a run has no work item, and an empty string is not nil. OTTL Concat renders a stray separator for an empty element, so an all-empty perf-iac stamp would have produced iac_group="--". Add != "" to every presence guard (iac_group sources, service.instance.id, xrpl.network.type) so a group is built only from genuinely-present values and left unset otherwise. Verified on a live collector: empty-string perf-iac attrs leave iac_group absent. Co-Authored-By: Claude Opus 4.8 (1M context) --- docker/telemetry/otel-collector-config.yaml | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/docker/telemetry/otel-collector-config.yaml b/docker/telemetry/otel-collector-config.yaml index 4f88fa7434..23f3a533b7 100644 --- a/docker/telemetry/otel-collector-config.yaml +++ b/docker/telemetry/otel-collector-config.yaml @@ -71,15 +71,18 @@ processors: # - resource_group: node id, optionally suffixed with network type. The id # is always present; network may be absent, so it is appended separately # to avoid a trailing separator. - # Concat is guarded on presence because OTTL Concat renders the literal text - # "" for an absent attribute (it does not skip it). + # Concat is guarded on presence (!= nil and != "") because OTTL Concat renders + # the literal text "" for an absent attribute and would emit a stray + # separator for an empty one. The perf-iac collector stamps these attributes + # with an empty-string default when a run has no work item, so the empty-string + # check matters, not just the nil check. transform/legendgroups: metric_statements: - context: resource statements: - - set(attributes["iac_group"], Concat([attributes["xrpl.branch"], attributes["xrpl.node.role"], attributes["xrpl.work.item"]], "-")) where attributes["xrpl.branch"] != nil and attributes["xrpl.node.role"] != nil and attributes["xrpl.work.item"] != nil - - set(attributes["resource_group"], attributes["service.instance.id"]) where attributes["service.instance.id"] != nil - - set(attributes["resource_group"], Concat([attributes["resource_group"], attributes["xrpl.network.type"]], "-")) where attributes["resource_group"] != nil and attributes["xrpl.network.type"] != nil + - set(attributes["iac_group"], Concat([attributes["xrpl.branch"], attributes["xrpl.node.role"], attributes["xrpl.work.item"]], "-")) where attributes["xrpl.branch"] != nil and attributes["xrpl.branch"] != "" and attributes["xrpl.node.role"] != nil and attributes["xrpl.node.role"] != "" and attributes["xrpl.work.item"] != nil and attributes["xrpl.work.item"] != "" + - set(attributes["resource_group"], attributes["service.instance.id"]) where attributes["service.instance.id"] != nil and attributes["service.instance.id"] != "" + - set(attributes["resource_group"], Concat([attributes["resource_group"], attributes["xrpl.network.type"]], "-")) where attributes["resource_group"] != nil and attributes["xrpl.network.type"] != nil and attributes["xrpl.network.type"] != "" connectors: spanmetrics: