From eb1e920c55a1fbe59336a3e594f8bdc6780281fd Mon Sep 17 00:00:00 2001 From: Antoine Toulme Date: Fri, 10 Jan 2025 10:01:58 -0800 Subject: [PATCH 1/6] move more tests to use golden --- tests/general/container_test.go | 94 ++++++++++++++++--- tests/general/testdata/expected/activemq.yaml | 77 +++++++++++++++ tests/general/testdata/expected/solr.yaml | 43 +++++++++ .../testdata/resource_metrics/activemq.yaml | 7 -- .../testdata/resource_metrics/solr.yaml | 5 - 5 files changed, 199 insertions(+), 27 deletions(-) create mode 100644 tests/general/testdata/expected/activemq.yaml create mode 100644 tests/general/testdata/expected/solr.yaml delete mode 100644 tests/general/testdata/resource_metrics/activemq.yaml delete mode 100644 tests/general/testdata/resource_metrics/solr.yaml diff --git a/tests/general/container_test.go b/tests/general/container_test.go index a0046f6ddb..f19a9a3747 100644 --- a/tests/general/container_test.go +++ b/tests/general/container_test.go @@ -18,6 +18,9 @@ package tests import ( "fmt" + "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/golden" + "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatatest/pmetrictest" + "path/filepath" "strings" "testing" "time" @@ -218,27 +221,88 @@ service: // This test also exercises collectd binary usage and managed config writing func TestNonDefaultGIDCanAccessJavaInAgentBundle(t *testing.T) { testutils.SkipIfNotContainerTest(t) - testutils.AssertAllMetricsReceived(t, "activemq.yaml", "activemq_config.yaml", nil, - []testutils.CollectorBuilder{ - func(collector testutils.Collector) testutils.Collector { - cc := collector.(*testutils.CollectorContainer) - cc.Container = cc.Container.WithUser("splunk-otel-collector:234567890") - return collector - }, + tc := testutils.NewTestcase(t) + defer tc.PrintLogsOnFailure() + defer tc.ShutdownOTLPReceiverSink() + + _, shutdown := tc.SplunkOtelCollectorContainer("activemq_config.yaml", + func(c testutils.Collector) testutils.Collector { + cc := c.(*testutils.CollectorContainer) + cc.Container = cc.Container.WithUser("splunk-otel-collector:234567890") + return cc }, ) + defer shutdown() + + expected, err := golden.ReadMetrics(filepath.Join("testdata", "expected", "activemq.yaml")) + require.NoError(t, err) + require.EventuallyWithT(t, func(tt *assert.CollectT) { + if len(tc.OTLPReceiverSink.AllMetrics()) == 0 { + assert.Fail(tt, "No metrics collected") + return + } + err := pmetrictest.CompareMetrics(expected, tc.OTLPReceiverSink.AllMetrics()[len(tc.OTLPReceiverSink.AllMetrics())-1], + pmetrictest.IgnoreResourceAttributeValue("service.instance.id"), + pmetrictest.IgnoreResourceAttributeValue("net.host.port"), + pmetrictest.IgnoreResourceAttributeValue("net.host.name"), + pmetrictest.IgnoreResourceAttributeValue("server.address"), + pmetrictest.IgnoreResourceAttributeValue("container.name"), + pmetrictest.IgnoreResourceAttributeValue("server.port"), + pmetrictest.IgnoreResourceAttributeValue("service.name"), + pmetrictest.IgnoreResourceAttributeValue("service_instance_id"), + pmetrictest.IgnoreResourceAttributeValue("service_version"), + pmetrictest.IgnoreTimestamp(), + pmetrictest.IgnoreStartTimestamp(), + pmetrictest.IgnoreMetricDataPointsOrder(), + pmetrictest.IgnoreScopeMetricsOrder(), + pmetrictest.IgnoreScopeVersion(), + pmetrictest.IgnoreResourceMetricsOrder(), + pmetrictest.IgnoreMetricValues(), + ) + assert.NoError(tt, err) + }, 30*time.Second, 1*time.Second) } func TestNonDefaultGIDCanAccessPythonInAgentBundle(t *testing.T) { testutils.SkipIfNotContainerTest(t) - testutils.AssertAllMetricsReceived(t, "solr.yaml", "solr_config.yaml", - nil, - []testutils.CollectorBuilder{ - func(collector testutils.Collector) testutils.Collector { - cc := collector.(*testutils.CollectorContainer) - cc.Container = cc.Container.WithUser("splunk-otel-collector:234567890") - return collector - }, + tc := testutils.NewTestcase(t) + defer tc.PrintLogsOnFailure() + defer tc.ShutdownOTLPReceiverSink() + + _, shutdown := tc.SplunkOtelCollectorContainer("solr_config.yaml", + func(c testutils.Collector) testutils.Collector { + cc := c.(*testutils.CollectorContainer) + cc.Container = cc.Container.WithUser("splunk-otel-collector:234567890") + return cc }, ) + defer shutdown() + + expected, err := golden.ReadMetrics(filepath.Join("testdata", "expected", "solr.yaml")) + require.NoError(t, err) + require.EventuallyWithT(t, func(tt *assert.CollectT) { + if len(tc.OTLPReceiverSink.AllMetrics()) == 0 { + assert.Fail(tt, "No metrics collected") + return + } + err := pmetrictest.CompareMetrics(expected, tc.OTLPReceiverSink.AllMetrics()[len(tc.OTLPReceiverSink.AllMetrics())-1], + pmetrictest.IgnoreResourceAttributeValue("service.instance.id"), + pmetrictest.IgnoreResourceAttributeValue("net.host.port"), + pmetrictest.IgnoreResourceAttributeValue("net.host.name"), + pmetrictest.IgnoreResourceAttributeValue("server.address"), + pmetrictest.IgnoreResourceAttributeValue("container.name"), + pmetrictest.IgnoreResourceAttributeValue("server.port"), + pmetrictest.IgnoreResourceAttributeValue("service.name"), + pmetrictest.IgnoreResourceAttributeValue("service_instance_id"), + pmetrictest.IgnoreResourceAttributeValue("service_version"), + pmetrictest.IgnoreTimestamp(), + pmetrictest.IgnoreStartTimestamp(), + pmetrictest.IgnoreMetricDataPointsOrder(), + pmetrictest.IgnoreScopeMetricsOrder(), + pmetrictest.IgnoreScopeVersion(), + pmetrictest.IgnoreResourceMetricsOrder(), + pmetrictest.IgnoreMetricValues(), + ) + assert.NoError(tt, err) + }, 30*time.Second, 1*time.Second) } diff --git a/tests/general/testdata/expected/activemq.yaml b/tests/general/testdata/expected/activemq.yaml new file mode 100644 index 0000000000..7a1cf0c739 --- /dev/null +++ b/tests/general/testdata/expected/activemq.yaml @@ -0,0 +1,77 @@ +resourceMetrics: + - resource: {} + scopeMetrics: + - metrics: + - gauge: + dataPoints: + - asInt: "3801088" + attributes: + - key: dsname + value: + stringValue: value + - key: host + value: + stringValue: docker-desktop + - key: hostHasService + value: + stringValue: activemq + - key: plugin + value: + stringValue: GenericJMX + - key: plugin_instance + value: + stringValue: memory_pool-Compressed Class Space + - key: system.type + value: + stringValue: activemq + timeUnixNano: "1000000" + name: jmx_memory.committed + - gauge: + dataPoints: + - asInt: "12189696" + attributes: + - key: dsname + value: + stringValue: value + - key: host + value: + stringValue: docker-desktop + - key: hostHasService + value: + stringValue: activemq + - key: plugin + value: + stringValue: GenericJMX + - key: plugin_instance + value: + stringValue: memory_pool-Code Cache + - key: system.type + value: + stringValue: activemq + timeUnixNano: "1000000" + name: jmx_memory.committed + - gauge: + dataPoints: + - asInt: "7864320" + attributes: + - key: dsname + value: + stringValue: value + - key: host + value: + stringValue: docker-desktop + - key: hostHasService + value: + stringValue: activemq + - key: plugin + value: + stringValue: GenericJMX + - key: plugin_instance + value: + stringValue: memory_pool-PS Survivor Space + - key: system.type + value: + stringValue: activemq + timeUnixNano: "1000000" + name: jmx_memory.committed + scope: {} diff --git a/tests/general/testdata/expected/solr.yaml b/tests/general/testdata/expected/solr.yaml new file mode 100644 index 0000000000..e3e8ab70dd --- /dev/null +++ b/tests/general/testdata/expected/solr.yaml @@ -0,0 +1,43 @@ +resourceMetrics: + - resource: {} + scopeMetrics: + - metrics: + - name: counter.solr.http_2xx_responses + sum: + aggregationTemporality: 2 + dataPoints: + - asInt: "38" + attributes: + - key: cluster + value: + stringValue: default + - key: collection + value: + stringValue: techproducts + - key: core + value: + stringValue: techproducts_shard1_replica_n1 + - key: dsname + value: + stringValue: value + - key: leader + value: + stringValue: "true" + - key: node + value: + stringValue: localhost:8983_solr + - key: plugin + value: + stringValue: solr + - key: plugin_instance + value: + stringValue: localhost:8983 + - key: shard + value: + stringValue: shard1 + - key: system.type + value: + stringValue: solr + timeUnixNano: "1000000" + isMonotonic: true + scope: {} diff --git a/tests/general/testdata/resource_metrics/activemq.yaml b/tests/general/testdata/resource_metrics/activemq.yaml deleted file mode 100644 index 5b2a00b2fd..0000000000 --- a/tests/general/testdata/resource_metrics/activemq.yaml +++ /dev/null @@ -1,7 +0,0 @@ -resource_metrics: - - scope_metrics: - - metrics: - - name: counter.amq.TotalConnectionsCount - type: IntMonotonicCumulativeSum - - name: jmx_memory.committed - type: IntGauge diff --git a/tests/general/testdata/resource_metrics/solr.yaml b/tests/general/testdata/resource_metrics/solr.yaml deleted file mode 100644 index f73566c7ec..0000000000 --- a/tests/general/testdata/resource_metrics/solr.yaml +++ /dev/null @@ -1,5 +0,0 @@ -resource_metrics: - - scope_metrics: - - metrics: - - name: counter.solr.http_2xx_responses - type: IntMonotonicCumulativeSum From 06572423ae182e79711883116968e54fa4095e7c Mon Sep 17 00:00:00 2001 From: Antoine Toulme Date: Fri, 10 Jan 2025 13:33:59 -0800 Subject: [PATCH 2/6] fix imports --- tests/general/container_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/general/container_test.go b/tests/general/container_test.go index f19a9a3747..1b6324c9cc 100644 --- a/tests/general/container_test.go +++ b/tests/general/container_test.go @@ -18,13 +18,13 @@ package tests import ( "fmt" - "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/golden" - "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatatest/pmetrictest" "path/filepath" "strings" "testing" "time" + "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/golden" + "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatatest/pmetrictest" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "go.opentelemetry.io/collector/pdata/pmetric" From 016ca6033083c44fcd5642e26a5e6f2d4eeb8b6b Mon Sep 17 00:00:00 2001 From: Antoine Toulme Date: Sat, 11 Jan 2025 00:36:32 -0800 Subject: [PATCH 3/6] just check we have the metrics --- tests/general/container_test.go | 78 ++++++++----------- tests/general/testdata/expected/activemq.yaml | 77 ------------------ tests/general/testdata/expected/solr.yaml | 43 ---------- 3 files changed, 32 insertions(+), 166 deletions(-) delete mode 100644 tests/general/testdata/expected/activemq.yaml delete mode 100644 tests/general/testdata/expected/solr.yaml diff --git a/tests/general/container_test.go b/tests/general/container_test.go index 1b6324c9cc..c7b991d2f1 100644 --- a/tests/general/container_test.go +++ b/tests/general/container_test.go @@ -18,13 +18,10 @@ package tests import ( "fmt" - "path/filepath" "strings" "testing" "time" - "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/golden" - "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatatest/pmetrictest" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "go.opentelemetry.io/collector/pdata/pmetric" @@ -233,33 +230,28 @@ func TestNonDefaultGIDCanAccessJavaInAgentBundle(t *testing.T) { }, ) defer shutdown() - - expected, err := golden.ReadMetrics(filepath.Join("testdata", "expected", "activemq.yaml")) - require.NoError(t, err) require.EventuallyWithT(t, func(tt *assert.CollectT) { if len(tc.OTLPReceiverSink.AllMetrics()) == 0 { assert.Fail(tt, "No metrics collected") return } - err := pmetrictest.CompareMetrics(expected, tc.OTLPReceiverSink.AllMetrics()[len(tc.OTLPReceiverSink.AllMetrics())-1], - pmetrictest.IgnoreResourceAttributeValue("service.instance.id"), - pmetrictest.IgnoreResourceAttributeValue("net.host.port"), - pmetrictest.IgnoreResourceAttributeValue("net.host.name"), - pmetrictest.IgnoreResourceAttributeValue("server.address"), - pmetrictest.IgnoreResourceAttributeValue("container.name"), - pmetrictest.IgnoreResourceAttributeValue("server.port"), - pmetrictest.IgnoreResourceAttributeValue("service.name"), - pmetrictest.IgnoreResourceAttributeValue("service_instance_id"), - pmetrictest.IgnoreResourceAttributeValue("service_version"), - pmetrictest.IgnoreTimestamp(), - pmetrictest.IgnoreStartTimestamp(), - pmetrictest.IgnoreMetricDataPointsOrder(), - pmetrictest.IgnoreScopeMetricsOrder(), - pmetrictest.IgnoreScopeVersion(), - pmetrictest.IgnoreResourceMetricsOrder(), - pmetrictest.IgnoreMetricValues(), - ) - assert.NoError(tt, err) + + metricsFound := 0 + m := tc.OTLPReceiverSink.AllMetrics()[len(tc.OTLPReceiverSink.AllMetrics())-1] + for i := 0; i < m.ResourceMetrics().Len(); i++ { + rm := m.ResourceMetrics().At(i) + for j := 0; j < rm.ScopeMetrics().Len(); j++ { + sm := rm.ScopeMetrics().At(j) + for k := 0; k < sm.Metrics().Len(); k++ { + metric := sm.Metrics().At(k) + + if metric.Name() == "counter.amq.TotalConnectionsCount" || metric.Name() == "jmx_memory.committed" { + metricsFound++ + } + } + } + } + assert.Equal(tt, 2, metricsFound) }, 30*time.Second, 1*time.Second) } @@ -278,31 +270,25 @@ func TestNonDefaultGIDCanAccessPythonInAgentBundle(t *testing.T) { ) defer shutdown() - expected, err := golden.ReadMetrics(filepath.Join("testdata", "expected", "solr.yaml")) - require.NoError(t, err) require.EventuallyWithT(t, func(tt *assert.CollectT) { if len(tc.OTLPReceiverSink.AllMetrics()) == 0 { assert.Fail(tt, "No metrics collected") return } - err := pmetrictest.CompareMetrics(expected, tc.OTLPReceiverSink.AllMetrics()[len(tc.OTLPReceiverSink.AllMetrics())-1], - pmetrictest.IgnoreResourceAttributeValue("service.instance.id"), - pmetrictest.IgnoreResourceAttributeValue("net.host.port"), - pmetrictest.IgnoreResourceAttributeValue("net.host.name"), - pmetrictest.IgnoreResourceAttributeValue("server.address"), - pmetrictest.IgnoreResourceAttributeValue("container.name"), - pmetrictest.IgnoreResourceAttributeValue("server.port"), - pmetrictest.IgnoreResourceAttributeValue("service.name"), - pmetrictest.IgnoreResourceAttributeValue("service_instance_id"), - pmetrictest.IgnoreResourceAttributeValue("service_version"), - pmetrictest.IgnoreTimestamp(), - pmetrictest.IgnoreStartTimestamp(), - pmetrictest.IgnoreMetricDataPointsOrder(), - pmetrictest.IgnoreScopeMetricsOrder(), - pmetrictest.IgnoreScopeVersion(), - pmetrictest.IgnoreResourceMetricsOrder(), - pmetrictest.IgnoreMetricValues(), - ) - assert.NoError(tt, err) + metricsFound := 0 + m := tc.OTLPReceiverSink.AllMetrics()[len(tc.OTLPReceiverSink.AllMetrics())-1] + for i := 0; i < m.ResourceMetrics().Len(); i++ { + rm := m.ResourceMetrics().At(i) + for j := 0; j < rm.ScopeMetrics().Len(); j++ { + sm := rm.ScopeMetrics().At(j) + for k := 0; k < sm.Metrics().Len(); k++ { + metric := sm.Metrics().At(k) + if metric.Name() == "counter.solr.http_2xx_responses" { + metricsFound++ + } + } + } + } + assert.Equal(tt, 1, metricsFound) }, 30*time.Second, 1*time.Second) } diff --git a/tests/general/testdata/expected/activemq.yaml b/tests/general/testdata/expected/activemq.yaml deleted file mode 100644 index 7a1cf0c739..0000000000 --- a/tests/general/testdata/expected/activemq.yaml +++ /dev/null @@ -1,77 +0,0 @@ -resourceMetrics: - - resource: {} - scopeMetrics: - - metrics: - - gauge: - dataPoints: - - asInt: "3801088" - attributes: - - key: dsname - value: - stringValue: value - - key: host - value: - stringValue: docker-desktop - - key: hostHasService - value: - stringValue: activemq - - key: plugin - value: - stringValue: GenericJMX - - key: plugin_instance - value: - stringValue: memory_pool-Compressed Class Space - - key: system.type - value: - stringValue: activemq - timeUnixNano: "1000000" - name: jmx_memory.committed - - gauge: - dataPoints: - - asInt: "12189696" - attributes: - - key: dsname - value: - stringValue: value - - key: host - value: - stringValue: docker-desktop - - key: hostHasService - value: - stringValue: activemq - - key: plugin - value: - stringValue: GenericJMX - - key: plugin_instance - value: - stringValue: memory_pool-Code Cache - - key: system.type - value: - stringValue: activemq - timeUnixNano: "1000000" - name: jmx_memory.committed - - gauge: - dataPoints: - - asInt: "7864320" - attributes: - - key: dsname - value: - stringValue: value - - key: host - value: - stringValue: docker-desktop - - key: hostHasService - value: - stringValue: activemq - - key: plugin - value: - stringValue: GenericJMX - - key: plugin_instance - value: - stringValue: memory_pool-PS Survivor Space - - key: system.type - value: - stringValue: activemq - timeUnixNano: "1000000" - name: jmx_memory.committed - scope: {} diff --git a/tests/general/testdata/expected/solr.yaml b/tests/general/testdata/expected/solr.yaml deleted file mode 100644 index e3e8ab70dd..0000000000 --- a/tests/general/testdata/expected/solr.yaml +++ /dev/null @@ -1,43 +0,0 @@ -resourceMetrics: - - resource: {} - scopeMetrics: - - metrics: - - name: counter.solr.http_2xx_responses - sum: - aggregationTemporality: 2 - dataPoints: - - asInt: "38" - attributes: - - key: cluster - value: - stringValue: default - - key: collection - value: - stringValue: techproducts - - key: core - value: - stringValue: techproducts_shard1_replica_n1 - - key: dsname - value: - stringValue: value - - key: leader - value: - stringValue: "true" - - key: node - value: - stringValue: localhost:8983_solr - - key: plugin - value: - stringValue: solr - - key: plugin_instance - value: - stringValue: localhost:8983 - - key: shard - value: - stringValue: shard1 - - key: system.type - value: - stringValue: solr - timeUnixNano: "1000000" - isMonotonic: true - scope: {} From 0c098db3993a4974c585beb46814d255e629c7df Mon Sep 17 00:00:00 2001 From: Antoine Toulme Date: Sat, 11 Jan 2025 17:57:32 -0800 Subject: [PATCH 4/6] fix the test some more --- tests/general/container_test.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/general/container_test.go b/tests/general/container_test.go index c7b991d2f1..3cc97ee7ea 100644 --- a/tests/general/container_test.go +++ b/tests/general/container_test.go @@ -236,7 +236,7 @@ func TestNonDefaultGIDCanAccessJavaInAgentBundle(t *testing.T) { return } - metricsFound := 0 + var metricsFound map[string]struct{} m := tc.OTLPReceiverSink.AllMetrics()[len(tc.OTLPReceiverSink.AllMetrics())-1] for i := 0; i < m.ResourceMetrics().Len(); i++ { rm := m.ResourceMetrics().At(i) @@ -246,12 +246,12 @@ func TestNonDefaultGIDCanAccessJavaInAgentBundle(t *testing.T) { metric := sm.Metrics().At(k) if metric.Name() == "counter.amq.TotalConnectionsCount" || metric.Name() == "jmx_memory.committed" { - metricsFound++ + metricsFound[metric.Name()] = struct{}{} } } } } - assert.Equal(tt, 2, metricsFound) + assert.Equal(tt, 2, len(metricsFound)) }, 30*time.Second, 1*time.Second) } @@ -275,7 +275,7 @@ func TestNonDefaultGIDCanAccessPythonInAgentBundle(t *testing.T) { assert.Fail(tt, "No metrics collected") return } - metricsFound := 0 + var metricsFound map[string]struct{} m := tc.OTLPReceiverSink.AllMetrics()[len(tc.OTLPReceiverSink.AllMetrics())-1] for i := 0; i < m.ResourceMetrics().Len(); i++ { rm := m.ResourceMetrics().At(i) @@ -284,11 +284,11 @@ func TestNonDefaultGIDCanAccessPythonInAgentBundle(t *testing.T) { for k := 0; k < sm.Metrics().Len(); k++ { metric := sm.Metrics().At(k) if metric.Name() == "counter.solr.http_2xx_responses" { - metricsFound++ + metricsFound[metric.Name()] = struct{}{} } } } } - assert.Equal(tt, 1, metricsFound) + assert.Equal(tt, 1, len(metricsFound)) }, 30*time.Second, 1*time.Second) } From 3fe97f1302c0c602cd6b8e4bdf4dcf45d1f7851c Mon Sep 17 00:00:00 2001 From: Antoine Toulme Date: Sat, 11 Jan 2025 22:43:04 -0800 Subject: [PATCH 5/6] fix bad go code --- tests/general/container_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/general/container_test.go b/tests/general/container_test.go index 3cc97ee7ea..372db62314 100644 --- a/tests/general/container_test.go +++ b/tests/general/container_test.go @@ -236,7 +236,7 @@ func TestNonDefaultGIDCanAccessJavaInAgentBundle(t *testing.T) { return } - var metricsFound map[string]struct{} + metricsFound := map[string]struct{}{} m := tc.OTLPReceiverSink.AllMetrics()[len(tc.OTLPReceiverSink.AllMetrics())-1] for i := 0; i < m.ResourceMetrics().Len(); i++ { rm := m.ResourceMetrics().At(i) @@ -275,7 +275,7 @@ func TestNonDefaultGIDCanAccessPythonInAgentBundle(t *testing.T) { assert.Fail(tt, "No metrics collected") return } - var metricsFound map[string]struct{} + metricsFound := map[string]struct{}{} m := tc.OTLPReceiverSink.AllMetrics()[len(tc.OTLPReceiverSink.AllMetrics())-1] for i := 0; i < m.ResourceMetrics().Len(); i++ { rm := m.ResourceMetrics().At(i) From b234edf1b65a5e1e370434b926c868a635759abb Mon Sep 17 00:00:00 2001 From: Antoine Toulme Date: Sat, 11 Jan 2025 23:22:38 -0800 Subject: [PATCH 6/6] fix some more --- tests/general/container_test.go | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/tests/general/container_test.go b/tests/general/container_test.go index 372db62314..b43836effb 100644 --- a/tests/general/container_test.go +++ b/tests/general/container_test.go @@ -237,16 +237,17 @@ func TestNonDefaultGIDCanAccessJavaInAgentBundle(t *testing.T) { } metricsFound := map[string]struct{}{} - m := tc.OTLPReceiverSink.AllMetrics()[len(tc.OTLPReceiverSink.AllMetrics())-1] - for i := 0; i < m.ResourceMetrics().Len(); i++ { - rm := m.ResourceMetrics().At(i) - for j := 0; j < rm.ScopeMetrics().Len(); j++ { - sm := rm.ScopeMetrics().At(j) - for k := 0; k < sm.Metrics().Len(); k++ { - metric := sm.Metrics().At(k) + for _, m := range tc.OTLPReceiverSink.AllMetrics() { + for i := 0; i < m.ResourceMetrics().Len(); i++ { + rm := m.ResourceMetrics().At(i) + for j := 0; j < rm.ScopeMetrics().Len(); j++ { + sm := rm.ScopeMetrics().At(j) + for k := 0; k < sm.Metrics().Len(); k++ { + metric := sm.Metrics().At(k) - if metric.Name() == "counter.amq.TotalConnectionsCount" || metric.Name() == "jmx_memory.committed" { - metricsFound[metric.Name()] = struct{}{} + if metric.Name() == "counter.amq.TotalConnectionsCount" || metric.Name() == "jmx_memory.committed" { + metricsFound[metric.Name()] = struct{}{} + } } } }