Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions test/otel/ebs_csi/attribute_scope_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
//go:build integration

// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: MIT

package ebs_csi

import (
"context"
"testing"

"github.com/stretchr/testify/require"

"github.com/aws/amazon-cloudwatch-agent-test/util/otelmetrics"
)

// TestEBSCSIDeprecatedSemconvAttributesRemoved asserts the ebs-csi pipeline deletes
// the deprecated semantic-convention attributes the Prometheus receiver injects.
//
// url.scheme is not asserted present here, because the pipeline runs on every node
// and a node near max_total_attributes loses attributes to the tier cascade.
//
// The ebs-csi pipeline needs no resource-scope raw-label check. It runs no
// groupbyattrs processor, so no raw Prometheus name reaches resource scope.
func TestEBSCSIDeprecatedSemconvAttributesRemoved(t *testing.T) {
t.Parallel()
for _, metricName := range ebsCsiMetricNames() {
metricName := metricName
t.Run(metricName, func(t *testing.T) {
t.Parallel()
results, err := queryCache.Get(context.Background(), metricName)
require.NoError(t, err, "querying %s", metricName)
require.NotEmpty(t, results, "%s not available (no EBS CSI driver?)", metricName)
require.NoError(t, otelmetrics.CheckDeprecatedSemconvRemoved(metricName, results))
})
}
}
52 changes: 52 additions & 0 deletions test/otel/gpu/attribute_scope_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
//go:build integration

// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: MIT

package gpu

import (
"context"
"testing"

"github.com/stretchr/testify/require"

"github.com/aws/amazon-cloudwatch-agent-test/util/otelmetrics"
)

// TestDCGMDeprecatedSemconvAttributesRemoved asserts the dcgm pipeline deletes the
// deprecated semantic-convention attributes the Prometheus receiver injects.
//
// url.scheme is not asserted present here. GPU nodes carry enough labels to reach
// max_total_attributes, and the attribute-limit processor then drops by tier.
func TestDCGMDeprecatedSemconvAttributesRemoved(t *testing.T) {
t.Parallel()
for _, metricName := range dcgmMetricNamesList {
metricName := metricName
t.Run(metricName, func(t *testing.T) {
t.Parallel()
results, err := queryCache.Get(context.Background(), metricName)
require.NoError(t, err, "querying %s", metricName)
require.NotEmpty(t, results, "%s not available (no GPU nodes?)", metricName)
require.NoError(t, otelmetrics.CheckDeprecatedSemconvRemoved(metricName, results))
})
}
}

// TestDCGMRawLabelsOnlyAtDatapointScope asserts the raw Prometheus labels the dcgm
// groupbyattrs processor lifts to resource scope are deleted there after the
// pipeline copies them back down. TestDCGMHasRawPromotedKeys covers the datapoint side.
func TestDCGMRawLabelsOnlyAtDatapointScope(t *testing.T) {
t.Parallel()
rawKeys := []string{"pod", "namespace", "container"}
for _, metricName := range dcgmMetricNamesList {
metricName := metricName
t.Run(metricName, func(t *testing.T) {
t.Parallel()
results, err := queryCache.Get(context.Background(), metricName)
require.NoError(t, err, "querying %s", metricName)
require.NotEmpty(t, results, "%s not available (no GPU nodes?)", metricName)
require.NoError(t, otelmetrics.CheckRawLabelsNotAtResourceScope(metricName, results, rawKeys))
})
}
}
38 changes: 38 additions & 0 deletions test/otel/lis_csi/attribute_scope_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
//go:build integration

// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: MIT

package lis_csi

import (
"context"
"testing"

"github.com/stretchr/testify/require"

"github.com/aws/amazon-cloudwatch-agent-test/util/otelmetrics"
)

// TestLISCSIDeprecatedSemconvAttributesRemoved asserts the lis-csi pipeline deletes
// the deprecated semantic-convention attributes the Prometheus receiver injects.
//
// url.scheme is not asserted present here, because the pipeline runs on every
// instance-store node and a node near max_total_attributes loses attributes to the
// tier cascade.
//
// The lis-csi pipeline needs no resource-scope raw-label check. It runs no
// groupbyattrs processor, so no raw Prometheus name reaches resource scope.
func TestLISCSIDeprecatedSemconvAttributesRemoved(t *testing.T) {
t.Parallel()
for _, metricName := range lisCsiMetricNames() {
metricName := metricName
t.Run(metricName, func(t *testing.T) {
t.Parallel()
results, err := queryCache.Get(context.Background(), metricName)
require.NoError(t, err, "querying %s", metricName)
require.NotEmpty(t, results, "%s not available", metricName)
require.NoError(t, otelmetrics.CheckDeprecatedSemconvRemoved(metricName, results))
})
}
}
38 changes: 38 additions & 0 deletions test/otel/neuron/attribute_scope_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
//go:build integration

// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: MIT

package neuron

import (
"context"
"testing"

"github.com/stretchr/testify/require"

"github.com/aws/amazon-cloudwatch-agent-test/util/otelmetrics"
)

// TestNeuronDeprecatedSemconvAttributesRemoved asserts the neuron pipeline deletes
// the deprecated semantic-convention attributes the Prometheus receiver injects.
//
// url.scheme is not asserted present here. Trainium nodes carry enough labels to
// reach max_total_attributes, and the attribute-limit processor then drops by tier.
//
// The neuron pipeline needs no resource-scope raw-label check. Its groupbyattrs
// processor lifts the semconv names and runtime_tag rather than raw Prometheus
// names, and neuron_promote renames then deletes runtime_tag.
func TestNeuronDeprecatedSemconvAttributesRemoved(t *testing.T) {
t.Parallel()
for _, metricName := range neuronMetricNames() {
metricName := metricName
t.Run(metricName, func(t *testing.T) {
t.Parallel()
results, err := queryCache.Get(context.Background(), metricName)
require.NoError(t, err, "querying %s", metricName)
require.NotEmpty(t, results, "%s not available (no Neuron nodes?)", metricName)
require.NoError(t, otelmetrics.CheckDeprecatedSemconvRemoved(metricName, results))
})
}
}
55 changes: 55 additions & 0 deletions test/otel/solutions/karpenter/attribute_scope_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
//go:build integration

// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: MIT

package karpenter

import (
"context"
"testing"

"github.com/stretchr/testify/require"

"github.com/aws/amazon-cloudwatch-agent-test/util/otelmetrics"
)

// TestKarpenterDeprecatedSemconvAttributesRemoved asserts the karpenter pipeline
// deletes the deprecated semantic-convention attributes and keeps url.scheme.
//
// The url.scheme assertion is the valuable half. karpenter_promote used to delete
// url.scheme, the current spelling, while keeping http.scheme, the deprecated one.
// These metrics are cluster-scoped and carry a small attribute set, so the tier
// cascade cannot explain a missing url.scheme here.
func TestKarpenterDeprecatedSemconvAttributesRemoved(t *testing.T) {
t.Parallel()
for _, metricName := range karpenterMetricNames() {
metricName := metricName
t.Run(metricName, func(t *testing.T) {
t.Parallel()
results, err := queryCache.Get(context.Background(), metricName)
require.NoError(t, err, "querying %s", metricName)
require.NotEmpty(t, results, "%s not available", metricName)
require.NoError(t, otelmetrics.CheckDeprecatedSemconvRemoved(metricName, results))
require.NoError(t, otelmetrics.CheckCurrentSemconvPresent(metricName, results))
})
}
}

// TestKarpenterRawLabelsOnlyAtDatapointScope asserts the raw Prometheus labels the
// karpenter groupbyattrs processor lifts to resource scope are deleted there after
// the pipeline copies them back down to datapoint scope.
func TestKarpenterRawLabelsOnlyAtDatapointScope(t *testing.T) {
t.Parallel()
rawKeys := []string{"pod", "namespace", "node"}
for _, metricName := range karpenterMetricNames() {
metricName := metricName
t.Run(metricName, func(t *testing.T) {
t.Parallel()
results, err := queryCache.Get(context.Background(), metricName)
require.NoError(t, err, "querying %s", metricName)
require.NotEmpty(t, results, "%s not available", metricName)
require.NoError(t, otelmetrics.CheckRawLabelsNotAtResourceScope(metricName, results, rawKeys))
})
}
}
55 changes: 55 additions & 0 deletions test/otel/solutions/keda/attribute_scope_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
//go:build integration

// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: MIT

package keda

import (
"context"
"testing"

"github.com/stretchr/testify/require"

"github.com/aws/amazon-cloudwatch-agent-test/util/otelmetrics"
)

