From 15f4a78d336618ed9ca3937f048e6db82a848fd2 Mon Sep 17 00:00:00 2001 From: braydonk Date: Mon, 19 Jan 2026 21:00:49 +0000 Subject: [PATCH] metadata: panic with additional information in rare panic case This PR introduces a manual panic with extra information in a scenario where a very rare panic occurs in our test runs. I have been unable to reproduce the failure in manual attempts, so this should help us discover the same bug happening again and give us more visibility to potentially address in the future. --- integration_test/metadata/integration_metadata.go | 13 +++++++++++++ integration_test/util/util.go | 2 -- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/integration_test/metadata/integration_metadata.go b/integration_test/metadata/integration_metadata.go index 085c9328ca..acf3cc32a0 100644 --- a/integration_test/metadata/integration_metadata.go +++ b/integration_test/metadata/integration_metadata.go @@ -22,6 +22,7 @@ import ( "slices" "cloud.google.com/go/monitoring/apiv3/v2/monitoringpb" + "github.com/GoogleCloudPlatform/ops-agent/integration_test/util" "github.com/go-playground/validator/v10" yaml "github.com/goccy/go-yaml" "go.uber.org/multierr" @@ -294,6 +295,18 @@ func assertMetricLabels(metric *ExpectedMetric, series *monitoringpb.TimeSeries) // Only expected labels must be present expectedLabels := make(map[string]bool) for _, expectedLabel := range metric.Labels { + // This is an attempt to catch a segfault we have not been + // able to reproduce yet. b/477046139 + // - braydonk + if expectedLabel == nil { + panic(fmt.Sprintf( + `this failure case appears to occur at random in a way we can't reproduce. this panic exists to dump more information for the scenario where it occurs. + metric name: %v + expected labels: %v`, + metric.Type, + util.DumpPointerArray(metric.Labels, "%v"), + )) + } expectedLabels[expectedLabel.Name] = true } for actualLabel, actualValue := range series.Metric.Labels { diff --git a/integration_test/util/util.go b/integration_test/util/util.go index 11791a6a4e..8d7961651a 100644 --- a/integration_test/util/util.go +++ b/integration_test/util/util.go @@ -12,8 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -//go:build integration_test - package util import (