From 8dbaf4effbf106bfb55a53b24d44e304304b083a Mon Sep 17 00:00:00 2001 From: Pratik Mankawde <3397372+pratikmankawde@users.noreply.github.com> Date: Tue, 14 Jul 2026 18:42:01 +0100 Subject: [PATCH] fix(telemetry): build legend groups on spans so span metrics get them In the Alloy config the spanmetrics connector derives span_calls_total / span_duration_* from the tagged TRACES and sends them straight to the batch processor, bypassing the metric resource statements. The grouped legend labels were built only in metric_statements, so span-derived RED metrics carried no resource_group / iac_group and span-based dashboard panels rendered empty group legends. Build the same labels in trace_statements too (mirroring how the tier attrs are already set in both), so spans carry them before spanmetrics derives from them. The reference otel collector is unaffected: there spanmetrics is a connector feeding the metrics pipeline, which runs transform/legendgroups on all inputs. Co-Authored-By: Claude Opus 4.8 (1M context) --- docker/telemetry/alloy/config.alloy | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/docker/telemetry/alloy/config.alloy b/docker/telemetry/alloy/config.alloy index 446e808c97..ffbe499159 100644 --- a/docker/telemetry/alloy/config.alloy +++ b/docker/telemetry/alloy/config.alloy @@ -151,6 +151,15 @@ otelcol.processor.transform "tier" { `delete_key(attributes, "telemetry.sdk.language")`, `delete_key(attributes, "telemetry.sdk.name")`, `delete_key(attributes, "telemetry.sdk.version")`, + // Grouped legend labels must be built here too, not only in + // metric_statements: span-derived RED metrics (span_calls_total, + // span_duration_*) are produced by the spanmetrics connector from these + // TRACES and go straight to the batch processor, bypassing the metric + // resource statements. Building the labels on the span resource keeps + // span-based dashboard panels' legends consistent with native metrics. + `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"] != ""`, + `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"] != ""`, ] }