From 8179e2ebd1dc7d92f86b4101f4105099e7d0ee58 Mon Sep 17 00:00:00 2001
From: Kaushik Surya <108111936+sky333999@users.noreply.github.com>
Date: Wed, 7 Jun 2023 16:05:12 -0400
Subject: [PATCH] [receiver/awscontainerinsightreceiver] Rollback addition of
container processes metrics (#31)
---
internal/aws/containerinsight/const.go | 9 ---
internal/aws/containerinsight/utils_test.go | 6 --
.../awscontainerinsightreceiver/README.md | 3 -
.../internal/cadvisor/cadvisor_linux.go | 2 -
.../cadvisor/container_info_processor_test.go | 1 -
.../extractors/processes_extractor.go | 56 -------------------
.../extractors/processes_extractor_test.go | 53 ------------------
.../extractors/testdata/CurInfoContainer.json | 6 --
.../extractors/testdata/PreInfoContainer.json | 6 --
9 files changed, 142 deletions(-)
delete mode 100644 receiver/awscontainerinsightreceiver/internal/cadvisor/extractors/processes_extractor.go
delete mode 100644 receiver/awscontainerinsightreceiver/internal/cadvisor/extractors/processes_extractor_test.go
diff --git a/internal/aws/containerinsight/const.go b/internal/aws/containerinsight/const.go
index 9bf655bd31ee..cd288506c9a6 100644
--- a/internal/aws/containerinsight/const.go
+++ b/internal/aws/containerinsight/const.go
@@ -89,10 +89,6 @@ const (
FSInodesfree = "filesystem_inodes_free"
FSUtilization = "filesystem_utilization"
- Processes = "processes"
- ProcessesThreads = "processes_threads"
- ProcessesFileDescriptors = "processes_file_descriptors"
-
StatusConditionReady = "status_condition_ready"
StatusConditionDiskPressure = "status_condition_disk_pressure"
StatusConditionMemoryPressure = "status_condition_memory_pressure"
@@ -240,11 +236,6 @@ func init() {
FSInodesfree: UnitCount,
FSUtilization: UnitPercent,
- // processes metrics
- Processes: UnitCount,
- ProcessesFileDescriptors: UnitCount,
- ProcessesThreads: UnitCount,
-
// status & spec metrics
StatusConditionReady: UnitCount,
StatusConditionDiskPressure: UnitCount,
diff --git a/internal/aws/containerinsight/utils_test.go b/internal/aws/containerinsight/utils_test.go
index a559fe02a6f9..a9a6cbc4e8a2 100644
--- a/internal/aws/containerinsight/utils_test.go
+++ b/internal/aws/containerinsight/utils_test.go
@@ -313,9 +313,6 @@ func TestConvertToOTLPMetricsForContainerMetrics(t *testing.T) {
"container_memory_utilization": 0.16909561488772057,
"container_memory_utilization_over_container_limit": 13.560546875,
"container_memory_working_set": int64(28438528),
- "container_processes": int64(5),
- "container_processes_threads": int64(10),
- "container_processes_file_descriptors": int64(15),
}
expectedUnits = map[string]string{
"container_cpu_limit": "",
@@ -342,9 +339,6 @@ func TestConvertToOTLPMetricsForContainerMetrics(t *testing.T) {
"container_memory_utilization": UnitPercent,
"container_memory_utilization_over_container_limit": UnitPercent,
"container_memory_working_set": UnitBytes,
- "container_processes": UnitCount,
- "container_processes_threads": UnitCount,
- "container_processes_file_descriptors": UnitCount,
}
tags = map[string]string{
"AutoScalingGroupName": "eks-a6bb9db9-267c-401c-db55-df8ef645b06f",
diff --git a/receiver/awscontainerinsightreceiver/README.md b/receiver/awscontainerinsightreceiver/README.md
index 1066508b3e7e..0c788470cd96 100644
--- a/receiver/awscontainerinsightreceiver/README.md
+++ b/receiver/awscontainerinsightreceiver/README.md
@@ -758,9 +758,6 @@ kubectl apply -f config.yaml
| container_status_terminated | Count |
| container_status_waiting | Count |
| container_status_waiting_reason_crashed | Count |
-| container_processes | Count |
-| container_processes_threads | Count |
-| container_processes_file_descriptors | Count |
diff --git a/receiver/awscontainerinsightreceiver/internal/cadvisor/cadvisor_linux.go b/receiver/awscontainerinsightreceiver/internal/cadvisor/cadvisor_linux.go
index d1b2ce55fe7b..0eb2f5e9d9d8 100644
--- a/receiver/awscontainerinsightreceiver/internal/cadvisor/cadvisor_linux.go
+++ b/receiver/awscontainerinsightreceiver/internal/cadvisor/cadvisor_linux.go
@@ -366,7 +366,6 @@ func (c *Cadvisor) initManager(createManager createCadvisorManager) error {
cadvisormetrics.DiskIOMetrics: struct{}{},
cadvisormetrics.NetworkUsageMetrics: struct{}{},
cadvisormetrics.DiskUsageMetrics: struct{}{},
- cadvisormetrics.ProcessMetrics: struct{}{},
}
var cgroupRoots []string
if c.containerOrchestrator == ci.EKS {
@@ -400,7 +399,6 @@ func (c *Cadvisor) initManager(createManager createCadvisorManager) error {
metricsExtractors = append(metricsExtractors, extractors.NewDiskIOMetricExtractor(c.logger))
metricsExtractors = append(metricsExtractors, extractors.NewNetMetricExtractor(c.logger))
metricsExtractors = append(metricsExtractors, extractors.NewFileSystemMetricExtractor(c.logger))
- metricsExtractors = append(metricsExtractors, extractors.NewProcessesMetricExtractor(c.logger))
return nil
}
diff --git a/receiver/awscontainerinsightreceiver/internal/cadvisor/container_info_processor_test.go b/receiver/awscontainerinsightreceiver/internal/cadvisor/container_info_processor_test.go
index 3519fdeb2770..bd6e1cded459 100644
--- a/receiver/awscontainerinsightreceiver/internal/cadvisor/container_info_processor_test.go
+++ b/receiver/awscontainerinsightreceiver/internal/cadvisor/container_info_processor_test.go
@@ -68,7 +68,6 @@ func TestProcessContainers(t *testing.T) {
metricsExtractors = append(metricsExtractors, extractors.NewDiskIOMetricExtractor(zap.NewNop()))
metricsExtractors = append(metricsExtractors, extractors.NewNetMetricExtractor(zap.NewNop()))
metricsExtractors = append(metricsExtractors, extractors.NewFileSystemMetricExtractor(zap.NewNop()))
- metricsExtractors = append(metricsExtractors, extractors.NewProcessesMetricExtractor(zap.NewNop()))
containerInfos := testutils.LoadContainerInfo(t, "./extractors/testdata/CurInfoContainer.json")
podInfos := testutils.LoadContainerInfo(t, "./extractors/testdata/InfoPod.json")
diff --git a/receiver/awscontainerinsightreceiver/internal/cadvisor/extractors/processes_extractor.go b/receiver/awscontainerinsightreceiver/internal/cadvisor/extractors/processes_extractor.go
deleted file mode 100644
index b84097fd4de6..000000000000
--- a/receiver/awscontainerinsightreceiver/internal/cadvisor/extractors/processes_extractor.go
+++ /dev/null
@@ -1,56 +0,0 @@
-// Copyright The OpenTelemetry Authors
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package extractors // import "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/awscontainerinsightreceiver/internal/cadvisor/extractors"
-
-import (
- cinfo "github.com/google/cadvisor/info/v1"
- "go.uber.org/zap"
-
- ci "github.com/open-telemetry/opentelemetry-collector-contrib/internal/aws/containerinsight"
-)
-
-type ProcessesMetricExtractor struct {
- logger *zap.Logger
-}
-
-func (f *ProcessesMetricExtractor) HasValue(info *cinfo.ContainerInfo) bool {
- return info.Spec.HasProcesses
-}
-
-func (f *ProcessesMetricExtractor) GetValue(info *cinfo.ContainerInfo, _ CPUMemInfoProvider, containerType string) []*CAdvisorMetric {
- var metrics []*CAdvisorMetric
- if containerType != ci.TypeContainer {
- return metrics
- }
-
- metric := newCadvisorMetric(containerType, f.logger)
- metric.cgroupPath = info.Name
-
- stats := GetStats(info)
- metric.fields[ci.MetricName(containerType, ci.Processes)] = stats.Processes.ProcessCount
- metric.fields[ci.MetricName(containerType, ci.ProcessesThreads)] = stats.Processes.ThreadsCurrent
- metric.fields[ci.MetricName(containerType, ci.ProcessesFileDescriptors)] = stats.Processes.FdCount
-
- metrics = append(metrics, metric)
- return metrics
-}
-
-func NewProcessesMetricExtractor(logger *zap.Logger) *ProcessesMetricExtractor {
- me := &ProcessesMetricExtractor{
- logger: logger,
- }
-
- return me
-}
diff --git a/receiver/awscontainerinsightreceiver/internal/cadvisor/extractors/processes_extractor_test.go b/receiver/awscontainerinsightreceiver/internal/cadvisor/extractors/processes_extractor_test.go
deleted file mode 100644
index d8f8f0da658f..000000000000
--- a/receiver/awscontainerinsightreceiver/internal/cadvisor/extractors/processes_extractor_test.go
+++ /dev/null
@@ -1,53 +0,0 @@
-// Copyright The OpenTelemetry Authors
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package extractors
-
-import (
- "testing"
-
- "github.com/stretchr/testify/assert"
- "go.uber.org/zap"
-
- . "github.com/open-telemetry/opentelemetry-collector-contrib/internal/aws/containerinsight"
- "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/awscontainerinsightreceiver/internal/cadvisor/testutils"
-)
-
-func TestProcessesStats(t *testing.T) {
- result := testutils.LoadContainerInfo(t, "./testdata/CurInfoContainer.json")
- extractor := NewProcessesMetricExtractor(zap.NewNop())
-
- var cMetrics []*CAdvisorMetric
-
- if !extractor.HasValue(result[0]) {
- t.Logf("Testdata not configured to work with extractor")
- t.FailNow()
- }
-
- // Type Container
- cMetrics = extractor.GetValue(result[0], nil, TypeContainer)
- expectedFields := map[string]interface{}{
- "container_processes": uint64(10),
- "container_processes_threads": uint64(20),
- "container_processes_file_descriptors": uint64(30),
- }
- expectedTags := map[string]string{
- "Type": "Container",
- }
- AssertContainsTaggedField(t, cMetrics[0], expectedFields, expectedTags)
-
- // Type Pod
- cMetrics = extractor.GetValue(result[0], nil, TypePod)
- assert.Equal(t, len(cMetrics), 0)
-}
diff --git a/receiver/awscontainerinsightreceiver/internal/cadvisor/extractors/testdata/CurInfoContainer.json b/receiver/awscontainerinsightreceiver/internal/cadvisor/extractors/testdata/CurInfoContainer.json
index 68764dc20a0f..1edda3137c32 100644
--- a/receiver/awscontainerinsightreceiver/internal/cadvisor/extractors/testdata/CurInfoContainer.json
+++ b/receiver/awscontainerinsightreceiver/internal/cadvisor/extractors/testdata/CurInfoContainer.json
@@ -40,7 +40,6 @@
"has_filesystem": true,
"has_diskio": true,
"has_custom_metrics": false,
- "has_processes": true,
"image": "ubuntu@sha256:017eef0b616011647b269b5c65826e2e2ebddbe5d1f8c1e56b3599fb14fabec8"
},
"stats": [
@@ -190,11 +189,6 @@
"nr_stopped": 0,
"nr_uninterruptible": 0,
"nr_io_wait": 0
- },
- "processes": {
- "process_count": 10,
- "threads_current": 20,
- "fd_count": 30
}
}
]
diff --git a/receiver/awscontainerinsightreceiver/internal/cadvisor/extractors/testdata/PreInfoContainer.json b/receiver/awscontainerinsightreceiver/internal/cadvisor/extractors/testdata/PreInfoContainer.json
index 091a24ce92a8..4c1bf3581521 100644
--- a/receiver/awscontainerinsightreceiver/internal/cadvisor/extractors/testdata/PreInfoContainer.json
+++ b/receiver/awscontainerinsightreceiver/internal/cadvisor/extractors/testdata/PreInfoContainer.json
@@ -40,7 +40,6 @@
"has_filesystem": true,
"has_diskio": true,
"has_custom_metrics": false,
- "has_processes": true,
"image": "ubuntu@sha256:017eef0b616011647b269b5c65826e2e2ebddbe5d1f8c1e56b3599fb14fabec8"
},
"stats": [
@@ -190,11 +189,6 @@
"nr_stopped": 0,
"nr_uninterruptible": 0,
"nr_io_wait": 0
- },
- "processes": {
- "process_count": 5,
- "threads_current": 15,
- "fd_count": 25
}
}
]