// TestKEDADeprecatedSemconvAttributesRemoved asserts the keda pipeline deletes the
// deprecated semantic-convention attributes and keeps url.scheme.
//
// The url.scheme assertion is the valuable half. keda_promote used to delete
// url.scheme, the current spelling, while keeping http.scheme, the deprecated one.
// These metrics are cluster-scoped and carry a small attribute set, so the tier
// cascade cannot explain a missing url.scheme here.
func TestKEDADeprecatedSemconvAttributesRemoved(t *testing.T) {
t.Parallel()
for _, metricName := range kedaMetricNames() {
metricName := metricName
t.Run(metricName, func(t *testing.T) {
t.Parallel()
results, err := queryCache.Get(context.Background(), metricName)
require.NoError(t, err, "querying %s", metricName)
require.NotEmpty(t, results, "%s not available", metricName)
require.NoError(t, otelmetrics.CheckDeprecatedSemconvRemoved(metricName, results))
require.NoError(t, otelmetrics.CheckCurrentSemconvPresent(metricName, results))
})
}
}

// TestKEDARawLabelsOnlyAtDatapointScope asserts the raw Prometheus labels the keda
// groupbyattrs processor lifts to resource scope are deleted there after the
// pipeline copies them back down to datapoint scope.
func TestKEDARawLabelsOnlyAtDatapointScope(t *testing.T) {
t.Parallel()
rawKeys := []string{"pod", "namespace", "node"}
for _, metricName := range kedaMetricNames() {
metricName := metricName
t.Run(metricName, func(t *testing.T) {
t.Parallel()
results, err := queryCache.Get(context.Background(), metricName)
require.NoError(t, err, "querying %s", metricName)
require.NotEmpty(t, results, "%s not available", metricName)
require.NoError(t, otelmetrics.CheckRawLabelsNotAtResourceScope(metricName, results, rawKeys))
})
}
}
64 changes: 64 additions & 0 deletions test/otel/standard/labels_common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -907,3 +907,67 @@ func TestPodLabelsStillEnriched(t *testing.T) {
})
}
}

// ---------------------------------------------------------------------------
// TestDeprecatedSemconvAttributesRemoved — the deprecated semconv attributes go,
// their current-spelling twins stay. url.scheme is asserted present on purpose:
// karpenter/keda used to delete it and keep http.scheme, which was backwards.
// The checks live in util/otelmetrics so the gpu, neuron, ebs_csi, lis_csi,
// karpenter and keda suites assert the same rule on their own pipelines.
// ---------------------------------------------------------------------------

func TestDeprecatedSemconvAttributesRemoved(t *testing.T) {
names := prometheusScrapedNames()
names = append(names, metricNames(allKSMMetricDefs)...)

for _, metricName := range names {
t.Run(metricName, func(t *testing.T) {
results, err := queryCache.Get(context.Background(), metricName)
require.NoError(t, err, "querying %s", metricName)
require.NotEmpty(t, results, "%s not available", metricName)
require.NoError(t, otelmetrics.CheckDeprecatedSemconvRemoved(metricName, results))
require.NoError(t, otelmetrics.CheckCurrentSemconvPresent(metricName, results))
})
}
}

// ---------------------------------------------------------------------------
// TestRawLabelsOnlyAtDatapointScope — the raw Prometheus labels must exist only at
// datapoint scope, not at resource scope too. The datapoint side is covered by
// TestCadvisorHasRawPromotedKeys and the TestKSM_*_HasRaw*Label family.
// ---------------------------------------------------------------------------

func TestRawLabelsOnlyAtDatapointScope(t *testing.T) {
cases := []struct {
pipeline string
names []string
rawKeys []string
}{
{
pipeline: "cadvisor",
names: cadvisorMetricNamesList,
rawKeys: []string{"pod", "namespace", "container"},
},
{
pipeline: "kube-state-metrics",
names: metricNames(allKSMMetricDefs),
rawKeys: []string{
"pod", "namespace", "node", "uid", "container",
"owner_name", "owner_kind", "deployment", "daemonset",
"statefulset", "replicaset", "job_name", "cronjob",
},
},
}

for _, c := range cases {
c := c
for _, metricName := range c.names {
t.Run(c.pipeline+"/"+metricName, func(t *testing.T) {
results, err := queryCache.Get(context.Background(), metricName)
require.NoError(t, err, "querying %s", metricName)
require.NotEmpty(t, results, "%s not available", metricName)
require.NoError(t, otelmetrics.CheckRawLabelsNotAtResourceScope(metricName, results, c.rawKeys))
})
}
}
}
Loading
Loading