Skip to content

Commit

Permalink
[incident-33304] Expect container tags on dogstatsd metrics (#32222)
Browse files Browse the repository at this point in the history
  • Loading branch information
L3n41c committed Dec 16, 2024
1 parent 0b6cf8e commit 88f03dc
Showing 1 changed file with 8 additions and 33 deletions.
41 changes: 8 additions & 33 deletions test/new-e2e/tests/containers/k8s_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ const (
kubeNamespaceDogstatsWorkload = "workload-dogstatsd"
kubeNamespaceDogstatsStandaloneWorkload = "workload-dogstatsd-standalone"
kubeNamespaceTracegenWorkload = "workload-tracegen"
kubeDeploymentDogstatsdUDP = "dogstatsd-udp"
kubeDeploymentDogstatsdUDPOrigin = "dogstatsd-udp-origin-detection"
kubeDeploymentDogstatsdUDS = "dogstatsd-uds"
kubeDeploymentTracegenTCPWorkload = "tracegen-tcp"
Expand Down Expand Up @@ -797,48 +798,22 @@ func (suite *k8sSuite) TestCPU() {

func (suite *k8sSuite) TestDogstatsdInAgent() {
// Test with UDS
suite.testDogstatsdContainerID(kubeNamespaceDogstatsWorkload, kubeDeploymentDogstatsdUDS)
suite.testDogstatsd(kubeNamespaceDogstatsWorkload, kubeDeploymentDogstatsdUDS)
// Test with UDP + Origin detection
suite.testDogstatsdContainerID(kubeNamespaceDogstatsWorkload, kubeDeploymentDogstatsdUDPOrigin)
suite.testDogstatsd(kubeNamespaceDogstatsWorkload, kubeDeploymentDogstatsdUDPOrigin)
// Test with UDP + DD_ENTITY_ID
suite.testDogstatsdPodUID(kubeNamespaceDogstatsWorkload)
suite.testDogstatsd(kubeNamespaceDogstatsWorkload, kubeDeploymentDogstatsdUDP)
}

func (suite *k8sSuite) TestDogstatsdStandalone() {
// Test with UDS
suite.testDogstatsdContainerID(kubeNamespaceDogstatsStandaloneWorkload, kubeDeploymentDogstatsdUDS)
suite.testDogstatsd(kubeNamespaceDogstatsStandaloneWorkload, kubeDeploymentDogstatsdUDS)
// Dogstatsd standalone does not support origin detection
// Test with UDP + DD_ENTITY_ID
suite.testDogstatsdPodUID(kubeNamespaceDogstatsWorkload)
suite.testDogstatsd(kubeNamespaceDogstatsWorkload, kubeDeploymentDogstatsdUDP)
}

func (suite *k8sSuite) testDogstatsdPodUID(kubeNamespace string) {
// Test dogstatsd origin detection with UDP + DD_ENTITY_ID
suite.testMetric(&testMetricArgs{
Filter: testMetricFilterArgs{
Name: "custom.metric",
Tags: []string{
"^kube_deployment:dogstatsd-udp$",
"^kube_namespace:" + regexp.QuoteMeta(kubeNamespace) + "$",
},
},
Expect: testMetricExpectArgs{
Tags: &[]string{
`^kube_deployment:dogstatsd-udp$`,
"^kube_namespace:" + regexp.QuoteMeta(kubeNamespace) + "$",
`^kube_ownerref_kind:replicaset$`,
`^kube_ownerref_name:dogstatsd-udp-[[:alnum:]]+$`,
`^kube_qos:Burstable$`,
`^kube_replica_set:dogstatsd-udp-[[:alnum:]]+$`,
`^pod_name:dogstatsd-udp-[[:alnum:]]+-[[:alnum:]]+$`,
`^pod_phase:running$`,
`^series:`,
},
},
})
}

func (suite *k8sSuite) testDogstatsdContainerID(kubeNamespace, kubeDeployment string) {
func (suite *k8sSuite) testDogstatsd(kubeNamespace, kubeDeployment string) {
suite.testMetric(&testMetricArgs{
Filter: testMetricFilterArgs{
Name: "custom.metric",
Expand All @@ -853,7 +828,7 @@ func (suite *k8sSuite) testDogstatsdContainerID(kubeNamespace, kubeDeployment st
`^container_name:dogstatsd$`,
`^display_container_name:dogstatsd`,
`^git.commit.sha:`, // org.opencontainers.image.revision docker image label
`^git.repository_url:https://github.com/DataDog/test-infra-definitions$`, // org.opencontainers.image.source docker image label
`^git.repository_url:https://github.com/DataDog/test-infra-definitions$`, // org.opencontainers.image.source docker image label
`^image_id:ghcr.io/datadog/apps-dogstatsd@sha256:`,
`^image_name:ghcr.io/datadog/apps-dogstatsd$`,
`^image_tag:main$`,
Expand Down

0 comments on commit 88f03dc

Please sign in to comment.