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 (