From 03f89abffa51877f15e9ce324e641f2bec2ed725 Mon Sep 17 00:00:00 2001 From: singhvibhanshu Date: Wed, 25 Feb 2026 19:00:54 +0530 Subject: [PATCH 1/3] [receiver/vcenter] Enable re-aggregation feature Signed-off-by: singhvibhanshu --- .chloggen/enable-re-aggregation-feat.yaml | 27 + .../vcenterreceiver/generated_package_test.go | 3 +- .../internal/metadata/generated_config.go | 386 ++ .../metadata/generated_config_test.go | 853 +++- .../internal/metadata/generated_metrics.go | 3283 +++++++++++-- .../metadata/generated_metrics_test.go | 4237 +++++++++++++---- .../internal/metadata/testdata/config.yaml | 382 ++ receiver/vcenterreceiver/metadata.yaml | 18 +- 8 files changed, 7679 insertions(+), 1510 deletions(-) create mode 100644 .chloggen/enable-re-aggregation-feat.yaml diff --git a/.chloggen/enable-re-aggregation-feat.yaml b/.chloggen/enable-re-aggregation-feat.yaml new file mode 100644 index 0000000000000..dd0559ae687e1 --- /dev/null +++ b/.chloggen/enable-re-aggregation-feat.yaml @@ -0,0 +1,27 @@ +# Use this changelog template to create an entry for release notes. + +# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' +change_type: enhancement + +# The name of the component, or a single word describing the area of concern, (e.g. receiver/filelog) +component: receiver/vcenter + +# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). +note: Enable re-aggregation feature for vcenter receiver metrics + +# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists. +issues: [46384] + +# (Optional) One or more lines of additional information to render under the primary note. +# These lines will be padded with 2 spaces and then inserted directly into the document. +# Use pipe (|) for multiline entries. +subtext: + +# If your change doesn't affect end users or the exported elements of any package, +# you should instead start your pull request title with [chore] or use the "Skip Changelog" label. +# Optional: The change log or logs in which this entry should be included. +# e.g. '[user]' or '[user, api]' +# Include 'user' if the change is relevant to end users. +# Include 'api' if there is a change to a library API. +# Default: '[user]' +change_logs: [] diff --git a/receiver/vcenterreceiver/generated_package_test.go b/receiver/vcenterreceiver/generated_package_test.go index 41cb84e7dcaef..b9f3211ba0b28 100644 --- a/receiver/vcenterreceiver/generated_package_test.go +++ b/receiver/vcenterreceiver/generated_package_test.go @@ -3,9 +3,8 @@ package vcenterreceiver import ( - "testing" - "go.uber.org/goleak" + "testing" ) func TestMain(m *testing.M) { diff --git a/receiver/vcenterreceiver/internal/metadata/generated_config.go b/receiver/vcenterreceiver/internal/metadata/generated_config.go index 2a59b5296fd36..f1b557e8776ea 100644 --- a/receiver/vcenterreceiver/internal/metadata/generated_config.go +++ b/receiver/vcenterreceiver/internal/metadata/generated_config.go @@ -3,6 +3,9 @@ package metadata import ( + "fmt" + "slices" + "go.opentelemetry.io/collector/confmap" "go.opentelemetry.io/collector/filter" ) @@ -11,6 +14,11 @@ import ( type MetricConfig struct { Enabled bool `mapstructure:"enabled"` enabledSetByUser bool + + AggregationStrategy string `mapstructure:"aggregation_strategy"` + EnabledAttributes []string `mapstructure:"attributes"` + definedAttributes []string + requiredAttributes []string } func (ms *MetricConfig) Unmarshal(parser *confmap.Conf) error { @@ -22,11 +30,34 @@ func (ms *MetricConfig) Unmarshal(parser *confmap.Conf) error { if err != nil { return err } + for _, val := range ms.EnabledAttributes { + if !slices.Contains(ms.definedAttributes, val) { + return fmt.Errorf("%v is not defined in metadata.yaml", val) + } + } + + for _, val := range ms.requiredAttributes { + if !slices.Contains(ms.EnabledAttributes, val) { + return fmt.Errorf("`attributes` field must contain required attribute: %v", val) + } + } + + if ms.AggregationStrategy != AggregationStrategySum && + ms.AggregationStrategy != AggregationStrategyAvg && + ms.AggregationStrategy != AggregationStrategyMin && + ms.AggregationStrategy != AggregationStrategyMax { + return fmt.Errorf("invalid aggregation strategy set: '%v'", ms.AggregationStrategy) + } ms.enabledSetByUser = parser.IsSet("enabled") return nil } +// AttributeConfig holds configuration information for a particular metric. +type AttributeConfig struct { + Enabled bool `mapstructure:"enabled"` +} + // MetricsConfig provides config for vcenter metrics. type MetricsConfig struct { VcenterClusterCPUEffective MetricConfig `mapstructure:"vcenter.cluster.cpu.effective"` @@ -106,216 +137,571 @@ func DefaultMetricsConfig() MetricsConfig { return MetricsConfig{ VcenterClusterCPUEffective: MetricConfig{ Enabled: true, + + AggregationStrategy: AggregationStrategySum, + requiredAttributes: []string{}, + definedAttributes: []string{}, + EnabledAttributes: []string{}, }, VcenterClusterCPULimit: MetricConfig{ Enabled: true, + + AggregationStrategy: AggregationStrategySum, + requiredAttributes: []string{}, + definedAttributes: []string{}, + EnabledAttributes: []string{}, }, VcenterClusterHostCount: MetricConfig{ Enabled: true, + + AggregationStrategy: AggregationStrategySum, + requiredAttributes: []string{}, + definedAttributes: []string{"effective"}, + EnabledAttributes: []string{"effective"}, }, VcenterClusterMemoryEffective: MetricConfig{ Enabled: true, + + AggregationStrategy: AggregationStrategySum, + requiredAttributes: []string{}, + definedAttributes: []string{}, + EnabledAttributes: []string{}, }, VcenterClusterMemoryLimit: MetricConfig{ Enabled: true, + + AggregationStrategy: AggregationStrategySum, + requiredAttributes: []string{}, + definedAttributes: []string{}, + EnabledAttributes: []string{}, }, VcenterClusterVMCount: MetricConfig{ Enabled: true, + + AggregationStrategy: AggregationStrategySum, + requiredAttributes: []string{}, + definedAttributes: []string{"power_state"}, + EnabledAttributes: []string{"power_state"}, }, VcenterClusterVMTemplateCount: MetricConfig{ Enabled: true, + + AggregationStrategy: AggregationStrategySum, + requiredAttributes: []string{}, + definedAttributes: []string{}, + EnabledAttributes: []string{}, }, VcenterClusterVsanCongestions: MetricConfig{ Enabled: true, + + AggregationStrategy: AggregationStrategyAvg, + requiredAttributes: []string{}, + definedAttributes: []string{}, + EnabledAttributes: []string{}, }, VcenterClusterVsanLatencyAvg: MetricConfig{ Enabled: true, + + AggregationStrategy: AggregationStrategyAvg, + requiredAttributes: []string{}, + definedAttributes: []string{"type"}, + EnabledAttributes: []string{"type"}, }, VcenterClusterVsanOperations: MetricConfig{ Enabled: true, + + AggregationStrategy: AggregationStrategyAvg, + requiredAttributes: []string{}, + definedAttributes: []string{"type"}, + EnabledAttributes: []string{"type"}, }, VcenterClusterVsanThroughput: MetricConfig{ Enabled: true, + + AggregationStrategy: AggregationStrategyAvg, + requiredAttributes: []string{}, + definedAttributes: []string{"direction"}, + EnabledAttributes: []string{"direction"}, }, VcenterDatacenterClusterCount: MetricConfig{ Enabled: true, + + AggregationStrategy: AggregationStrategySum, + requiredAttributes: []string{}, + definedAttributes: []string{"status"}, + EnabledAttributes: []string{"status"}, }, VcenterDatacenterCPULimit: MetricConfig{ Enabled: true, + + AggregationStrategy: AggregationStrategySum, + requiredAttributes: []string{}, + definedAttributes: []string{}, + EnabledAttributes: []string{}, }, VcenterDatacenterDatastoreCount: MetricConfig{ Enabled: true, + + AggregationStrategy: AggregationStrategySum, + requiredAttributes: []string{}, + definedAttributes: []string{}, + EnabledAttributes: []string{}, }, VcenterDatacenterDiskSpace: MetricConfig{ Enabled: true, + + AggregationStrategy: AggregationStrategySum, + requiredAttributes: []string{}, + definedAttributes: []string{"disk_state"}, + EnabledAttributes: []string{"disk_state"}, }, VcenterDatacenterHostCount: MetricConfig{ Enabled: true, + + AggregationStrategy: AggregationStrategySum, + requiredAttributes: []string{}, + definedAttributes: []string{"status", "power_state"}, + EnabledAttributes: []string{"status", "power_state"}, }, VcenterDatacenterMemoryLimit: MetricConfig{ Enabled: true, + + AggregationStrategy: AggregationStrategySum, + requiredAttributes: []string{}, + definedAttributes: []string{}, + EnabledAttributes: []string{}, }, VcenterDatacenterVMCount: MetricConfig{ Enabled: true, + + AggregationStrategy: AggregationStrategySum, + requiredAttributes: []string{}, + definedAttributes: []string{"status", "power_state"}, + EnabledAttributes: []string{"status", "power_state"}, }, VcenterDatastoreDiskUsage: MetricConfig{ Enabled: true, + + AggregationStrategy: AggregationStrategySum, + requiredAttributes: []string{}, + definedAttributes: []string{"disk_state"}, + EnabledAttributes: []string{"disk_state"}, }, VcenterDatastoreDiskUtilization: MetricConfig{ Enabled: true, + + AggregationStrategy: AggregationStrategyAvg, + requiredAttributes: []string{}, + definedAttributes: []string{}, + EnabledAttributes: []string{}, }, VcenterHostCPUCapacity: MetricConfig{ Enabled: true, + + AggregationStrategy: AggregationStrategySum, + requiredAttributes: []string{}, + definedAttributes: []string{}, + EnabledAttributes: []string{}, }, VcenterHostCPUReserved: MetricConfig{ Enabled: true, + + AggregationStrategy: AggregationStrategySum, + requiredAttributes: []string{}, + definedAttributes: []string{"cpu_reservation_type"}, + EnabledAttributes: []string{"cpu_reservation_type"}, }, VcenterHostCPUUsage: MetricConfig{ Enabled: true, + + AggregationStrategy: AggregationStrategySum, + requiredAttributes: []string{}, + definedAttributes: []string{}, + EnabledAttributes: []string{}, }, VcenterHostCPUUtilization: MetricConfig{ Enabled: true, + + AggregationStrategy: AggregationStrategyAvg, + requiredAttributes: []string{}, + definedAttributes: []string{}, + EnabledAttributes: []string{}, }, VcenterHostDiskLatencyAvg: MetricConfig{ Enabled: true, + + AggregationStrategy: AggregationStrategyAvg, + requiredAttributes: []string{}, + definedAttributes: []string{"direction", "object"}, + EnabledAttributes: []string{"direction", "object"}, }, VcenterHostDiskLatencyMax: MetricConfig{ Enabled: true, + + AggregationStrategy: AggregationStrategyAvg, + requiredAttributes: []string{}, + definedAttributes: []string{"object"}, + EnabledAttributes: []string{"object"}, }, VcenterHostDiskThroughput: MetricConfig{ Enabled: true, + + AggregationStrategy: AggregationStrategySum, + requiredAttributes: []string{}, + definedAttributes: []string{"direction", "object"}, + EnabledAttributes: []string{"direction", "object"}, }, VcenterHostMemoryCapacity: MetricConfig{ Enabled: false, + + AggregationStrategy: AggregationStrategySum, + requiredAttributes: []string{}, + definedAttributes: []string{}, + EnabledAttributes: []string{}, }, VcenterHostMemoryUsage: MetricConfig{ Enabled: true, + + AggregationStrategy: AggregationStrategySum, + requiredAttributes: []string{}, + definedAttributes: []string{}, + EnabledAttributes: []string{}, }, VcenterHostMemoryUtilization: MetricConfig{ Enabled: true, + + AggregationStrategy: AggregationStrategyAvg, + requiredAttributes: []string{}, + definedAttributes: []string{}, + EnabledAttributes: []string{}, }, VcenterHostNetworkPacketDropRate: MetricConfig{ Enabled: true, + + AggregationStrategy: AggregationStrategyAvg, + requiredAttributes: []string{}, + definedAttributes: []string{"direction", "object"}, + EnabledAttributes: []string{"direction", "object"}, }, VcenterHostNetworkPacketErrorRate: MetricConfig{ Enabled: true, + + AggregationStrategy: AggregationStrategyAvg, + requiredAttributes: []string{}, + definedAttributes: []string{"direction", "object"}, + EnabledAttributes: []string{"direction", "object"}, }, VcenterHostNetworkPacketRate: MetricConfig{ Enabled: true, + + AggregationStrategy: AggregationStrategyAvg, + requiredAttributes: []string{}, + definedAttributes: []string{"direction", "object"}, + EnabledAttributes: []string{"direction", "object"}, }, VcenterHostNetworkThroughput: MetricConfig{ Enabled: true, + + AggregationStrategy: AggregationStrategySum, + requiredAttributes: []string{}, + definedAttributes: []string{"direction", "object"}, + EnabledAttributes: []string{"direction", "object"}, }, VcenterHostNetworkUsage: MetricConfig{ Enabled: true, + + AggregationStrategy: AggregationStrategySum, + requiredAttributes: []string{}, + definedAttributes: []string{"object"}, + EnabledAttributes: []string{"object"}, }, VcenterHostVsanCacheHitRate: MetricConfig{ Enabled: true, + + AggregationStrategy: AggregationStrategyAvg, + requiredAttributes: []string{}, + definedAttributes: []string{}, + EnabledAttributes: []string{}, }, VcenterHostVsanCongestions: MetricConfig{ Enabled: true, + + AggregationStrategy: AggregationStrategyAvg, + requiredAttributes: []string{}, + definedAttributes: []string{}, + EnabledAttributes: []string{}, }, VcenterHostVsanLatencyAvg: MetricConfig{ Enabled: true, + + AggregationStrategy: AggregationStrategyAvg, + requiredAttributes: []string{}, + definedAttributes: []string{"type"}, + EnabledAttributes: []string{"type"}, }, VcenterHostVsanOperations: MetricConfig{ Enabled: true, + + AggregationStrategy: AggregationStrategyAvg, + requiredAttributes: []string{}, + definedAttributes: []string{"type"}, + EnabledAttributes: []string{"type"}, }, VcenterHostVsanThroughput: MetricConfig{ Enabled: true, + + AggregationStrategy: AggregationStrategyAvg, + requiredAttributes: []string{}, + definedAttributes: []string{"direction"}, + EnabledAttributes: []string{"direction"}, }, VcenterResourcePoolCPUShares: MetricConfig{ Enabled: true, + + AggregationStrategy: AggregationStrategySum, + requiredAttributes: []string{}, + definedAttributes: []string{}, + EnabledAttributes: []string{}, }, VcenterResourcePoolCPUUsage: MetricConfig{ Enabled: true, + + AggregationStrategy: AggregationStrategySum, + requiredAttributes: []string{}, + definedAttributes: []string{}, + EnabledAttributes: []string{}, }, VcenterResourcePoolMemoryBallooned: MetricConfig{ Enabled: true, + + AggregationStrategy: AggregationStrategySum, + requiredAttributes: []string{}, + definedAttributes: []string{}, + EnabledAttributes: []string{}, }, VcenterResourcePoolMemoryGranted: MetricConfig{ Enabled: true, + + AggregationStrategy: AggregationStrategySum, + requiredAttributes: []string{}, + definedAttributes: []string{"type"}, + EnabledAttributes: []string{"type"}, }, VcenterResourcePoolMemoryShares: MetricConfig{ Enabled: true, + + AggregationStrategy: AggregationStrategySum, + requiredAttributes: []string{}, + definedAttributes: []string{}, + EnabledAttributes: []string{}, }, VcenterResourcePoolMemorySwapped: MetricConfig{ Enabled: true, + + AggregationStrategy: AggregationStrategySum, + requiredAttributes: []string{}, + definedAttributes: []string{}, + EnabledAttributes: []string{}, }, VcenterResourcePoolMemoryUsage: MetricConfig{ Enabled: true, + + AggregationStrategy: AggregationStrategySum, + requiredAttributes: []string{}, + definedAttributes: []string{"type"}, + EnabledAttributes: []string{"type"}, }, VcenterVMCPUReadiness: MetricConfig{ Enabled: true, + + AggregationStrategy: AggregationStrategyAvg, + requiredAttributes: []string{}, + definedAttributes: []string{}, + EnabledAttributes: []string{}, }, VcenterVMCPUTime: MetricConfig{ Enabled: false, + + AggregationStrategy: AggregationStrategyAvg, + requiredAttributes: []string{}, + definedAttributes: []string{"cpu_state", "object"}, + EnabledAttributes: []string{"cpu_state", "object"}, }, VcenterVMCPUUsage: MetricConfig{ Enabled: true, + + AggregationStrategy: AggregationStrategySum, + requiredAttributes: []string{}, + definedAttributes: []string{}, + EnabledAttributes: []string{}, }, VcenterVMCPUUtilization: MetricConfig{ Enabled: true, + + AggregationStrategy: AggregationStrategyAvg, + requiredAttributes: []string{}, + definedAttributes: []string{}, + EnabledAttributes: []string{}, }, VcenterVMDiskLatencyAvg: MetricConfig{ Enabled: true, + + AggregationStrategy: AggregationStrategyAvg, + requiredAttributes: []string{}, + definedAttributes: []string{"direction", "disk_type", "object"}, + EnabledAttributes: []string{"direction", "disk_type", "object"}, }, VcenterVMDiskLatencyMax: MetricConfig{ Enabled: true, + + AggregationStrategy: AggregationStrategyAvg, + requiredAttributes: []string{}, + definedAttributes: []string{"object"}, + EnabledAttributes: []string{"object"}, }, VcenterVMDiskThroughput: MetricConfig{ Enabled: true, + + AggregationStrategy: AggregationStrategyAvg, + requiredAttributes: []string{}, + definedAttributes: []string{"direction", "object"}, + EnabledAttributes: []string{"direction", "object"}, }, VcenterVMDiskUsage: MetricConfig{ Enabled: true, + + AggregationStrategy: AggregationStrategySum, + requiredAttributes: []string{}, + definedAttributes: []string{"disk_state"}, + EnabledAttributes: []string{"disk_state"}, }, VcenterVMDiskUtilization: MetricConfig{ Enabled: true, + + AggregationStrategy: AggregationStrategyAvg, + requiredAttributes: []string{}, + definedAttributes: []string{}, + EnabledAttributes: []string{}, }, VcenterVMMemoryBallooned: MetricConfig{ Enabled: true, + + AggregationStrategy: AggregationStrategySum, + requiredAttributes: []string{}, + definedAttributes: []string{}, + EnabledAttributes: []string{}, }, VcenterVMMemoryGranted: MetricConfig{ Enabled: false, + + AggregationStrategy: AggregationStrategySum, + requiredAttributes: []string{}, + definedAttributes: []string{}, + EnabledAttributes: []string{}, }, VcenterVMMemorySwapped: MetricConfig{ Enabled: true, + + AggregationStrategy: AggregationStrategySum, + requiredAttributes: []string{}, + definedAttributes: []string{}, + EnabledAttributes: []string{}, }, VcenterVMMemorySwappedSsd: MetricConfig{ Enabled: true, + + AggregationStrategy: AggregationStrategySum, + requiredAttributes: []string{}, + definedAttributes: []string{}, + EnabledAttributes: []string{}, }, VcenterVMMemoryUsage: MetricConfig{ Enabled: true, + + AggregationStrategy: AggregationStrategySum, + requiredAttributes: []string{}, + definedAttributes: []string{}, + EnabledAttributes: []string{}, }, VcenterVMMemoryUtilization: MetricConfig{ Enabled: true, + + AggregationStrategy: AggregationStrategyAvg, + requiredAttributes: []string{}, + definedAttributes: []string{}, + EnabledAttributes: []string{}, }, VcenterVMNetworkBroadcastPacketRate: MetricConfig{ Enabled: false, + + AggregationStrategy: AggregationStrategyAvg, + requiredAttributes: []string{}, + definedAttributes: []string{"direction", "object"}, + EnabledAttributes: []string{"direction", "object"}, }, VcenterVMNetworkMulticastPacketRate: MetricConfig{ Enabled: false, + + AggregationStrategy: AggregationStrategyAvg, + requiredAttributes: []string{}, + definedAttributes: []string{"direction", "object"}, + EnabledAttributes: []string{"direction", "object"}, }, VcenterVMNetworkPacketDropRate: MetricConfig{ Enabled: true, + + AggregationStrategy: AggregationStrategyAvg, + requiredAttributes: []string{}, + definedAttributes: []string{"direction", "object"}, + EnabledAttributes: []string{"direction", "object"}, }, VcenterVMNetworkPacketRate: MetricConfig{ Enabled: true, + + AggregationStrategy: AggregationStrategyAvg, + requiredAttributes: []string{}, + definedAttributes: []string{"direction", "object"}, + EnabledAttributes: []string{"direction", "object"}, }, VcenterVMNetworkThroughput: MetricConfig{ Enabled: true, + + AggregationStrategy: AggregationStrategySum, + requiredAttributes: []string{}, + definedAttributes: []string{"direction", "object"}, + EnabledAttributes: []string{"direction", "object"}, }, VcenterVMNetworkUsage: MetricConfig{ Enabled: true, + + AggregationStrategy: AggregationStrategySum, + requiredAttributes: []string{}, + definedAttributes: []string{"object"}, + EnabledAttributes: []string{"object"}, }, VcenterVMVsanLatencyAvg: MetricConfig{ Enabled: true, + + AggregationStrategy: AggregationStrategyAvg, + requiredAttributes: []string{}, + definedAttributes: []string{"type"}, + EnabledAttributes: []string{"type"}, }, VcenterVMVsanOperations: MetricConfig{ Enabled: true, + + AggregationStrategy: AggregationStrategyAvg, + requiredAttributes: []string{}, + definedAttributes: []string{"type"}, + EnabledAttributes: []string{"type"}, }, VcenterVMVsanThroughput: MetricConfig{ Enabled: true, + + AggregationStrategy: AggregationStrategyAvg, + requiredAttributes: []string{}, + definedAttributes: []string{"direction"}, + EnabledAttributes: []string{"direction"}, }, } } diff --git a/receiver/vcenterreceiver/internal/metadata/generated_config_test.go b/receiver/vcenterreceiver/internal/metadata/generated_config_test.go index 05f1538247ca8..9c8691255db7c 100644 --- a/receiver/vcenterreceiver/internal/metadata/generated_config_test.go +++ b/receiver/vcenterreceiver/internal/metadata/generated_config_test.go @@ -9,6 +9,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/stretchr/testify/require" + "go.opentelemetry.io/collector/confmap" "go.opentelemetry.io/collector/confmap/confmaptest" ) @@ -26,77 +27,361 @@ func TestMetricsBuilderConfig(t *testing.T) { name: "all_set", want: MetricsBuilderConfig{ Metrics: MetricsConfig{ - VcenterClusterCPUEffective: MetricConfig{Enabled: true}, - VcenterClusterCPULimit: MetricConfig{Enabled: true}, - VcenterClusterHostCount: MetricConfig{Enabled: true}, - VcenterClusterMemoryEffective: MetricConfig{Enabled: true}, - VcenterClusterMemoryLimit: MetricConfig{Enabled: true}, - VcenterClusterVMCount: MetricConfig{Enabled: true}, - VcenterClusterVMTemplateCount: MetricConfig{Enabled: true}, - VcenterClusterVsanCongestions: MetricConfig{Enabled: true}, - VcenterClusterVsanLatencyAvg: MetricConfig{Enabled: true}, - VcenterClusterVsanOperations: MetricConfig{Enabled: true}, - VcenterClusterVsanThroughput: MetricConfig{Enabled: true}, - VcenterDatacenterClusterCount: MetricConfig{Enabled: true}, - VcenterDatacenterCPULimit: MetricConfig{Enabled: true}, - VcenterDatacenterDatastoreCount: MetricConfig{Enabled: true}, - VcenterDatacenterDiskSpace: MetricConfig{Enabled: true}, - VcenterDatacenterHostCount: MetricConfig{Enabled: true}, - VcenterDatacenterMemoryLimit: MetricConfig{Enabled: true}, - VcenterDatacenterVMCount: MetricConfig{Enabled: true}, - VcenterDatastoreDiskUsage: MetricConfig{Enabled: true}, - VcenterDatastoreDiskUtilization: MetricConfig{Enabled: true}, - VcenterHostCPUCapacity: MetricConfig{Enabled: true}, - VcenterHostCPUReserved: MetricConfig{Enabled: true}, - VcenterHostCPUUsage: MetricConfig{Enabled: true}, - VcenterHostCPUUtilization: MetricConfig{Enabled: true}, - VcenterHostDiskLatencyAvg: MetricConfig{Enabled: true}, - VcenterHostDiskLatencyMax: MetricConfig{Enabled: true}, - VcenterHostDiskThroughput: MetricConfig{Enabled: true}, - VcenterHostMemoryCapacity: MetricConfig{Enabled: true}, - VcenterHostMemoryUsage: MetricConfig{Enabled: true}, - VcenterHostMemoryUtilization: MetricConfig{Enabled: true}, - VcenterHostNetworkPacketDropRate: MetricConfig{Enabled: true}, - VcenterHostNetworkPacketErrorRate: MetricConfig{Enabled: true}, - VcenterHostNetworkPacketRate: MetricConfig{Enabled: true}, - VcenterHostNetworkThroughput: MetricConfig{Enabled: true}, - VcenterHostNetworkUsage: MetricConfig{Enabled: true}, - VcenterHostVsanCacheHitRate: MetricConfig{Enabled: true}, - VcenterHostVsanCongestions: MetricConfig{Enabled: true}, - VcenterHostVsanLatencyAvg: MetricConfig{Enabled: true}, - VcenterHostVsanOperations: MetricConfig{Enabled: true}, - VcenterHostVsanThroughput: MetricConfig{Enabled: true}, - VcenterResourcePoolCPUShares: MetricConfig{Enabled: true}, - VcenterResourcePoolCPUUsage: MetricConfig{Enabled: true}, - VcenterResourcePoolMemoryBallooned: MetricConfig{Enabled: true}, - VcenterResourcePoolMemoryGranted: MetricConfig{Enabled: true}, - VcenterResourcePoolMemoryShares: MetricConfig{Enabled: true}, - VcenterResourcePoolMemorySwapped: MetricConfig{Enabled: true}, - VcenterResourcePoolMemoryUsage: MetricConfig{Enabled: true}, - VcenterVMCPUReadiness: MetricConfig{Enabled: true}, - VcenterVMCPUTime: MetricConfig{Enabled: true}, - VcenterVMCPUUsage: MetricConfig{Enabled: true}, - VcenterVMCPUUtilization: MetricConfig{Enabled: true}, - VcenterVMDiskLatencyAvg: MetricConfig{Enabled: true}, - VcenterVMDiskLatencyMax: MetricConfig{Enabled: true}, - VcenterVMDiskThroughput: MetricConfig{Enabled: true}, - VcenterVMDiskUsage: MetricConfig{Enabled: true}, - VcenterVMDiskUtilization: MetricConfig{Enabled: true}, - VcenterVMMemoryBallooned: MetricConfig{Enabled: true}, - VcenterVMMemoryGranted: MetricConfig{Enabled: true}, - VcenterVMMemorySwapped: MetricConfig{Enabled: true}, - VcenterVMMemorySwappedSsd: MetricConfig{Enabled: true}, - VcenterVMMemoryUsage: MetricConfig{Enabled: true}, - VcenterVMMemoryUtilization: MetricConfig{Enabled: true}, - VcenterVMNetworkBroadcastPacketRate: MetricConfig{Enabled: true}, - VcenterVMNetworkMulticastPacketRate: MetricConfig{Enabled: true}, - VcenterVMNetworkPacketDropRate: MetricConfig{Enabled: true}, - VcenterVMNetworkPacketRate: MetricConfig{Enabled: true}, - VcenterVMNetworkThroughput: MetricConfig{Enabled: true}, - VcenterVMNetworkUsage: MetricConfig{Enabled: true}, - VcenterVMVsanLatencyAvg: MetricConfig{Enabled: true}, - VcenterVMVsanOperations: MetricConfig{Enabled: true}, - VcenterVMVsanThroughput: MetricConfig{Enabled: true}, + VcenterClusterCPUEffective: MetricConfig{ + Enabled: true, + AggregationStrategy: AggregationStrategySum, + EnabledAttributes: []string{}, + }, + VcenterClusterCPULimit: MetricConfig{ + Enabled: true, + AggregationStrategy: AggregationStrategySum, + EnabledAttributes: []string{}, + }, + VcenterClusterHostCount: MetricConfig{ + Enabled: true, + AggregationStrategy: AggregationStrategySum, + EnabledAttributes: []string{"effective"}, + }, + VcenterClusterMemoryEffective: MetricConfig{ + Enabled: true, + AggregationStrategy: AggregationStrategySum, + EnabledAttributes: []string{}, + }, + VcenterClusterMemoryLimit: MetricConfig{ + Enabled: true, + AggregationStrategy: AggregationStrategySum, + EnabledAttributes: []string{}, + }, + VcenterClusterVMCount: MetricConfig{ + Enabled: true, + AggregationStrategy: AggregationStrategySum, + EnabledAttributes: []string{"power_state"}, + }, + VcenterClusterVMTemplateCount: MetricConfig{ + Enabled: true, + AggregationStrategy: AggregationStrategySum, + EnabledAttributes: []string{}, + }, + VcenterClusterVsanCongestions: MetricConfig{ + Enabled: true, + AggregationStrategy: AggregationStrategyAvg, + EnabledAttributes: []string{}, + }, + VcenterClusterVsanLatencyAvg: MetricConfig{ + Enabled: true, + AggregationStrategy: AggregationStrategyAvg, + EnabledAttributes: []string{"type"}, + }, + VcenterClusterVsanOperations: MetricConfig{ + Enabled: true, + AggregationStrategy: AggregationStrategyAvg, + EnabledAttributes: []string{"type"}, + }, + VcenterClusterVsanThroughput: MetricConfig{ + Enabled: true, + AggregationStrategy: AggregationStrategyAvg, + EnabledAttributes: []string{"direction"}, + }, + VcenterDatacenterClusterCount: MetricConfig{ + Enabled: true, + AggregationStrategy: AggregationStrategySum, + EnabledAttributes: []string{"status"}, + }, + VcenterDatacenterCPULimit: MetricConfig{ + Enabled: true, + AggregationStrategy: AggregationStrategySum, + EnabledAttributes: []string{}, + }, + VcenterDatacenterDatastoreCount: MetricConfig{ + Enabled: true, + AggregationStrategy: AggregationStrategySum, + EnabledAttributes: []string{}, + }, + VcenterDatacenterDiskSpace: MetricConfig{ + Enabled: true, + AggregationStrategy: AggregationStrategySum, + EnabledAttributes: []string{"disk_state"}, + }, + VcenterDatacenterHostCount: MetricConfig{ + Enabled: true, + AggregationStrategy: AggregationStrategySum, + EnabledAttributes: []string{"status", "power_state"}, + }, + VcenterDatacenterMemoryLimit: MetricConfig{ + Enabled: true, + AggregationStrategy: AggregationStrategySum, + EnabledAttributes: []string{}, + }, + VcenterDatacenterVMCount: MetricConfig{ + Enabled: true, + AggregationStrategy: AggregationStrategySum, + EnabledAttributes: []string{"status", "power_state"}, + }, + VcenterDatastoreDiskUsage: MetricConfig{ + Enabled: true, + AggregationStrategy: AggregationStrategySum, + EnabledAttributes: []string{"disk_state"}, + }, + VcenterDatastoreDiskUtilization: MetricConfig{ + Enabled: true, + AggregationStrategy: AggregationStrategyAvg, + EnabledAttributes: []string{}, + }, + VcenterHostCPUCapacity: MetricConfig{ + Enabled: true, + AggregationStrategy: AggregationStrategySum, + EnabledAttributes: []string{}, + }, + VcenterHostCPUReserved: MetricConfig{ + Enabled: true, + AggregationStrategy: AggregationStrategySum, + EnabledAttributes: []string{"cpu_reservation_type"}, + }, + VcenterHostCPUUsage: MetricConfig{ + Enabled: true, + AggregationStrategy: AggregationStrategySum, + EnabledAttributes: []string{}, + }, + VcenterHostCPUUtilization: MetricConfig{ + Enabled: true, + AggregationStrategy: AggregationStrategyAvg, + EnabledAttributes: []string{}, + }, + VcenterHostDiskLatencyAvg: MetricConfig{ + Enabled: true, + AggregationStrategy: AggregationStrategyAvg, + EnabledAttributes: []string{"direction", "object"}, + }, + VcenterHostDiskLatencyMax: MetricConfig{ + Enabled: true, + AggregationStrategy: AggregationStrategyAvg, + EnabledAttributes: []string{"object"}, + }, + VcenterHostDiskThroughput: MetricConfig{ + Enabled: true, + AggregationStrategy: AggregationStrategySum, + EnabledAttributes: []string{"direction", "object"}, + }, + VcenterHostMemoryCapacity: MetricConfig{ + Enabled: true, + AggregationStrategy: AggregationStrategySum, + EnabledAttributes: []string{}, + }, + VcenterHostMemoryUsage: MetricConfig{ + Enabled: true, + AggregationStrategy: AggregationStrategySum, + EnabledAttributes: []string{}, + }, + VcenterHostMemoryUtilization: MetricConfig{ + Enabled: true, + AggregationStrategy: AggregationStrategyAvg, + EnabledAttributes: []string{}, + }, + VcenterHostNetworkPacketDropRate: MetricConfig{ + Enabled: true, + AggregationStrategy: AggregationStrategyAvg, + EnabledAttributes: []string{"direction", "object"}, + }, + VcenterHostNetworkPacketErrorRate: MetricConfig{ + Enabled: true, + AggregationStrategy: AggregationStrategyAvg, + EnabledAttributes: []string{"direction", "object"}, + }, + VcenterHostNetworkPacketRate: MetricConfig{ + Enabled: true, + AggregationStrategy: AggregationStrategyAvg, + EnabledAttributes: []string{"direction", "object"}, + }, + VcenterHostNetworkThroughput: MetricConfig{ + Enabled: true, + AggregationStrategy: AggregationStrategySum, + EnabledAttributes: []string{"direction", "object"}, + }, + VcenterHostNetworkUsage: MetricConfig{ + Enabled: true, + AggregationStrategy: AggregationStrategySum, + EnabledAttributes: []string{"object"}, + }, + VcenterHostVsanCacheHitRate: MetricConfig{ + Enabled: true, + AggregationStrategy: AggregationStrategyAvg, + EnabledAttributes: []string{}, + }, + VcenterHostVsanCongestions: MetricConfig{ + Enabled: true, + AggregationStrategy: AggregationStrategyAvg, + EnabledAttributes: []string{}, + }, + VcenterHostVsanLatencyAvg: MetricConfig{ + Enabled: true, + AggregationStrategy: AggregationStrategyAvg, + EnabledAttributes: []string{"type"}, + }, + VcenterHostVsanOperations: MetricConfig{ + Enabled: true, + AggregationStrategy: AggregationStrategyAvg, + EnabledAttributes: []string{"type"}, + }, + VcenterHostVsanThroughput: MetricConfig{ + Enabled: true, + AggregationStrategy: AggregationStrategyAvg, + EnabledAttributes: []string{"direction"}, + }, + VcenterResourcePoolCPUShares: MetricConfig{ + Enabled: true, + AggregationStrategy: AggregationStrategySum, + EnabledAttributes: []string{}, + }, + VcenterResourcePoolCPUUsage: MetricConfig{ + Enabled: true, + AggregationStrategy: AggregationStrategySum, + EnabledAttributes: []string{}, + }, + VcenterResourcePoolMemoryBallooned: MetricConfig{ + Enabled: true, + AggregationStrategy: AggregationStrategySum, + EnabledAttributes: []string{}, + }, + VcenterResourcePoolMemoryGranted: MetricConfig{ + Enabled: true, + AggregationStrategy: AggregationStrategySum, + EnabledAttributes: []string{"type"}, + }, + VcenterResourcePoolMemoryShares: MetricConfig{ + Enabled: true, + AggregationStrategy: AggregationStrategySum, + EnabledAttributes: []string{}, + }, + VcenterResourcePoolMemorySwapped: MetricConfig{ + Enabled: true, + AggregationStrategy: AggregationStrategySum, + EnabledAttributes: []string{}, + }, + VcenterResourcePoolMemoryUsage: MetricConfig{ + Enabled: true, + AggregationStrategy: AggregationStrategySum, + EnabledAttributes: []string{"type"}, + }, + VcenterVMCPUReadiness: MetricConfig{ + Enabled: true, + AggregationStrategy: AggregationStrategyAvg, + EnabledAttributes: []string{}, + }, + VcenterVMCPUTime: MetricConfig{ + Enabled: true, + AggregationStrategy: AggregationStrategyAvg, + EnabledAttributes: []string{"cpu_state", "object"}, + }, + VcenterVMCPUUsage: MetricConfig{ + Enabled: true, + AggregationStrategy: AggregationStrategySum, + EnabledAttributes: []string{}, + }, + VcenterVMCPUUtilization: MetricConfig{ + Enabled: true, + AggregationStrategy: AggregationStrategyAvg, + EnabledAttributes: []string{}, + }, + VcenterVMDiskLatencyAvg: MetricConfig{ + Enabled: true, + AggregationStrategy: AggregationStrategyAvg, + EnabledAttributes: []string{"direction", "disk_type", "object"}, + }, + VcenterVMDiskLatencyMax: MetricConfig{ + Enabled: true, + AggregationStrategy: AggregationStrategyAvg, + EnabledAttributes: []string{"object"}, + }, + VcenterVMDiskThroughput: MetricConfig{ + Enabled: true, + AggregationStrategy: AggregationStrategyAvg, + EnabledAttributes: []string{"direction", "object"}, + }, + VcenterVMDiskUsage: MetricConfig{ + Enabled: true, + AggregationStrategy: AggregationStrategySum, + EnabledAttributes: []string{"disk_state"}, + }, + VcenterVMDiskUtilization: MetricConfig{ + Enabled: true, + AggregationStrategy: AggregationStrategyAvg, + EnabledAttributes: []string{}, + }, + VcenterVMMemoryBallooned: MetricConfig{ + Enabled: true, + AggregationStrategy: AggregationStrategySum, + EnabledAttributes: []string{}, + }, + VcenterVMMemoryGranted: MetricConfig{ + Enabled: true, + AggregationStrategy: AggregationStrategySum, + EnabledAttributes: []string{}, + }, + VcenterVMMemorySwapped: MetricConfig{ + Enabled: true, + AggregationStrategy: AggregationStrategySum, + EnabledAttributes: []string{}, + }, + VcenterVMMemorySwappedSsd: MetricConfig{ + Enabled: true, + AggregationStrategy: AggregationStrategySum, + EnabledAttributes: []string{}, + }, + VcenterVMMemoryUsage: MetricConfig{ + Enabled: true, + AggregationStrategy: AggregationStrategySum, + EnabledAttributes: []string{}, + }, + VcenterVMMemoryUtilization: MetricConfig{ + Enabled: true, + AggregationStrategy: AggregationStrategyAvg, + EnabledAttributes: []string{}, + }, + VcenterVMNetworkBroadcastPacketRate: MetricConfig{ + Enabled: true, + AggregationStrategy: AggregationStrategyAvg, + EnabledAttributes: []string{"direction", "object"}, + }, + VcenterVMNetworkMulticastPacketRate: MetricConfig{ + Enabled: true, + AggregationStrategy: AggregationStrategyAvg, + EnabledAttributes: []string{"direction", "object"}, + }, + VcenterVMNetworkPacketDropRate: MetricConfig{ + Enabled: true, + AggregationStrategy: AggregationStrategyAvg, + EnabledAttributes: []string{"direction", "object"}, + }, + VcenterVMNetworkPacketRate: MetricConfig{ + Enabled: true, + AggregationStrategy: AggregationStrategyAvg, + EnabledAttributes: []string{"direction", "object"}, + }, + VcenterVMNetworkThroughput: MetricConfig{ + Enabled: true, + AggregationStrategy: AggregationStrategySum, + EnabledAttributes: []string{"direction", "object"}, + }, + VcenterVMNetworkUsage: MetricConfig{ + Enabled: true, + AggregationStrategy: AggregationStrategySum, + EnabledAttributes: []string{"object"}, + }, + VcenterVMVsanLatencyAvg: MetricConfig{ + Enabled: true, + AggregationStrategy: AggregationStrategyAvg, + EnabledAttributes: []string{"type"}, + }, + VcenterVMVsanOperations: MetricConfig{ + Enabled: true, + AggregationStrategy: AggregationStrategyAvg, + EnabledAttributes: []string{"type"}, + }, + VcenterVMVsanThroughput: MetricConfig{ + Enabled: true, + AggregationStrategy: AggregationStrategyAvg, + EnabledAttributes: []string{"direction"}, + }, }, ResourceAttributes: ResourceAttributesConfig{ VcenterClusterName: ResourceAttributeConfig{Enabled: true}, @@ -118,77 +403,361 @@ func TestMetricsBuilderConfig(t *testing.T) { name: "none_set", want: MetricsBuilderConfig{ Metrics: MetricsConfig{ - VcenterClusterCPUEffective: MetricConfig{Enabled: false}, - VcenterClusterCPULimit: MetricConfig{Enabled: false}, - VcenterClusterHostCount: MetricConfig{Enabled: false}, - VcenterClusterMemoryEffective: MetricConfig{Enabled: false}, - VcenterClusterMemoryLimit: MetricConfig{Enabled: false}, - VcenterClusterVMCount: MetricConfig{Enabled: false}, - VcenterClusterVMTemplateCount: MetricConfig{Enabled: false}, - VcenterClusterVsanCongestions: MetricConfig{Enabled: false}, - VcenterClusterVsanLatencyAvg: MetricConfig{Enabled: false}, - VcenterClusterVsanOperations: MetricConfig{Enabled: false}, - VcenterClusterVsanThroughput: MetricConfig{Enabled: false}, - VcenterDatacenterClusterCount: MetricConfig{Enabled: false}, - VcenterDatacenterCPULimit: MetricConfig{Enabled: false}, - VcenterDatacenterDatastoreCount: MetricConfig{Enabled: false}, - VcenterDatacenterDiskSpace: MetricConfig{Enabled: false}, - VcenterDatacenterHostCount: MetricConfig{Enabled: false}, - VcenterDatacenterMemoryLimit: MetricConfig{Enabled: false}, - VcenterDatacenterVMCount: MetricConfig{Enabled: false}, - VcenterDatastoreDiskUsage: MetricConfig{Enabled: false}, - VcenterDatastoreDiskUtilization: MetricConfig{Enabled: false}, - VcenterHostCPUCapacity: MetricConfig{Enabled: false}, - VcenterHostCPUReserved: MetricConfig{Enabled: false}, - VcenterHostCPUUsage: MetricConfig{Enabled: false}, - VcenterHostCPUUtilization: MetricConfig{Enabled: false}, - VcenterHostDiskLatencyAvg: MetricConfig{Enabled: false}, - VcenterHostDiskLatencyMax: MetricConfig{Enabled: false}, - VcenterHostDiskThroughput: MetricConfig{Enabled: false}, - VcenterHostMemoryCapacity: MetricConfig{Enabled: false}, - VcenterHostMemoryUsage: MetricConfig{Enabled: false}, - VcenterHostMemoryUtilization: MetricConfig{Enabled: false}, - VcenterHostNetworkPacketDropRate: MetricConfig{Enabled: false}, - VcenterHostNetworkPacketErrorRate: MetricConfig{Enabled: false}, - VcenterHostNetworkPacketRate: MetricConfig{Enabled: false}, - VcenterHostNetworkThroughput: MetricConfig{Enabled: false}, - VcenterHostNetworkUsage: MetricConfig{Enabled: false}, - VcenterHostVsanCacheHitRate: MetricConfig{Enabled: false}, - VcenterHostVsanCongestions: MetricConfig{Enabled: false}, - VcenterHostVsanLatencyAvg: MetricConfig{Enabled: false}, - VcenterHostVsanOperations: MetricConfig{Enabled: false}, - VcenterHostVsanThroughput: MetricConfig{Enabled: false}, - VcenterResourcePoolCPUShares: MetricConfig{Enabled: false}, - VcenterResourcePoolCPUUsage: MetricConfig{Enabled: false}, - VcenterResourcePoolMemoryBallooned: MetricConfig{Enabled: false}, - VcenterResourcePoolMemoryGranted: MetricConfig{Enabled: false}, - VcenterResourcePoolMemoryShares: MetricConfig{Enabled: false}, - VcenterResourcePoolMemorySwapped: MetricConfig{Enabled: false}, - VcenterResourcePoolMemoryUsage: MetricConfig{Enabled: false}, - VcenterVMCPUReadiness: MetricConfig{Enabled: false}, - VcenterVMCPUTime: MetricConfig{Enabled: false}, - VcenterVMCPUUsage: MetricConfig{Enabled: false}, - VcenterVMCPUUtilization: MetricConfig{Enabled: false}, - VcenterVMDiskLatencyAvg: MetricConfig{Enabled: false}, - VcenterVMDiskLatencyMax: MetricConfig{Enabled: false}, - VcenterVMDiskThroughput: MetricConfig{Enabled: false}, - VcenterVMDiskUsage: MetricConfig{Enabled: false}, - VcenterVMDiskUtilization: MetricConfig{Enabled: false}, - VcenterVMMemoryBallooned: MetricConfig{Enabled: false}, - VcenterVMMemoryGranted: MetricConfig{Enabled: false}, - VcenterVMMemorySwapped: MetricConfig{Enabled: false}, - VcenterVMMemorySwappedSsd: MetricConfig{Enabled: false}, - VcenterVMMemoryUsage: MetricConfig{Enabled: false}, - VcenterVMMemoryUtilization: MetricConfig{Enabled: false}, - VcenterVMNetworkBroadcastPacketRate: MetricConfig{Enabled: false}, - VcenterVMNetworkMulticastPacketRate: MetricConfig{Enabled: false}, - VcenterVMNetworkPacketDropRate: MetricConfig{Enabled: false}, - VcenterVMNetworkPacketRate: MetricConfig{Enabled: false}, - VcenterVMNetworkThroughput: MetricConfig{Enabled: false}, - VcenterVMNetworkUsage: MetricConfig{Enabled: false}, - VcenterVMVsanLatencyAvg: MetricConfig{Enabled: false}, - VcenterVMVsanOperations: MetricConfig{Enabled: false}, - VcenterVMVsanThroughput: MetricConfig{Enabled: false}, + VcenterClusterCPUEffective: MetricConfig{ + Enabled: false, + AggregationStrategy: AggregationStrategySum, + EnabledAttributes: []string{}, + }, + VcenterClusterCPULimit: MetricConfig{ + Enabled: false, + AggregationStrategy: AggregationStrategySum, + EnabledAttributes: []string{}, + }, + VcenterClusterHostCount: MetricConfig{ + Enabled: false, + AggregationStrategy: AggregationStrategySum, + EnabledAttributes: []string{"effective"}, + }, + VcenterClusterMemoryEffective: MetricConfig{ + Enabled: false, + AggregationStrategy: AggregationStrategySum, + EnabledAttributes: []string{}, + }, + VcenterClusterMemoryLimit: MetricConfig{ + Enabled: false, + AggregationStrategy: AggregationStrategySum, + EnabledAttributes: []string{}, + }, + VcenterClusterVMCount: MetricConfig{ + Enabled: false, + AggregationStrategy: AggregationStrategySum, + EnabledAttributes: []string{"power_state"}, + }, + VcenterClusterVMTemplateCount: MetricConfig{ + Enabled: false, + AggregationStrategy: AggregationStrategySum, + EnabledAttributes: []string{}, + }, + VcenterClusterVsanCongestions: MetricConfig{ + Enabled: false, + AggregationStrategy: AggregationStrategyAvg, + EnabledAttributes: []string{}, + }, + VcenterClusterVsanLatencyAvg: MetricConfig{ + Enabled: false, + AggregationStrategy: AggregationStrategyAvg, + EnabledAttributes: []string{"type"}, + }, + VcenterClusterVsanOperations: MetricConfig{ + Enabled: false, + AggregationStrategy: AggregationStrategyAvg, + EnabledAttributes: []string{"type"}, + }, + VcenterClusterVsanThroughput: MetricConfig{ + Enabled: false, + AggregationStrategy: AggregationStrategyAvg, + EnabledAttributes: []string{"direction"}, + }, + VcenterDatacenterClusterCount: MetricConfig{ + Enabled: false, + AggregationStrategy: AggregationStrategySum, + EnabledAttributes: []string{"status"}, + }, + VcenterDatacenterCPULimit: MetricConfig{ + Enabled: false, + AggregationStrategy: AggregationStrategySum, + EnabledAttributes: []string{}, + }, + VcenterDatacenterDatastoreCount: MetricConfig{ + Enabled: false, + AggregationStrategy: AggregationStrategySum, + EnabledAttributes: []string{}, + }, + VcenterDatacenterDiskSpace: MetricConfig{ + Enabled: false, + AggregationStrategy: AggregationStrategySum, + EnabledAttributes: []string{"disk_state"}, + }, + VcenterDatacenterHostCount: MetricConfig{ + Enabled: false, + AggregationStrategy: AggregationStrategySum, + EnabledAttributes: []string{"status", "power_state"}, + }, + VcenterDatacenterMemoryLimit: MetricConfig{ + Enabled: false, + AggregationStrategy: AggregationStrategySum, + EnabledAttributes: []string{}, + }, + VcenterDatacenterVMCount: MetricConfig{ + Enabled: false, + AggregationStrategy: AggregationStrategySum, + EnabledAttributes: []string{"status", "power_state"}, + }, + VcenterDatastoreDiskUsage: MetricConfig{ + Enabled: false, + AggregationStrategy: AggregationStrategySum, + EnabledAttributes: []string{"disk_state"}, + }, + VcenterDatastoreDiskUtilization: MetricConfig{ + Enabled: false, + AggregationStrategy: AggregationStrategyAvg, + EnabledAttributes: []string{}, + }, + VcenterHostCPUCapacity: MetricConfig{ + Enabled: false, + AggregationStrategy: AggregationStrategySum, + EnabledAttributes: []string{}, + }, + VcenterHostCPUReserved: MetricConfig{ + Enabled: false, + AggregationStrategy: AggregationStrategySum, + EnabledAttributes: []string{"cpu_reservation_type"}, + }, + VcenterHostCPUUsage: MetricConfig{ + Enabled: false, + AggregationStrategy: AggregationStrategySum, + EnabledAttributes: []string{}, + }, + VcenterHostCPUUtilization: MetricConfig{ + Enabled: false, + AggregationStrategy: AggregationStrategyAvg, + EnabledAttributes: []string{}, + }, + VcenterHostDiskLatencyAvg: MetricConfig{ + Enabled: false, + AggregationStrategy: AggregationStrategyAvg, + EnabledAttributes: []string{"direction", "object"}, + }, + VcenterHostDiskLatencyMax: MetricConfig{ + Enabled: false, + AggregationStrategy: AggregationStrategyAvg, + EnabledAttributes: []string{"object"}, + }, + VcenterHostDiskThroughput: MetricConfig{ + Enabled: false, + AggregationStrategy: AggregationStrategySum, + EnabledAttributes: []string{"direction", "object"}, + }, + VcenterHostMemoryCapacity: MetricConfig{ + Enabled: false, + AggregationStrategy: AggregationStrategySum, + EnabledAttributes: []string{}, + }, + VcenterHostMemoryUsage: MetricConfig{ + Enabled: false, + AggregationStrategy: AggregationStrategySum, + EnabledAttributes: []string{}, + }, + VcenterHostMemoryUtilization: MetricConfig{ + Enabled: false, + AggregationStrategy: AggregationStrategyAvg, + EnabledAttributes: []string{}, + }, + VcenterHostNetworkPacketDropRate: MetricConfig{ + Enabled: false, + AggregationStrategy: AggregationStrategyAvg, + EnabledAttributes: []string{"direction", "object"}, + }, + VcenterHostNetworkPacketErrorRate: MetricConfig{ + Enabled: false, + AggregationStrategy: AggregationStrategyAvg, + EnabledAttributes: []string{"direction", "object"}, + }, + VcenterHostNetworkPacketRate: MetricConfig{ + Enabled: false, + AggregationStrategy: AggregationStrategyAvg, + EnabledAttributes: []string{"direction", "object"}, + }, + VcenterHostNetworkThroughput: MetricConfig{ + Enabled: false, + AggregationStrategy: AggregationStrategySum, + EnabledAttributes: []string{"direction", "object"}, + }, + VcenterHostNetworkUsage: MetricConfig{ + Enabled: false, + AggregationStrategy: AggregationStrategySum, + EnabledAttributes: []string{"object"}, + }, + VcenterHostVsanCacheHitRate: MetricConfig{ + Enabled: false, + AggregationStrategy: AggregationStrategyAvg, + EnabledAttributes: []string{}, + }, + VcenterHostVsanCongestions: MetricConfig{ + Enabled: false, + AggregationStrategy: AggregationStrategyAvg, + EnabledAttributes: []string{}, + }, + VcenterHostVsanLatencyAvg: MetricConfig{ + Enabled: false, + AggregationStrategy: AggregationStrategyAvg, + EnabledAttributes: []string{"type"}, + }, + VcenterHostVsanOperations: MetricConfig{ + Enabled: false, + AggregationStrategy: AggregationStrategyAvg, + EnabledAttributes: []string{"type"}, + }, + VcenterHostVsanThroughput: MetricConfig{ + Enabled: false, + AggregationStrategy: AggregationStrategyAvg, + EnabledAttributes: []string{"direction"}, + }, + VcenterResourcePoolCPUShares: MetricConfig{ + Enabled: false, + AggregationStrategy: AggregationStrategySum, + EnabledAttributes: []string{}, + }, + VcenterResourcePoolCPUUsage: MetricConfig{ + Enabled: false, + AggregationStrategy: AggregationStrategySum, + EnabledAttributes: []string{}, + }, + VcenterResourcePoolMemoryBallooned: MetricConfig{ + Enabled: false, + AggregationStrategy: AggregationStrategySum, + EnabledAttributes: []string{}, + }, + VcenterResourcePoolMemoryGranted: MetricConfig{ + Enabled: false, + AggregationStrategy: AggregationStrategySum, + EnabledAttributes: []string{"type"}, + }, + VcenterResourcePoolMemoryShares: MetricConfig{ + Enabled: false, + AggregationStrategy: AggregationStrategySum, + EnabledAttributes: []string{}, + }, + VcenterResourcePoolMemorySwapped: MetricConfig{ + Enabled: false, + AggregationStrategy: AggregationStrategySum, + EnabledAttributes: []string{}, + }, + VcenterResourcePoolMemoryUsage: MetricConfig{ + Enabled: false, + AggregationStrategy: AggregationStrategySum, + EnabledAttributes: []string{"type"}, + }, + VcenterVMCPUReadiness: MetricConfig{ + Enabled: false, + AggregationStrategy: AggregationStrategyAvg, + EnabledAttributes: []string{}, + }, + VcenterVMCPUTime: MetricConfig{ + Enabled: false, + AggregationStrategy: AggregationStrategyAvg, + EnabledAttributes: []string{"cpu_state", "object"}, + }, + VcenterVMCPUUsage: MetricConfig{ + Enabled: false, + AggregationStrategy: AggregationStrategySum, + EnabledAttributes: []string{}, + }, + VcenterVMCPUUtilization: MetricConfig{ + Enabled: false, + AggregationStrategy: AggregationStrategyAvg, + EnabledAttributes: []string{}, + }, + VcenterVMDiskLatencyAvg: MetricConfig{ + Enabled: false, + AggregationStrategy: AggregationStrategyAvg, + EnabledAttributes: []string{"direction", "disk_type", "object"}, + }, + VcenterVMDiskLatencyMax: MetricConfig{ + Enabled: false, + AggregationStrategy: AggregationStrategyAvg, + EnabledAttributes: []string{"object"}, + }, + VcenterVMDiskThroughput: MetricConfig{ + Enabled: false, + AggregationStrategy: AggregationStrategyAvg, + EnabledAttributes: []string{"direction", "object"}, + }, + VcenterVMDiskUsage: MetricConfig{ + Enabled: false, + AggregationStrategy: AggregationStrategySum, + EnabledAttributes: []string{"disk_state"}, + }, + VcenterVMDiskUtilization: MetricConfig{ + Enabled: false, + AggregationStrategy: AggregationStrategyAvg, + EnabledAttributes: []string{}, + }, + VcenterVMMemoryBallooned: MetricConfig{ + Enabled: false, + AggregationStrategy: AggregationStrategySum, + EnabledAttributes: []string{}, + }, + VcenterVMMemoryGranted: MetricConfig{ + Enabled: false, + AggregationStrategy: AggregationStrategySum, + EnabledAttributes: []string{}, + }, + VcenterVMMemorySwapped: MetricConfig{ + Enabled: false, + AggregationStrategy: AggregationStrategySum, + EnabledAttributes: []string{}, + }, + VcenterVMMemorySwappedSsd: MetricConfig{ + Enabled: false, + AggregationStrategy: AggregationStrategySum, + EnabledAttributes: []string{}, + }, + VcenterVMMemoryUsage: MetricConfig{ + Enabled: false, + AggregationStrategy: AggregationStrategySum, + EnabledAttributes: []string{}, + }, + VcenterVMMemoryUtilization: MetricConfig{ + Enabled: false, + AggregationStrategy: AggregationStrategyAvg, + EnabledAttributes: []string{}, + }, + VcenterVMNetworkBroadcastPacketRate: MetricConfig{ + Enabled: false, + AggregationStrategy: AggregationStrategyAvg, + EnabledAttributes: []string{"direction", "object"}, + }, + VcenterVMNetworkMulticastPacketRate: MetricConfig{ + Enabled: false, + AggregationStrategy: AggregationStrategyAvg, + EnabledAttributes: []string{"direction", "object"}, + }, + VcenterVMNetworkPacketDropRate: MetricConfig{ + Enabled: false, + AggregationStrategy: AggregationStrategyAvg, + EnabledAttributes: []string{"direction", "object"}, + }, + VcenterVMNetworkPacketRate: MetricConfig{ + Enabled: false, + AggregationStrategy: AggregationStrategyAvg, + EnabledAttributes: []string{"direction", "object"}, + }, + VcenterVMNetworkThroughput: MetricConfig{ + Enabled: false, + AggregationStrategy: AggregationStrategySum, + EnabledAttributes: []string{"direction", "object"}, + }, + VcenterVMNetworkUsage: MetricConfig{ + Enabled: false, + AggregationStrategy: AggregationStrategySum, + EnabledAttributes: []string{"object"}, + }, + VcenterVMVsanLatencyAvg: MetricConfig{ + Enabled: false, + AggregationStrategy: AggregationStrategyAvg, + EnabledAttributes: []string{"type"}, + }, + VcenterVMVsanOperations: MetricConfig{ + Enabled: false, + AggregationStrategy: AggregationStrategyAvg, + EnabledAttributes: []string{"type"}, + }, + VcenterVMVsanThroughput: MetricConfig{ + Enabled: false, + AggregationStrategy: AggregationStrategyAvg, + EnabledAttributes: []string{"direction"}, + }, }, ResourceAttributes: ResourceAttributesConfig{ VcenterClusterName: ResourceAttributeConfig{Enabled: false}, diff --git a/receiver/vcenterreceiver/internal/metadata/generated_metrics.go b/receiver/vcenterreceiver/internal/metadata/generated_metrics.go index 499fa38f6841a..247de427d61e9 100644 --- a/receiver/vcenterreceiver/internal/metadata/generated_metrics.go +++ b/receiver/vcenterreceiver/internal/metadata/generated_metrics.go @@ -3,6 +3,7 @@ package metadata import ( + "slices" "time" "go.opentelemetry.io/collector/component" @@ -12,6 +13,13 @@ import ( "go.opentelemetry.io/collector/receiver" ) +const ( + AggregationStrategySum = "sum" + AggregationStrategyAvg = "avg" + AggregationStrategyMin = "min" + AggregationStrategyMax = "max" +) + // AttributeCPUReservationType specifies the value cpu_reservation_type attribute. type AttributeCPUReservationType int @@ -707,9 +715,10 @@ type metricInfo struct { } type metricVcenterClusterCPUEffective struct { - data pmetric.Metric // data buffer for generated metric. - config MetricConfig // metric config provided by user. - capacity int // max observed number of data points added to the metric. + data pmetric.Metric // data buffer for generated metric. + config MetricConfig // metric config provided by user. + capacity int // max observed number of data points added to the metric. + aggDataPoints []int64 // slice containing number of aggregated datapoints at each index } // init fills vcenter.cluster.cpu.effective metric with initial data. @@ -720,16 +729,45 @@ func (m *metricVcenterClusterCPUEffective) init() { m.data.SetEmptySum() m.data.Sum().SetIsMonotonic(false) m.data.Sum().SetAggregationTemporality(pmetric.AggregationTemporalityCumulative) + m.aggDataPoints = m.aggDataPoints[:0] } func (m *metricVcenterClusterCPUEffective) recordDataPoint(start pcommon.Timestamp, ts pcommon.Timestamp, val int64) { if !m.config.Enabled { return } - dp := m.data.Sum().DataPoints().AppendEmpty() + + dp := pmetric.NewNumberDataPoint() dp.SetStartTimestamp(start) dp.SetTimestamp(ts) + + var s string + dps := m.data.Sum().DataPoints() + for i := 0; i < dps.Len(); i++ { + dpi := dps.At(i) + if dp.Attributes().Equal(dpi.Attributes()) && dp.StartTimestamp() == dpi.StartTimestamp() && dp.Timestamp() == dpi.Timestamp() { + switch s = m.config.AggregationStrategy; s { + case AggregationStrategySum, AggregationStrategyAvg: + dpi.SetIntValue(dpi.IntValue() + val) + m.aggDataPoints[i] += 1 + return + case AggregationStrategyMin: + if dpi.IntValue() > val { + dpi.SetIntValue(val) + } + return + case AggregationStrategyMax: + if dpi.IntValue() < val { + dpi.SetIntValue(val) + } + return + } + } + } + dp.SetIntValue(val) + m.aggDataPoints = append(m.aggDataPoints, 1) + dp.MoveTo(dps.AppendEmpty()) } // updateCapacity saves max length of data point slices that will be used for the slice capacity. @@ -742,6 +780,11 @@ func (m *metricVcenterClusterCPUEffective) updateCapacity() { // emit appends recorded metric data to a metrics slice and prepares it for recording another set of data points. func (m *metricVcenterClusterCPUEffective) emit(metrics pmetric.MetricSlice) { if m.config.Enabled && m.data.Sum().DataPoints().Len() > 0 { + if m.config.AggregationStrategy == AggregationStrategyAvg { + for i, aggCount := range m.aggDataPoints { + m.data.Sum().DataPoints().At(i).SetIntValue(m.data.Sum().DataPoints().At(i).IntValue() / aggCount) + } + } m.updateCapacity() m.data.MoveTo(metrics.AppendEmpty()) m.init() @@ -759,9 +802,10 @@ func newMetricVcenterClusterCPUEffective(cfg MetricConfig) metricVcenterClusterC } type metricVcenterClusterCPULimit struct { - data pmetric.Metric // data buffer for generated metric. - config MetricConfig // metric config provided by user. - capacity int // max observed number of data points added to the metric. + data pmetric.Metric // data buffer for generated metric. + config MetricConfig // metric config provided by user. + capacity int // max observed number of data points added to the metric. + aggDataPoints []int64 // slice containing number of aggregated datapoints at each index } // init fills vcenter.cluster.cpu.limit metric with initial data. @@ -772,16 +816,45 @@ func (m *metricVcenterClusterCPULimit) init() { m.data.SetEmptySum() m.data.Sum().SetIsMonotonic(false) m.data.Sum().SetAggregationTemporality(pmetric.AggregationTemporalityCumulative) + m.aggDataPoints = m.aggDataPoints[:0] } func (m *metricVcenterClusterCPULimit) recordDataPoint(start pcommon.Timestamp, ts pcommon.Timestamp, val int64) { if !m.config.Enabled { return } - dp := m.data.Sum().DataPoints().AppendEmpty() + + dp := pmetric.NewNumberDataPoint() dp.SetStartTimestamp(start) dp.SetTimestamp(ts) + + var s string + dps := m.data.Sum().DataPoints() + for i := 0; i < dps.Len(); i++ { + dpi := dps.At(i) + if dp.Attributes().Equal(dpi.Attributes()) && dp.StartTimestamp() == dpi.StartTimestamp() && dp.Timestamp() == dpi.Timestamp() { + switch s = m.config.AggregationStrategy; s { + case AggregationStrategySum, AggregationStrategyAvg: + dpi.SetIntValue(dpi.IntValue() + val) + m.aggDataPoints[i] += 1 + return + case AggregationStrategyMin: + if dpi.IntValue() > val { + dpi.SetIntValue(val) + } + return + case AggregationStrategyMax: + if dpi.IntValue() < val { + dpi.SetIntValue(val) + } + return + } + } + } + dp.SetIntValue(val) + m.aggDataPoints = append(m.aggDataPoints, 1) + dp.MoveTo(dps.AppendEmpty()) } // updateCapacity saves max length of data point slices that will be used for the slice capacity. @@ -794,6 +867,11 @@ func (m *metricVcenterClusterCPULimit) updateCapacity() { // emit appends recorded metric data to a metrics slice and prepares it for recording another set of data points. func (m *metricVcenterClusterCPULimit) emit(metrics pmetric.MetricSlice) { if m.config.Enabled && m.data.Sum().DataPoints().Len() > 0 { + if m.config.AggregationStrategy == AggregationStrategyAvg { + for i, aggCount := range m.aggDataPoints { + m.data.Sum().DataPoints().At(i).SetIntValue(m.data.Sum().DataPoints().At(i).IntValue() / aggCount) + } + } m.updateCapacity() m.data.MoveTo(metrics.AppendEmpty()) m.init() @@ -811,9 +889,10 @@ func newMetricVcenterClusterCPULimit(cfg MetricConfig) metricVcenterClusterCPULi } type metricVcenterClusterHostCount struct { - data pmetric.Metric // data buffer for generated metric. - config MetricConfig // metric config provided by user. - capacity int // max observed number of data points added to the metric. + data pmetric.Metric // data buffer for generated metric. + config MetricConfig // metric config provided by user. + capacity int // max observed number of data points added to the metric. + aggDataPoints []int64 // slice containing number of aggregated datapoints at each index } // init fills vcenter.cluster.host.count metric with initial data. @@ -825,17 +904,48 @@ func (m *metricVcenterClusterHostCount) init() { m.data.Sum().SetIsMonotonic(false) m.data.Sum().SetAggregationTemporality(pmetric.AggregationTemporalityCumulative) m.data.Sum().DataPoints().EnsureCapacity(m.capacity) + m.aggDataPoints = m.aggDataPoints[:0] } func (m *metricVcenterClusterHostCount) recordDataPoint(start pcommon.Timestamp, ts pcommon.Timestamp, val int64, hostEffectiveAttributeValue bool) { if !m.config.Enabled { return } - dp := m.data.Sum().DataPoints().AppendEmpty() + + dp := pmetric.NewNumberDataPoint() dp.SetStartTimestamp(start) dp.SetTimestamp(ts) + if slices.Contains(m.config.EnabledAttributes, "effective") { + dp.Attributes().PutBool("effective", hostEffectiveAttributeValue) + } + + var s string + dps := m.data.Sum().DataPoints() + for i := 0; i < dps.Len(); i++ { + dpi := dps.At(i) + if dp.Attributes().Equal(dpi.Attributes()) && dp.StartTimestamp() == dpi.StartTimestamp() && dp.Timestamp() == dpi.Timestamp() { + switch s = m.config.AggregationStrategy; s { + case AggregationStrategySum, AggregationStrategyAvg: + dpi.SetIntValue(dpi.IntValue() + val) + m.aggDataPoints[i] += 1 + return + case AggregationStrategyMin: + if dpi.IntValue() > val { + dpi.SetIntValue(val) + } + return + case AggregationStrategyMax: + if dpi.IntValue() < val { + dpi.SetIntValue(val) + } + return + } + } + } + dp.SetIntValue(val) - dp.Attributes().PutBool("effective", hostEffectiveAttributeValue) + m.aggDataPoints = append(m.aggDataPoints, 1) + dp.MoveTo(dps.AppendEmpty()) } // updateCapacity saves max length of data point slices that will be used for the slice capacity. @@ -848,6 +958,11 @@ func (m *metricVcenterClusterHostCount) updateCapacity() { // emit appends recorded metric data to a metrics slice and prepares it for recording another set of data points. func (m *metricVcenterClusterHostCount) emit(metrics pmetric.MetricSlice) { if m.config.Enabled && m.data.Sum().DataPoints().Len() > 0 { + if m.config.AggregationStrategy == AggregationStrategyAvg { + for i, aggCount := range m.aggDataPoints { + m.data.Sum().DataPoints().At(i).SetIntValue(m.data.Sum().DataPoints().At(i).IntValue() / aggCount) + } + } m.updateCapacity() m.data.MoveTo(metrics.AppendEmpty()) m.init() @@ -865,9 +980,10 @@ func newMetricVcenterClusterHostCount(cfg MetricConfig) metricVcenterClusterHost } type metricVcenterClusterMemoryEffective struct { - data pmetric.Metric // data buffer for generated metric. - config MetricConfig // metric config provided by user. - capacity int // max observed number of data points added to the metric. + data pmetric.Metric // data buffer for generated metric. + config MetricConfig // metric config provided by user. + capacity int // max observed number of data points added to the metric. + aggDataPoints []int64 // slice containing number of aggregated datapoints at each index } // init fills vcenter.cluster.memory.effective metric with initial data. @@ -878,16 +994,45 @@ func (m *metricVcenterClusterMemoryEffective) init() { m.data.SetEmptySum() m.data.Sum().SetIsMonotonic(false) m.data.Sum().SetAggregationTemporality(pmetric.AggregationTemporalityCumulative) + m.aggDataPoints = m.aggDataPoints[:0] } func (m *metricVcenterClusterMemoryEffective) recordDataPoint(start pcommon.Timestamp, ts pcommon.Timestamp, val int64) { if !m.config.Enabled { return } - dp := m.data.Sum().DataPoints().AppendEmpty() + + dp := pmetric.NewNumberDataPoint() dp.SetStartTimestamp(start) dp.SetTimestamp(ts) + + var s string + dps := m.data.Sum().DataPoints() + for i := 0; i < dps.Len(); i++ { + dpi := dps.At(i) + if dp.Attributes().Equal(dpi.Attributes()) && dp.StartTimestamp() == dpi.StartTimestamp() && dp.Timestamp() == dpi.Timestamp() { + switch s = m.config.AggregationStrategy; s { + case AggregationStrategySum, AggregationStrategyAvg: + dpi.SetIntValue(dpi.IntValue() + val) + m.aggDataPoints[i] += 1 + return + case AggregationStrategyMin: + if dpi.IntValue() > val { + dpi.SetIntValue(val) + } + return + case AggregationStrategyMax: + if dpi.IntValue() < val { + dpi.SetIntValue(val) + } + return + } + } + } + dp.SetIntValue(val) + m.aggDataPoints = append(m.aggDataPoints, 1) + dp.MoveTo(dps.AppendEmpty()) } // updateCapacity saves max length of data point slices that will be used for the slice capacity. @@ -900,6 +1045,11 @@ func (m *metricVcenterClusterMemoryEffective) updateCapacity() { // emit appends recorded metric data to a metrics slice and prepares it for recording another set of data points. func (m *metricVcenterClusterMemoryEffective) emit(metrics pmetric.MetricSlice) { if m.config.Enabled && m.data.Sum().DataPoints().Len() > 0 { + if m.config.AggregationStrategy == AggregationStrategyAvg { + for i, aggCount := range m.aggDataPoints { + m.data.Sum().DataPoints().At(i).SetIntValue(m.data.Sum().DataPoints().At(i).IntValue() / aggCount) + } + } m.updateCapacity() m.data.MoveTo(metrics.AppendEmpty()) m.init() @@ -917,9 +1067,10 @@ func newMetricVcenterClusterMemoryEffective(cfg MetricConfig) metricVcenterClust } type metricVcenterClusterMemoryLimit struct { - data pmetric.Metric // data buffer for generated metric. - config MetricConfig // metric config provided by user. - capacity int // max observed number of data points added to the metric. + data pmetric.Metric // data buffer for generated metric. + config MetricConfig // metric config provided by user. + capacity int // max observed number of data points added to the metric. + aggDataPoints []int64 // slice containing number of aggregated datapoints at each index } // init fills vcenter.cluster.memory.limit metric with initial data. @@ -930,16 +1081,45 @@ func (m *metricVcenterClusterMemoryLimit) init() { m.data.SetEmptySum() m.data.Sum().SetIsMonotonic(false) m.data.Sum().SetAggregationTemporality(pmetric.AggregationTemporalityCumulative) + m.aggDataPoints = m.aggDataPoints[:0] } func (m *metricVcenterClusterMemoryLimit) recordDataPoint(start pcommon.Timestamp, ts pcommon.Timestamp, val int64) { if !m.config.Enabled { return } - dp := m.data.Sum().DataPoints().AppendEmpty() + + dp := pmetric.NewNumberDataPoint() dp.SetStartTimestamp(start) dp.SetTimestamp(ts) + + var s string + dps := m.data.Sum().DataPoints() + for i := 0; i < dps.Len(); i++ { + dpi := dps.At(i) + if dp.Attributes().Equal(dpi.Attributes()) && dp.StartTimestamp() == dpi.StartTimestamp() && dp.Timestamp() == dpi.Timestamp() { + switch s = m.config.AggregationStrategy; s { + case AggregationStrategySum, AggregationStrategyAvg: + dpi.SetIntValue(dpi.IntValue() + val) + m.aggDataPoints[i] += 1 + return + case AggregationStrategyMin: + if dpi.IntValue() > val { + dpi.SetIntValue(val) + } + return + case AggregationStrategyMax: + if dpi.IntValue() < val { + dpi.SetIntValue(val) + } + return + } + } + } + dp.SetIntValue(val) + m.aggDataPoints = append(m.aggDataPoints, 1) + dp.MoveTo(dps.AppendEmpty()) } // updateCapacity saves max length of data point slices that will be used for the slice capacity. @@ -952,6 +1132,11 @@ func (m *metricVcenterClusterMemoryLimit) updateCapacity() { // emit appends recorded metric data to a metrics slice and prepares it for recording another set of data points. func (m *metricVcenterClusterMemoryLimit) emit(metrics pmetric.MetricSlice) { if m.config.Enabled && m.data.Sum().DataPoints().Len() > 0 { + if m.config.AggregationStrategy == AggregationStrategyAvg { + for i, aggCount := range m.aggDataPoints { + m.data.Sum().DataPoints().At(i).SetIntValue(m.data.Sum().DataPoints().At(i).IntValue() / aggCount) + } + } m.updateCapacity() m.data.MoveTo(metrics.AppendEmpty()) m.init() @@ -969,9 +1154,10 @@ func newMetricVcenterClusterMemoryLimit(cfg MetricConfig) metricVcenterClusterMe } type metricVcenterClusterVMCount struct { - data pmetric.Metric // data buffer for generated metric. - config MetricConfig // metric config provided by user. - capacity int // max observed number of data points added to the metric. + data pmetric.Metric // data buffer for generated metric. + config MetricConfig // metric config provided by user. + capacity int // max observed number of data points added to the metric. + aggDataPoints []int64 // slice containing number of aggregated datapoints at each index } // init fills vcenter.cluster.vm.count metric with initial data. @@ -983,17 +1169,48 @@ func (m *metricVcenterClusterVMCount) init() { m.data.Sum().SetIsMonotonic(false) m.data.Sum().SetAggregationTemporality(pmetric.AggregationTemporalityCumulative) m.data.Sum().DataPoints().EnsureCapacity(m.capacity) + m.aggDataPoints = m.aggDataPoints[:0] } func (m *metricVcenterClusterVMCount) recordDataPoint(start pcommon.Timestamp, ts pcommon.Timestamp, val int64, vmCountPowerStateAttributeValue string) { if !m.config.Enabled { return } - dp := m.data.Sum().DataPoints().AppendEmpty() + + dp := pmetric.NewNumberDataPoint() dp.SetStartTimestamp(start) dp.SetTimestamp(ts) + if slices.Contains(m.config.EnabledAttributes, "power_state") { + dp.Attributes().PutStr("power_state", vmCountPowerStateAttributeValue) + } + + var s string + dps := m.data.Sum().DataPoints() + for i := 0; i < dps.Len(); i++ { + dpi := dps.At(i) + if dp.Attributes().Equal(dpi.Attributes()) && dp.StartTimestamp() == dpi.StartTimestamp() && dp.Timestamp() == dpi.Timestamp() { + switch s = m.config.AggregationStrategy; s { + case AggregationStrategySum, AggregationStrategyAvg: + dpi.SetIntValue(dpi.IntValue() + val) + m.aggDataPoints[i] += 1 + return + case AggregationStrategyMin: + if dpi.IntValue() > val { + dpi.SetIntValue(val) + } + return + case AggregationStrategyMax: + if dpi.IntValue() < val { + dpi.SetIntValue(val) + } + return + } + } + } + dp.SetIntValue(val) - dp.Attributes().PutStr("power_state", vmCountPowerStateAttributeValue) + m.aggDataPoints = append(m.aggDataPoints, 1) + dp.MoveTo(dps.AppendEmpty()) } // updateCapacity saves max length of data point slices that will be used for the slice capacity. @@ -1006,6 +1223,11 @@ func (m *metricVcenterClusterVMCount) updateCapacity() { // emit appends recorded metric data to a metrics slice and prepares it for recording another set of data points. func (m *metricVcenterClusterVMCount) emit(metrics pmetric.MetricSlice) { if m.config.Enabled && m.data.Sum().DataPoints().Len() > 0 { + if m.config.AggregationStrategy == AggregationStrategyAvg { + for i, aggCount := range m.aggDataPoints { + m.data.Sum().DataPoints().At(i).SetIntValue(m.data.Sum().DataPoints().At(i).IntValue() / aggCount) + } + } m.updateCapacity() m.data.MoveTo(metrics.AppendEmpty()) m.init() @@ -1023,9 +1245,10 @@ func newMetricVcenterClusterVMCount(cfg MetricConfig) metricVcenterClusterVMCoun } type metricVcenterClusterVMTemplateCount struct { - data pmetric.Metric // data buffer for generated metric. - config MetricConfig // metric config provided by user. - capacity int // max observed number of data points added to the metric. + data pmetric.Metric // data buffer for generated metric. + config MetricConfig // metric config provided by user. + capacity int // max observed number of data points added to the metric. + aggDataPoints []int64 // slice containing number of aggregated datapoints at each index } // init fills vcenter.cluster.vm_template.count metric with initial data. @@ -1036,16 +1259,45 @@ func (m *metricVcenterClusterVMTemplateCount) init() { m.data.SetEmptySum() m.data.Sum().SetIsMonotonic(false) m.data.Sum().SetAggregationTemporality(pmetric.AggregationTemporalityCumulative) + m.aggDataPoints = m.aggDataPoints[:0] } func (m *metricVcenterClusterVMTemplateCount) recordDataPoint(start pcommon.Timestamp, ts pcommon.Timestamp, val int64) { if !m.config.Enabled { return } - dp := m.data.Sum().DataPoints().AppendEmpty() + + dp := pmetric.NewNumberDataPoint() dp.SetStartTimestamp(start) dp.SetTimestamp(ts) + + var s string + dps := m.data.Sum().DataPoints() + for i := 0; i < dps.Len(); i++ { + dpi := dps.At(i) + if dp.Attributes().Equal(dpi.Attributes()) && dp.StartTimestamp() == dpi.StartTimestamp() && dp.Timestamp() == dpi.Timestamp() { + switch s = m.config.AggregationStrategy; s { + case AggregationStrategySum, AggregationStrategyAvg: + dpi.SetIntValue(dpi.IntValue() + val) + m.aggDataPoints[i] += 1 + return + case AggregationStrategyMin: + if dpi.IntValue() > val { + dpi.SetIntValue(val) + } + return + case AggregationStrategyMax: + if dpi.IntValue() < val { + dpi.SetIntValue(val) + } + return + } + } + } + dp.SetIntValue(val) + m.aggDataPoints = append(m.aggDataPoints, 1) + dp.MoveTo(dps.AppendEmpty()) } // updateCapacity saves max length of data point slices that will be used for the slice capacity. @@ -1058,6 +1310,11 @@ func (m *metricVcenterClusterVMTemplateCount) updateCapacity() { // emit appends recorded metric data to a metrics slice and prepares it for recording another set of data points. func (m *metricVcenterClusterVMTemplateCount) emit(metrics pmetric.MetricSlice) { if m.config.Enabled && m.data.Sum().DataPoints().Len() > 0 { + if m.config.AggregationStrategy == AggregationStrategyAvg { + for i, aggCount := range m.aggDataPoints { + m.data.Sum().DataPoints().At(i).SetIntValue(m.data.Sum().DataPoints().At(i).IntValue() / aggCount) + } + } m.updateCapacity() m.data.MoveTo(metrics.AppendEmpty()) m.init() @@ -1075,9 +1332,10 @@ func newMetricVcenterClusterVMTemplateCount(cfg MetricConfig) metricVcenterClust } type metricVcenterClusterVsanCongestions struct { - data pmetric.Metric // data buffer for generated metric. - config MetricConfig // metric config provided by user. - capacity int // max observed number of data points added to the metric. + data pmetric.Metric // data buffer for generated metric. + config MetricConfig // metric config provided by user. + capacity int // max observed number of data points added to the metric. + aggDataPoints []float64 // slice containing number of aggregated datapoints at each index } // init fills vcenter.cluster.vsan.congestions metric with initial data. @@ -1086,16 +1344,45 @@ func (m *metricVcenterClusterVsanCongestions) init() { m.data.SetDescription("The congestions of IOs generated by all vSAN clients in the cluster.") m.data.SetUnit("{congestions/s}") m.data.SetEmptyGauge() + m.aggDataPoints = m.aggDataPoints[:0] } func (m *metricVcenterClusterVsanCongestions) recordDataPoint(start pcommon.Timestamp, ts pcommon.Timestamp, val float64) { if !m.config.Enabled { return } - dp := m.data.Gauge().DataPoints().AppendEmpty() + + dp := pmetric.NewNumberDataPoint() dp.SetStartTimestamp(start) dp.SetTimestamp(ts) + + var s string + dps := m.data.Gauge().DataPoints() + for i := 0; i < dps.Len(); i++ { + dpi := dps.At(i) + if dp.Attributes().Equal(dpi.Attributes()) && dp.StartTimestamp() == dpi.StartTimestamp() && dp.Timestamp() == dpi.Timestamp() { + switch s = m.config.AggregationStrategy; s { + case AggregationStrategySum, AggregationStrategyAvg: + dpi.SetDoubleValue(dpi.DoubleValue() + val) + m.aggDataPoints[i] += 1 + return + case AggregationStrategyMin: + if dpi.DoubleValue() > val { + dpi.SetDoubleValue(val) + } + return + case AggregationStrategyMax: + if dpi.DoubleValue() < val { + dpi.SetDoubleValue(val) + } + return + } + } + } + dp.SetDoubleValue(val) + m.aggDataPoints = append(m.aggDataPoints, 1) + dp.MoveTo(dps.AppendEmpty()) } // updateCapacity saves max length of data point slices that will be used for the slice capacity. @@ -1108,6 +1395,11 @@ func (m *metricVcenterClusterVsanCongestions) updateCapacity() { // emit appends recorded metric data to a metrics slice and prepares it for recording another set of data points. func (m *metricVcenterClusterVsanCongestions) emit(metrics pmetric.MetricSlice) { if m.config.Enabled && m.data.Gauge().DataPoints().Len() > 0 { + if m.config.AggregationStrategy == AggregationStrategyAvg { + for i, aggCount := range m.aggDataPoints { + m.data.Gauge().DataPoints().At(i).SetDoubleValue(m.data.Gauge().DataPoints().At(i).DoubleValue() / aggCount) + } + } m.updateCapacity() m.data.MoveTo(metrics.AppendEmpty()) m.init() @@ -1125,9 +1417,10 @@ func newMetricVcenterClusterVsanCongestions(cfg MetricConfig) metricVcenterClust } type metricVcenterClusterVsanLatencyAvg struct { - data pmetric.Metric // data buffer for generated metric. - config MetricConfig // metric config provided by user. - capacity int // max observed number of data points added to the metric. + data pmetric.Metric // data buffer for generated metric. + config MetricConfig // metric config provided by user. + capacity int // max observed number of data points added to the metric. + aggDataPoints []int64 // slice containing number of aggregated datapoints at each index } // init fills vcenter.cluster.vsan.latency.avg metric with initial data. @@ -1137,17 +1430,48 @@ func (m *metricVcenterClusterVsanLatencyAvg) init() { m.data.SetUnit("us") m.data.SetEmptyGauge() m.data.Gauge().DataPoints().EnsureCapacity(m.capacity) + m.aggDataPoints = m.aggDataPoints[:0] } func (m *metricVcenterClusterVsanLatencyAvg) recordDataPoint(start pcommon.Timestamp, ts pcommon.Timestamp, val int64, vsanLatencyTypeAttributeValue string) { if !m.config.Enabled { return } - dp := m.data.Gauge().DataPoints().AppendEmpty() + + dp := pmetric.NewNumberDataPoint() dp.SetStartTimestamp(start) dp.SetTimestamp(ts) + if slices.Contains(m.config.EnabledAttributes, "type") { + dp.Attributes().PutStr("type", vsanLatencyTypeAttributeValue) + } + + var s string + dps := m.data.Gauge().DataPoints() + for i := 0; i < dps.Len(); i++ { + dpi := dps.At(i) + if dp.Attributes().Equal(dpi.Attributes()) && dp.StartTimestamp() == dpi.StartTimestamp() && dp.Timestamp() == dpi.Timestamp() { + switch s = m.config.AggregationStrategy; s { + case AggregationStrategySum, AggregationStrategyAvg: + dpi.SetIntValue(dpi.IntValue() + val) + m.aggDataPoints[i] += 1 + return + case AggregationStrategyMin: + if dpi.IntValue() > val { + dpi.SetIntValue(val) + } + return + case AggregationStrategyMax: + if dpi.IntValue() < val { + dpi.SetIntValue(val) + } + return + } + } + } + dp.SetIntValue(val) - dp.Attributes().PutStr("type", vsanLatencyTypeAttributeValue) + m.aggDataPoints = append(m.aggDataPoints, 1) + dp.MoveTo(dps.AppendEmpty()) } // updateCapacity saves max length of data point slices that will be used for the slice capacity. @@ -1160,6 +1484,11 @@ func (m *metricVcenterClusterVsanLatencyAvg) updateCapacity() { // emit appends recorded metric data to a metrics slice and prepares it for recording another set of data points. func (m *metricVcenterClusterVsanLatencyAvg) emit(metrics pmetric.MetricSlice) { if m.config.Enabled && m.data.Gauge().DataPoints().Len() > 0 { + if m.config.AggregationStrategy == AggregationStrategyAvg { + for i, aggCount := range m.aggDataPoints { + m.data.Gauge().DataPoints().At(i).SetIntValue(m.data.Gauge().DataPoints().At(i).IntValue() / aggCount) + } + } m.updateCapacity() m.data.MoveTo(metrics.AppendEmpty()) m.init() @@ -1177,9 +1506,10 @@ func newMetricVcenterClusterVsanLatencyAvg(cfg MetricConfig) metricVcenterCluste } type metricVcenterClusterVsanOperations struct { - data pmetric.Metric // data buffer for generated metric. - config MetricConfig // metric config provided by user. - capacity int // max observed number of data points added to the metric. + data pmetric.Metric // data buffer for generated metric. + config MetricConfig // metric config provided by user. + capacity int // max observed number of data points added to the metric. + aggDataPoints []int64 // slice containing number of aggregated datapoints at each index } // init fills vcenter.cluster.vsan.operations metric with initial data. @@ -1189,17 +1519,48 @@ func (m *metricVcenterClusterVsanOperations) init() { m.data.SetUnit("{operations/s}") m.data.SetEmptyGauge() m.data.Gauge().DataPoints().EnsureCapacity(m.capacity) + m.aggDataPoints = m.aggDataPoints[:0] } func (m *metricVcenterClusterVsanOperations) recordDataPoint(start pcommon.Timestamp, ts pcommon.Timestamp, val int64, vsanOperationTypeAttributeValue string) { if !m.config.Enabled { return } - dp := m.data.Gauge().DataPoints().AppendEmpty() + + dp := pmetric.NewNumberDataPoint() dp.SetStartTimestamp(start) dp.SetTimestamp(ts) + if slices.Contains(m.config.EnabledAttributes, "type") { + dp.Attributes().PutStr("type", vsanOperationTypeAttributeValue) + } + + var s string + dps := m.data.Gauge().DataPoints() + for i := 0; i < dps.Len(); i++ { + dpi := dps.At(i) + if dp.Attributes().Equal(dpi.Attributes()) && dp.StartTimestamp() == dpi.StartTimestamp() && dp.Timestamp() == dpi.Timestamp() { + switch s = m.config.AggregationStrategy; s { + case AggregationStrategySum, AggregationStrategyAvg: + dpi.SetIntValue(dpi.IntValue() + val) + m.aggDataPoints[i] += 1 + return + case AggregationStrategyMin: + if dpi.IntValue() > val { + dpi.SetIntValue(val) + } + return + case AggregationStrategyMax: + if dpi.IntValue() < val { + dpi.SetIntValue(val) + } + return + } + } + } + dp.SetIntValue(val) - dp.Attributes().PutStr("type", vsanOperationTypeAttributeValue) + m.aggDataPoints = append(m.aggDataPoints, 1) + dp.MoveTo(dps.AppendEmpty()) } // updateCapacity saves max length of data point slices that will be used for the slice capacity. @@ -1212,6 +1573,11 @@ func (m *metricVcenterClusterVsanOperations) updateCapacity() { // emit appends recorded metric data to a metrics slice and prepares it for recording another set of data points. func (m *metricVcenterClusterVsanOperations) emit(metrics pmetric.MetricSlice) { if m.config.Enabled && m.data.Gauge().DataPoints().Len() > 0 { + if m.config.AggregationStrategy == AggregationStrategyAvg { + for i, aggCount := range m.aggDataPoints { + m.data.Gauge().DataPoints().At(i).SetIntValue(m.data.Gauge().DataPoints().At(i).IntValue() / aggCount) + } + } m.updateCapacity() m.data.MoveTo(metrics.AppendEmpty()) m.init() @@ -1229,9 +1595,10 @@ func newMetricVcenterClusterVsanOperations(cfg MetricConfig) metricVcenterCluste } type metricVcenterClusterVsanThroughput struct { - data pmetric.Metric // data buffer for generated metric. - config MetricConfig // metric config provided by user. - capacity int // max observed number of data points added to the metric. + data pmetric.Metric // data buffer for generated metric. + config MetricConfig // metric config provided by user. + capacity int // max observed number of data points added to the metric. + aggDataPoints []float64 // slice containing number of aggregated datapoints at each index } // init fills vcenter.cluster.vsan.throughput metric with initial data. @@ -1241,17 +1608,48 @@ func (m *metricVcenterClusterVsanThroughput) init() { m.data.SetUnit("By/s") m.data.SetEmptyGauge() m.data.Gauge().DataPoints().EnsureCapacity(m.capacity) + m.aggDataPoints = m.aggDataPoints[:0] } func (m *metricVcenterClusterVsanThroughput) recordDataPoint(start pcommon.Timestamp, ts pcommon.Timestamp, val float64, vsanThroughputDirectionAttributeValue string) { if !m.config.Enabled { return } - dp := m.data.Gauge().DataPoints().AppendEmpty() + + dp := pmetric.NewNumberDataPoint() dp.SetStartTimestamp(start) dp.SetTimestamp(ts) + if slices.Contains(m.config.EnabledAttributes, "direction") { + dp.Attributes().PutStr("direction", vsanThroughputDirectionAttributeValue) + } + + var s string + dps := m.data.Gauge().DataPoints() + for i := 0; i < dps.Len(); i++ { + dpi := dps.At(i) + if dp.Attributes().Equal(dpi.Attributes()) && dp.StartTimestamp() == dpi.StartTimestamp() && dp.Timestamp() == dpi.Timestamp() { + switch s = m.config.AggregationStrategy; s { + case AggregationStrategySum, AggregationStrategyAvg: + dpi.SetDoubleValue(dpi.DoubleValue() + val) + m.aggDataPoints[i] += 1 + return + case AggregationStrategyMin: + if dpi.DoubleValue() > val { + dpi.SetDoubleValue(val) + } + return + case AggregationStrategyMax: + if dpi.DoubleValue() < val { + dpi.SetDoubleValue(val) + } + return + } + } + } + dp.SetDoubleValue(val) - dp.Attributes().PutStr("direction", vsanThroughputDirectionAttributeValue) + m.aggDataPoints = append(m.aggDataPoints, 1) + dp.MoveTo(dps.AppendEmpty()) } // updateCapacity saves max length of data point slices that will be used for the slice capacity. @@ -1264,6 +1662,11 @@ func (m *metricVcenterClusterVsanThroughput) updateCapacity() { // emit appends recorded metric data to a metrics slice and prepares it for recording another set of data points. func (m *metricVcenterClusterVsanThroughput) emit(metrics pmetric.MetricSlice) { if m.config.Enabled && m.data.Gauge().DataPoints().Len() > 0 { + if m.config.AggregationStrategy == AggregationStrategyAvg { + for i, aggCount := range m.aggDataPoints { + m.data.Gauge().DataPoints().At(i).SetDoubleValue(m.data.Gauge().DataPoints().At(i).DoubleValue() / aggCount) + } + } m.updateCapacity() m.data.MoveTo(metrics.AppendEmpty()) m.init() @@ -1281,9 +1684,10 @@ func newMetricVcenterClusterVsanThroughput(cfg MetricConfig) metricVcenterCluste } type metricVcenterDatacenterClusterCount struct { - data pmetric.Metric // data buffer for generated metric. - config MetricConfig // metric config provided by user. - capacity int // max observed number of data points added to the metric. + data pmetric.Metric // data buffer for generated metric. + config MetricConfig // metric config provided by user. + capacity int // max observed number of data points added to the metric. + aggDataPoints []int64 // slice containing number of aggregated datapoints at each index } // init fills vcenter.datacenter.cluster.count metric with initial data. @@ -1295,17 +1699,48 @@ func (m *metricVcenterDatacenterClusterCount) init() { m.data.Sum().SetIsMonotonic(false) m.data.Sum().SetAggregationTemporality(pmetric.AggregationTemporalityCumulative) m.data.Sum().DataPoints().EnsureCapacity(m.capacity) + m.aggDataPoints = m.aggDataPoints[:0] } func (m *metricVcenterDatacenterClusterCount) recordDataPoint(start pcommon.Timestamp, ts pcommon.Timestamp, val int64, entityStatusAttributeValue string) { if !m.config.Enabled { return } - dp := m.data.Sum().DataPoints().AppendEmpty() + + dp := pmetric.NewNumberDataPoint() dp.SetStartTimestamp(start) dp.SetTimestamp(ts) + if slices.Contains(m.config.EnabledAttributes, "status") { + dp.Attributes().PutStr("status", entityStatusAttributeValue) + } + + var s string + dps := m.data.Sum().DataPoints() + for i := 0; i < dps.Len(); i++ { + dpi := dps.At(i) + if dp.Attributes().Equal(dpi.Attributes()) && dp.StartTimestamp() == dpi.StartTimestamp() && dp.Timestamp() == dpi.Timestamp() { + switch s = m.config.AggregationStrategy; s { + case AggregationStrategySum, AggregationStrategyAvg: + dpi.SetIntValue(dpi.IntValue() + val) + m.aggDataPoints[i] += 1 + return + case AggregationStrategyMin: + if dpi.IntValue() > val { + dpi.SetIntValue(val) + } + return + case AggregationStrategyMax: + if dpi.IntValue() < val { + dpi.SetIntValue(val) + } + return + } + } + } + dp.SetIntValue(val) - dp.Attributes().PutStr("status", entityStatusAttributeValue) + m.aggDataPoints = append(m.aggDataPoints, 1) + dp.MoveTo(dps.AppendEmpty()) } // updateCapacity saves max length of data point slices that will be used for the slice capacity. @@ -1318,6 +1753,11 @@ func (m *metricVcenterDatacenterClusterCount) updateCapacity() { // emit appends recorded metric data to a metrics slice and prepares it for recording another set of data points. func (m *metricVcenterDatacenterClusterCount) emit(metrics pmetric.MetricSlice) { if m.config.Enabled && m.data.Sum().DataPoints().Len() > 0 { + if m.config.AggregationStrategy == AggregationStrategyAvg { + for i, aggCount := range m.aggDataPoints { + m.data.Sum().DataPoints().At(i).SetIntValue(m.data.Sum().DataPoints().At(i).IntValue() / aggCount) + } + } m.updateCapacity() m.data.MoveTo(metrics.AppendEmpty()) m.init() @@ -1335,9 +1775,10 @@ func newMetricVcenterDatacenterClusterCount(cfg MetricConfig) metricVcenterDatac } type metricVcenterDatacenterCPULimit struct { - data pmetric.Metric // data buffer for generated metric. - config MetricConfig // metric config provided by user. - capacity int // max observed number of data points added to the metric. + data pmetric.Metric // data buffer for generated metric. + config MetricConfig // metric config provided by user. + capacity int // max observed number of data points added to the metric. + aggDataPoints []int64 // slice containing number of aggregated datapoints at each index } // init fills vcenter.datacenter.cpu.limit metric with initial data. @@ -1348,16 +1789,45 @@ func (m *metricVcenterDatacenterCPULimit) init() { m.data.SetEmptySum() m.data.Sum().SetIsMonotonic(false) m.data.Sum().SetAggregationTemporality(pmetric.AggregationTemporalityCumulative) + m.aggDataPoints = m.aggDataPoints[:0] } func (m *metricVcenterDatacenterCPULimit) recordDataPoint(start pcommon.Timestamp, ts pcommon.Timestamp, val int64) { if !m.config.Enabled { return } - dp := m.data.Sum().DataPoints().AppendEmpty() + + dp := pmetric.NewNumberDataPoint() dp.SetStartTimestamp(start) dp.SetTimestamp(ts) + + var s string + dps := m.data.Sum().DataPoints() + for i := 0; i < dps.Len(); i++ { + dpi := dps.At(i) + if dp.Attributes().Equal(dpi.Attributes()) && dp.StartTimestamp() == dpi.StartTimestamp() && dp.Timestamp() == dpi.Timestamp() { + switch s = m.config.AggregationStrategy; s { + case AggregationStrategySum, AggregationStrategyAvg: + dpi.SetIntValue(dpi.IntValue() + val) + m.aggDataPoints[i] += 1 + return + case AggregationStrategyMin: + if dpi.IntValue() > val { + dpi.SetIntValue(val) + } + return + case AggregationStrategyMax: + if dpi.IntValue() < val { + dpi.SetIntValue(val) + } + return + } + } + } + dp.SetIntValue(val) + m.aggDataPoints = append(m.aggDataPoints, 1) + dp.MoveTo(dps.AppendEmpty()) } // updateCapacity saves max length of data point slices that will be used for the slice capacity. @@ -1370,6 +1840,11 @@ func (m *metricVcenterDatacenterCPULimit) updateCapacity() { // emit appends recorded metric data to a metrics slice and prepares it for recording another set of data points. func (m *metricVcenterDatacenterCPULimit) emit(metrics pmetric.MetricSlice) { if m.config.Enabled && m.data.Sum().DataPoints().Len() > 0 { + if m.config.AggregationStrategy == AggregationStrategyAvg { + for i, aggCount := range m.aggDataPoints { + m.data.Sum().DataPoints().At(i).SetIntValue(m.data.Sum().DataPoints().At(i).IntValue() / aggCount) + } + } m.updateCapacity() m.data.MoveTo(metrics.AppendEmpty()) m.init() @@ -1387,9 +1862,10 @@ func newMetricVcenterDatacenterCPULimit(cfg MetricConfig) metricVcenterDatacente } type metricVcenterDatacenterDatastoreCount struct { - data pmetric.Metric // data buffer for generated metric. - config MetricConfig // metric config provided by user. - capacity int // max observed number of data points added to the metric. + data pmetric.Metric // data buffer for generated metric. + config MetricConfig // metric config provided by user. + capacity int // max observed number of data points added to the metric. + aggDataPoints []int64 // slice containing number of aggregated datapoints at each index } // init fills vcenter.datacenter.datastore.count metric with initial data. @@ -1400,16 +1876,45 @@ func (m *metricVcenterDatacenterDatastoreCount) init() { m.data.SetEmptySum() m.data.Sum().SetIsMonotonic(false) m.data.Sum().SetAggregationTemporality(pmetric.AggregationTemporalityCumulative) + m.aggDataPoints = m.aggDataPoints[:0] } func (m *metricVcenterDatacenterDatastoreCount) recordDataPoint(start pcommon.Timestamp, ts pcommon.Timestamp, val int64) { if !m.config.Enabled { return } - dp := m.data.Sum().DataPoints().AppendEmpty() + + dp := pmetric.NewNumberDataPoint() dp.SetStartTimestamp(start) dp.SetTimestamp(ts) + + var s string + dps := m.data.Sum().DataPoints() + for i := 0; i < dps.Len(); i++ { + dpi := dps.At(i) + if dp.Attributes().Equal(dpi.Attributes()) && dp.StartTimestamp() == dpi.StartTimestamp() && dp.Timestamp() == dpi.Timestamp() { + switch s = m.config.AggregationStrategy; s { + case AggregationStrategySum, AggregationStrategyAvg: + dpi.SetIntValue(dpi.IntValue() + val) + m.aggDataPoints[i] += 1 + return + case AggregationStrategyMin: + if dpi.IntValue() > val { + dpi.SetIntValue(val) + } + return + case AggregationStrategyMax: + if dpi.IntValue() < val { + dpi.SetIntValue(val) + } + return + } + } + } + dp.SetIntValue(val) + m.aggDataPoints = append(m.aggDataPoints, 1) + dp.MoveTo(dps.AppendEmpty()) } // updateCapacity saves max length of data point slices that will be used for the slice capacity. @@ -1422,6 +1927,11 @@ func (m *metricVcenterDatacenterDatastoreCount) updateCapacity() { // emit appends recorded metric data to a metrics slice and prepares it for recording another set of data points. func (m *metricVcenterDatacenterDatastoreCount) emit(metrics pmetric.MetricSlice) { if m.config.Enabled && m.data.Sum().DataPoints().Len() > 0 { + if m.config.AggregationStrategy == AggregationStrategyAvg { + for i, aggCount := range m.aggDataPoints { + m.data.Sum().DataPoints().At(i).SetIntValue(m.data.Sum().DataPoints().At(i).IntValue() / aggCount) + } + } m.updateCapacity() m.data.MoveTo(metrics.AppendEmpty()) m.init() @@ -1439,9 +1949,10 @@ func newMetricVcenterDatacenterDatastoreCount(cfg MetricConfig) metricVcenterDat } type metricVcenterDatacenterDiskSpace struct { - data pmetric.Metric // data buffer for generated metric. - config MetricConfig // metric config provided by user. - capacity int // max observed number of data points added to the metric. + data pmetric.Metric // data buffer for generated metric. + config MetricConfig // metric config provided by user. + capacity int // max observed number of data points added to the metric. + aggDataPoints []int64 // slice containing number of aggregated datapoints at each index } // init fills vcenter.datacenter.disk.space metric with initial data. @@ -1453,17 +1964,48 @@ func (m *metricVcenterDatacenterDiskSpace) init() { m.data.Sum().SetIsMonotonic(false) m.data.Sum().SetAggregationTemporality(pmetric.AggregationTemporalityCumulative) m.data.Sum().DataPoints().EnsureCapacity(m.capacity) + m.aggDataPoints = m.aggDataPoints[:0] } func (m *metricVcenterDatacenterDiskSpace) recordDataPoint(start pcommon.Timestamp, ts pcommon.Timestamp, val int64, diskStateAttributeValue string) { if !m.config.Enabled { return } - dp := m.data.Sum().DataPoints().AppendEmpty() + + dp := pmetric.NewNumberDataPoint() dp.SetStartTimestamp(start) dp.SetTimestamp(ts) + if slices.Contains(m.config.EnabledAttributes, "disk_state") { + dp.Attributes().PutStr("disk_state", diskStateAttributeValue) + } + + var s string + dps := m.data.Sum().DataPoints() + for i := 0; i < dps.Len(); i++ { + dpi := dps.At(i) + if dp.Attributes().Equal(dpi.Attributes()) && dp.StartTimestamp() == dpi.StartTimestamp() && dp.Timestamp() == dpi.Timestamp() { + switch s = m.config.AggregationStrategy; s { + case AggregationStrategySum, AggregationStrategyAvg: + dpi.SetIntValue(dpi.IntValue() + val) + m.aggDataPoints[i] += 1 + return + case AggregationStrategyMin: + if dpi.IntValue() > val { + dpi.SetIntValue(val) + } + return + case AggregationStrategyMax: + if dpi.IntValue() < val { + dpi.SetIntValue(val) + } + return + } + } + } + dp.SetIntValue(val) - dp.Attributes().PutStr("disk_state", diskStateAttributeValue) + m.aggDataPoints = append(m.aggDataPoints, 1) + dp.MoveTo(dps.AppendEmpty()) } // updateCapacity saves max length of data point slices that will be used for the slice capacity. @@ -1476,6 +2018,11 @@ func (m *metricVcenterDatacenterDiskSpace) updateCapacity() { // emit appends recorded metric data to a metrics slice and prepares it for recording another set of data points. func (m *metricVcenterDatacenterDiskSpace) emit(metrics pmetric.MetricSlice) { if m.config.Enabled && m.data.Sum().DataPoints().Len() > 0 { + if m.config.AggregationStrategy == AggregationStrategyAvg { + for i, aggCount := range m.aggDataPoints { + m.data.Sum().DataPoints().At(i).SetIntValue(m.data.Sum().DataPoints().At(i).IntValue() / aggCount) + } + } m.updateCapacity() m.data.MoveTo(metrics.AppendEmpty()) m.init() @@ -1493,9 +2040,10 @@ func newMetricVcenterDatacenterDiskSpace(cfg MetricConfig) metricVcenterDatacent } type metricVcenterDatacenterHostCount struct { - data pmetric.Metric // data buffer for generated metric. - config MetricConfig // metric config provided by user. - capacity int // max observed number of data points added to the metric. + data pmetric.Metric // data buffer for generated metric. + config MetricConfig // metric config provided by user. + capacity int // max observed number of data points added to the metric. + aggDataPoints []int64 // slice containing number of aggregated datapoints at each index } // init fills vcenter.datacenter.host.count metric with initial data. @@ -1507,18 +2055,51 @@ func (m *metricVcenterDatacenterHostCount) init() { m.data.Sum().SetIsMonotonic(false) m.data.Sum().SetAggregationTemporality(pmetric.AggregationTemporalityCumulative) m.data.Sum().DataPoints().EnsureCapacity(m.capacity) + m.aggDataPoints = m.aggDataPoints[:0] } func (m *metricVcenterDatacenterHostCount) recordDataPoint(start pcommon.Timestamp, ts pcommon.Timestamp, val int64, entityStatusAttributeValue string, hostPowerStateAttributeValue string) { if !m.config.Enabled { return } - dp := m.data.Sum().DataPoints().AppendEmpty() + + dp := pmetric.NewNumberDataPoint() dp.SetStartTimestamp(start) dp.SetTimestamp(ts) + if slices.Contains(m.config.EnabledAttributes, "status") { + dp.Attributes().PutStr("status", entityStatusAttributeValue) + } + if slices.Contains(m.config.EnabledAttributes, "power_state") { + dp.Attributes().PutStr("power_state", hostPowerStateAttributeValue) + } + + var s string + dps := m.data.Sum().DataPoints() + for i := 0; i < dps.Len(); i++ { + dpi := dps.At(i) + if dp.Attributes().Equal(dpi.Attributes()) && dp.StartTimestamp() == dpi.StartTimestamp() && dp.Timestamp() == dpi.Timestamp() { + switch s = m.config.AggregationStrategy; s { + case AggregationStrategySum, AggregationStrategyAvg: + dpi.SetIntValue(dpi.IntValue() + val) + m.aggDataPoints[i] += 1 + return + case AggregationStrategyMin: + if dpi.IntValue() > val { + dpi.SetIntValue(val) + } + return + case AggregationStrategyMax: + if dpi.IntValue() < val { + dpi.SetIntValue(val) + } + return + } + } + } + dp.SetIntValue(val) - dp.Attributes().PutStr("status", entityStatusAttributeValue) - dp.Attributes().PutStr("power_state", hostPowerStateAttributeValue) + m.aggDataPoints = append(m.aggDataPoints, 1) + dp.MoveTo(dps.AppendEmpty()) } // updateCapacity saves max length of data point slices that will be used for the slice capacity. @@ -1531,6 +2112,11 @@ func (m *metricVcenterDatacenterHostCount) updateCapacity() { // emit appends recorded metric data to a metrics slice and prepares it for recording another set of data points. func (m *metricVcenterDatacenterHostCount) emit(metrics pmetric.MetricSlice) { if m.config.Enabled && m.data.Sum().DataPoints().Len() > 0 { + if m.config.AggregationStrategy == AggregationStrategyAvg { + for i, aggCount := range m.aggDataPoints { + m.data.Sum().DataPoints().At(i).SetIntValue(m.data.Sum().DataPoints().At(i).IntValue() / aggCount) + } + } m.updateCapacity() m.data.MoveTo(metrics.AppendEmpty()) m.init() @@ -1548,9 +2134,10 @@ func newMetricVcenterDatacenterHostCount(cfg MetricConfig) metricVcenterDatacent } type metricVcenterDatacenterMemoryLimit struct { - data pmetric.Metric // data buffer for generated metric. - config MetricConfig // metric config provided by user. - capacity int // max observed number of data points added to the metric. + data pmetric.Metric // data buffer for generated metric. + config MetricConfig // metric config provided by user. + capacity int // max observed number of data points added to the metric. + aggDataPoints []int64 // slice containing number of aggregated datapoints at each index } // init fills vcenter.datacenter.memory.limit metric with initial data. @@ -1561,16 +2148,45 @@ func (m *metricVcenterDatacenterMemoryLimit) init() { m.data.SetEmptySum() m.data.Sum().SetIsMonotonic(false) m.data.Sum().SetAggregationTemporality(pmetric.AggregationTemporalityCumulative) + m.aggDataPoints = m.aggDataPoints[:0] } func (m *metricVcenterDatacenterMemoryLimit) recordDataPoint(start pcommon.Timestamp, ts pcommon.Timestamp, val int64) { if !m.config.Enabled { return } - dp := m.data.Sum().DataPoints().AppendEmpty() + + dp := pmetric.NewNumberDataPoint() dp.SetStartTimestamp(start) dp.SetTimestamp(ts) + + var s string + dps := m.data.Sum().DataPoints() + for i := 0; i < dps.Len(); i++ { + dpi := dps.At(i) + if dp.Attributes().Equal(dpi.Attributes()) && dp.StartTimestamp() == dpi.StartTimestamp() && dp.Timestamp() == dpi.Timestamp() { + switch s = m.config.AggregationStrategy; s { + case AggregationStrategySum, AggregationStrategyAvg: + dpi.SetIntValue(dpi.IntValue() + val) + m.aggDataPoints[i] += 1 + return + case AggregationStrategyMin: + if dpi.IntValue() > val { + dpi.SetIntValue(val) + } + return + case AggregationStrategyMax: + if dpi.IntValue() < val { + dpi.SetIntValue(val) + } + return + } + } + } + dp.SetIntValue(val) + m.aggDataPoints = append(m.aggDataPoints, 1) + dp.MoveTo(dps.AppendEmpty()) } // updateCapacity saves max length of data point slices that will be used for the slice capacity. @@ -1583,6 +2199,11 @@ func (m *metricVcenterDatacenterMemoryLimit) updateCapacity() { // emit appends recorded metric data to a metrics slice and prepares it for recording another set of data points. func (m *metricVcenterDatacenterMemoryLimit) emit(metrics pmetric.MetricSlice) { if m.config.Enabled && m.data.Sum().DataPoints().Len() > 0 { + if m.config.AggregationStrategy == AggregationStrategyAvg { + for i, aggCount := range m.aggDataPoints { + m.data.Sum().DataPoints().At(i).SetIntValue(m.data.Sum().DataPoints().At(i).IntValue() / aggCount) + } + } m.updateCapacity() m.data.MoveTo(metrics.AppendEmpty()) m.init() @@ -1600,9 +2221,10 @@ func newMetricVcenterDatacenterMemoryLimit(cfg MetricConfig) metricVcenterDatace } type metricVcenterDatacenterVMCount struct { - data pmetric.Metric // data buffer for generated metric. - config MetricConfig // metric config provided by user. - capacity int // max observed number of data points added to the metric. + data pmetric.Metric // data buffer for generated metric. + config MetricConfig // metric config provided by user. + capacity int // max observed number of data points added to the metric. + aggDataPoints []int64 // slice containing number of aggregated datapoints at each index } // init fills vcenter.datacenter.vm.count metric with initial data. @@ -1614,18 +2236,51 @@ func (m *metricVcenterDatacenterVMCount) init() { m.data.Sum().SetIsMonotonic(false) m.data.Sum().SetAggregationTemporality(pmetric.AggregationTemporalityCumulative) m.data.Sum().DataPoints().EnsureCapacity(m.capacity) + m.aggDataPoints = m.aggDataPoints[:0] } func (m *metricVcenterDatacenterVMCount) recordDataPoint(start pcommon.Timestamp, ts pcommon.Timestamp, val int64, entityStatusAttributeValue string, vmCountPowerStateAttributeValue string) { if !m.config.Enabled { return } - dp := m.data.Sum().DataPoints().AppendEmpty() + + dp := pmetric.NewNumberDataPoint() dp.SetStartTimestamp(start) dp.SetTimestamp(ts) + if slices.Contains(m.config.EnabledAttributes, "status") { + dp.Attributes().PutStr("status", entityStatusAttributeValue) + } + if slices.Contains(m.config.EnabledAttributes, "power_state") { + dp.Attributes().PutStr("power_state", vmCountPowerStateAttributeValue) + } + + var s string + dps := m.data.Sum().DataPoints() + for i := 0; i < dps.Len(); i++ { + dpi := dps.At(i) + if dp.Attributes().Equal(dpi.Attributes()) && dp.StartTimestamp() == dpi.StartTimestamp() && dp.Timestamp() == dpi.Timestamp() { + switch s = m.config.AggregationStrategy; s { + case AggregationStrategySum, AggregationStrategyAvg: + dpi.SetIntValue(dpi.IntValue() + val) + m.aggDataPoints[i] += 1 + return + case AggregationStrategyMin: + if dpi.IntValue() > val { + dpi.SetIntValue(val) + } + return + case AggregationStrategyMax: + if dpi.IntValue() < val { + dpi.SetIntValue(val) + } + return + } + } + } + dp.SetIntValue(val) - dp.Attributes().PutStr("status", entityStatusAttributeValue) - dp.Attributes().PutStr("power_state", vmCountPowerStateAttributeValue) + m.aggDataPoints = append(m.aggDataPoints, 1) + dp.MoveTo(dps.AppendEmpty()) } // updateCapacity saves max length of data point slices that will be used for the slice capacity. @@ -1638,6 +2293,11 @@ func (m *metricVcenterDatacenterVMCount) updateCapacity() { // emit appends recorded metric data to a metrics slice and prepares it for recording another set of data points. func (m *metricVcenterDatacenterVMCount) emit(metrics pmetric.MetricSlice) { if m.config.Enabled && m.data.Sum().DataPoints().Len() > 0 { + if m.config.AggregationStrategy == AggregationStrategyAvg { + for i, aggCount := range m.aggDataPoints { + m.data.Sum().DataPoints().At(i).SetIntValue(m.data.Sum().DataPoints().At(i).IntValue() / aggCount) + } + } m.updateCapacity() m.data.MoveTo(metrics.AppendEmpty()) m.init() @@ -1655,9 +2315,10 @@ func newMetricVcenterDatacenterVMCount(cfg MetricConfig) metricVcenterDatacenter } type metricVcenterDatastoreDiskUsage struct { - data pmetric.Metric // data buffer for generated metric. - config MetricConfig // metric config provided by user. - capacity int // max observed number of data points added to the metric. + data pmetric.Metric // data buffer for generated metric. + config MetricConfig // metric config provided by user. + capacity int // max observed number of data points added to the metric. + aggDataPoints []int64 // slice containing number of aggregated datapoints at each index } // init fills vcenter.datastore.disk.usage metric with initial data. @@ -1669,17 +2330,48 @@ func (m *metricVcenterDatastoreDiskUsage) init() { m.data.Sum().SetIsMonotonic(false) m.data.Sum().SetAggregationTemporality(pmetric.AggregationTemporalityCumulative) m.data.Sum().DataPoints().EnsureCapacity(m.capacity) + m.aggDataPoints = m.aggDataPoints[:0] } func (m *metricVcenterDatastoreDiskUsage) recordDataPoint(start pcommon.Timestamp, ts pcommon.Timestamp, val int64, diskStateAttributeValue string) { if !m.config.Enabled { return } - dp := m.data.Sum().DataPoints().AppendEmpty() + + dp := pmetric.NewNumberDataPoint() dp.SetStartTimestamp(start) dp.SetTimestamp(ts) + if slices.Contains(m.config.EnabledAttributes, "disk_state") { + dp.Attributes().PutStr("disk_state", diskStateAttributeValue) + } + + var s string + dps := m.data.Sum().DataPoints() + for i := 0; i < dps.Len(); i++ { + dpi := dps.At(i) + if dp.Attributes().Equal(dpi.Attributes()) && dp.StartTimestamp() == dpi.StartTimestamp() && dp.Timestamp() == dpi.Timestamp() { + switch s = m.config.AggregationStrategy; s { + case AggregationStrategySum, AggregationStrategyAvg: + dpi.SetIntValue(dpi.IntValue() + val) + m.aggDataPoints[i] += 1 + return + case AggregationStrategyMin: + if dpi.IntValue() > val { + dpi.SetIntValue(val) + } + return + case AggregationStrategyMax: + if dpi.IntValue() < val { + dpi.SetIntValue(val) + } + return + } + } + } + dp.SetIntValue(val) - dp.Attributes().PutStr("disk_state", diskStateAttributeValue) + m.aggDataPoints = append(m.aggDataPoints, 1) + dp.MoveTo(dps.AppendEmpty()) } // updateCapacity saves max length of data point slices that will be used for the slice capacity. @@ -1692,6 +2384,11 @@ func (m *metricVcenterDatastoreDiskUsage) updateCapacity() { // emit appends recorded metric data to a metrics slice and prepares it for recording another set of data points. func (m *metricVcenterDatastoreDiskUsage) emit(metrics pmetric.MetricSlice) { if m.config.Enabled && m.data.Sum().DataPoints().Len() > 0 { + if m.config.AggregationStrategy == AggregationStrategyAvg { + for i, aggCount := range m.aggDataPoints { + m.data.Sum().DataPoints().At(i).SetIntValue(m.data.Sum().DataPoints().At(i).IntValue() / aggCount) + } + } m.updateCapacity() m.data.MoveTo(metrics.AppendEmpty()) m.init() @@ -1709,9 +2406,10 @@ func newMetricVcenterDatastoreDiskUsage(cfg MetricConfig) metricVcenterDatastore } type metricVcenterDatastoreDiskUtilization struct { - data pmetric.Metric // data buffer for generated metric. - config MetricConfig // metric config provided by user. - capacity int // max observed number of data points added to the metric. + data pmetric.Metric // data buffer for generated metric. + config MetricConfig // metric config provided by user. + capacity int // max observed number of data points added to the metric. + aggDataPoints []float64 // slice containing number of aggregated datapoints at each index } // init fills vcenter.datastore.disk.utilization metric with initial data. @@ -1720,16 +2418,45 @@ func (m *metricVcenterDatastoreDiskUtilization) init() { m.data.SetDescription("The utilization of the datastore.") m.data.SetUnit("%") m.data.SetEmptyGauge() + m.aggDataPoints = m.aggDataPoints[:0] } func (m *metricVcenterDatastoreDiskUtilization) recordDataPoint(start pcommon.Timestamp, ts pcommon.Timestamp, val float64) { if !m.config.Enabled { return } - dp := m.data.Gauge().DataPoints().AppendEmpty() + + dp := pmetric.NewNumberDataPoint() dp.SetStartTimestamp(start) dp.SetTimestamp(ts) + + var s string + dps := m.data.Gauge().DataPoints() + for i := 0; i < dps.Len(); i++ { + dpi := dps.At(i) + if dp.Attributes().Equal(dpi.Attributes()) && dp.StartTimestamp() == dpi.StartTimestamp() && dp.Timestamp() == dpi.Timestamp() { + switch s = m.config.AggregationStrategy; s { + case AggregationStrategySum, AggregationStrategyAvg: + dpi.SetDoubleValue(dpi.DoubleValue() + val) + m.aggDataPoints[i] += 1 + return + case AggregationStrategyMin: + if dpi.DoubleValue() > val { + dpi.SetDoubleValue(val) + } + return + case AggregationStrategyMax: + if dpi.DoubleValue() < val { + dpi.SetDoubleValue(val) + } + return + } + } + } + dp.SetDoubleValue(val) + m.aggDataPoints = append(m.aggDataPoints, 1) + dp.MoveTo(dps.AppendEmpty()) } // updateCapacity saves max length of data point slices that will be used for the slice capacity. @@ -1742,6 +2469,11 @@ func (m *metricVcenterDatastoreDiskUtilization) updateCapacity() { // emit appends recorded metric data to a metrics slice and prepares it for recording another set of data points. func (m *metricVcenterDatastoreDiskUtilization) emit(metrics pmetric.MetricSlice) { if m.config.Enabled && m.data.Gauge().DataPoints().Len() > 0 { + if m.config.AggregationStrategy == AggregationStrategyAvg { + for i, aggCount := range m.aggDataPoints { + m.data.Gauge().DataPoints().At(i).SetDoubleValue(m.data.Gauge().DataPoints().At(i).DoubleValue() / aggCount) + } + } m.updateCapacity() m.data.MoveTo(metrics.AppendEmpty()) m.init() @@ -1759,9 +2491,10 @@ func newMetricVcenterDatastoreDiskUtilization(cfg MetricConfig) metricVcenterDat } type metricVcenterHostCPUCapacity struct { - data pmetric.Metric // data buffer for generated metric. - config MetricConfig // metric config provided by user. - capacity int // max observed number of data points added to the metric. + data pmetric.Metric // data buffer for generated metric. + config MetricConfig // metric config provided by user. + capacity int // max observed number of data points added to the metric. + aggDataPoints []int64 // slice containing number of aggregated datapoints at each index } // init fills vcenter.host.cpu.capacity metric with initial data. @@ -1772,16 +2505,45 @@ func (m *metricVcenterHostCPUCapacity) init() { m.data.SetEmptySum() m.data.Sum().SetIsMonotonic(false) m.data.Sum().SetAggregationTemporality(pmetric.AggregationTemporalityCumulative) + m.aggDataPoints = m.aggDataPoints[:0] } func (m *metricVcenterHostCPUCapacity) recordDataPoint(start pcommon.Timestamp, ts pcommon.Timestamp, val int64) { if !m.config.Enabled { return } - dp := m.data.Sum().DataPoints().AppendEmpty() + + dp := pmetric.NewNumberDataPoint() dp.SetStartTimestamp(start) dp.SetTimestamp(ts) + + var s string + dps := m.data.Sum().DataPoints() + for i := 0; i < dps.Len(); i++ { + dpi := dps.At(i) + if dp.Attributes().Equal(dpi.Attributes()) && dp.StartTimestamp() == dpi.StartTimestamp() && dp.Timestamp() == dpi.Timestamp() { + switch s = m.config.AggregationStrategy; s { + case AggregationStrategySum, AggregationStrategyAvg: + dpi.SetIntValue(dpi.IntValue() + val) + m.aggDataPoints[i] += 1 + return + case AggregationStrategyMin: + if dpi.IntValue() > val { + dpi.SetIntValue(val) + } + return + case AggregationStrategyMax: + if dpi.IntValue() < val { + dpi.SetIntValue(val) + } + return + } + } + } + dp.SetIntValue(val) + m.aggDataPoints = append(m.aggDataPoints, 1) + dp.MoveTo(dps.AppendEmpty()) } // updateCapacity saves max length of data point slices that will be used for the slice capacity. @@ -1794,6 +2556,11 @@ func (m *metricVcenterHostCPUCapacity) updateCapacity() { // emit appends recorded metric data to a metrics slice and prepares it for recording another set of data points. func (m *metricVcenterHostCPUCapacity) emit(metrics pmetric.MetricSlice) { if m.config.Enabled && m.data.Sum().DataPoints().Len() > 0 { + if m.config.AggregationStrategy == AggregationStrategyAvg { + for i, aggCount := range m.aggDataPoints { + m.data.Sum().DataPoints().At(i).SetIntValue(m.data.Sum().DataPoints().At(i).IntValue() / aggCount) + } + } m.updateCapacity() m.data.MoveTo(metrics.AppendEmpty()) m.init() @@ -1811,9 +2578,10 @@ func newMetricVcenterHostCPUCapacity(cfg MetricConfig) metricVcenterHostCPUCapac } type metricVcenterHostCPUReserved struct { - data pmetric.Metric // data buffer for generated metric. - config MetricConfig // metric config provided by user. - capacity int // max observed number of data points added to the metric. + data pmetric.Metric // data buffer for generated metric. + config MetricConfig // metric config provided by user. + capacity int // max observed number of data points added to the metric. + aggDataPoints []int64 // slice containing number of aggregated datapoints at each index } // init fills vcenter.host.cpu.reserved metric with initial data. @@ -1825,17 +2593,48 @@ func (m *metricVcenterHostCPUReserved) init() { m.data.Sum().SetIsMonotonic(false) m.data.Sum().SetAggregationTemporality(pmetric.AggregationTemporalityCumulative) m.data.Sum().DataPoints().EnsureCapacity(m.capacity) + m.aggDataPoints = m.aggDataPoints[:0] } func (m *metricVcenterHostCPUReserved) recordDataPoint(start pcommon.Timestamp, ts pcommon.Timestamp, val int64, cpuReservationTypeAttributeValue string) { if !m.config.Enabled { return } - dp := m.data.Sum().DataPoints().AppendEmpty() + + dp := pmetric.NewNumberDataPoint() dp.SetStartTimestamp(start) dp.SetTimestamp(ts) + if slices.Contains(m.config.EnabledAttributes, "cpu_reservation_type") { + dp.Attributes().PutStr("cpu_reservation_type", cpuReservationTypeAttributeValue) + } + + var s string + dps := m.data.Sum().DataPoints() + for i := 0; i < dps.Len(); i++ { + dpi := dps.At(i) + if dp.Attributes().Equal(dpi.Attributes()) && dp.StartTimestamp() == dpi.StartTimestamp() && dp.Timestamp() == dpi.Timestamp() { + switch s = m.config.AggregationStrategy; s { + case AggregationStrategySum, AggregationStrategyAvg: + dpi.SetIntValue(dpi.IntValue() + val) + m.aggDataPoints[i] += 1 + return + case AggregationStrategyMin: + if dpi.IntValue() > val { + dpi.SetIntValue(val) + } + return + case AggregationStrategyMax: + if dpi.IntValue() < val { + dpi.SetIntValue(val) + } + return + } + } + } + dp.SetIntValue(val) - dp.Attributes().PutStr("cpu_reservation_type", cpuReservationTypeAttributeValue) + m.aggDataPoints = append(m.aggDataPoints, 1) + dp.MoveTo(dps.AppendEmpty()) } // updateCapacity saves max length of data point slices that will be used for the slice capacity. @@ -1848,6 +2647,11 @@ func (m *metricVcenterHostCPUReserved) updateCapacity() { // emit appends recorded metric data to a metrics slice and prepares it for recording another set of data points. func (m *metricVcenterHostCPUReserved) emit(metrics pmetric.MetricSlice) { if m.config.Enabled && m.data.Sum().DataPoints().Len() > 0 { + if m.config.AggregationStrategy == AggregationStrategyAvg { + for i, aggCount := range m.aggDataPoints { + m.data.Sum().DataPoints().At(i).SetIntValue(m.data.Sum().DataPoints().At(i).IntValue() / aggCount) + } + } m.updateCapacity() m.data.MoveTo(metrics.AppendEmpty()) m.init() @@ -1865,9 +2669,10 @@ func newMetricVcenterHostCPUReserved(cfg MetricConfig) metricVcenterHostCPUReser } type metricVcenterHostCPUUsage struct { - data pmetric.Metric // data buffer for generated metric. - config MetricConfig // metric config provided by user. - capacity int // max observed number of data points added to the metric. + data pmetric.Metric // data buffer for generated metric. + config MetricConfig // metric config provided by user. + capacity int // max observed number of data points added to the metric. + aggDataPoints []int64 // slice containing number of aggregated datapoints at each index } // init fills vcenter.host.cpu.usage metric with initial data. @@ -1878,16 +2683,45 @@ func (m *metricVcenterHostCPUUsage) init() { m.data.SetEmptySum() m.data.Sum().SetIsMonotonic(false) m.data.Sum().SetAggregationTemporality(pmetric.AggregationTemporalityCumulative) + m.aggDataPoints = m.aggDataPoints[:0] } func (m *metricVcenterHostCPUUsage) recordDataPoint(start pcommon.Timestamp, ts pcommon.Timestamp, val int64) { if !m.config.Enabled { return } - dp := m.data.Sum().DataPoints().AppendEmpty() + + dp := pmetric.NewNumberDataPoint() dp.SetStartTimestamp(start) dp.SetTimestamp(ts) + + var s string + dps := m.data.Sum().DataPoints() + for i := 0; i < dps.Len(); i++ { + dpi := dps.At(i) + if dp.Attributes().Equal(dpi.Attributes()) && dp.StartTimestamp() == dpi.StartTimestamp() && dp.Timestamp() == dpi.Timestamp() { + switch s = m.config.AggregationStrategy; s { + case AggregationStrategySum, AggregationStrategyAvg: + dpi.SetIntValue(dpi.IntValue() + val) + m.aggDataPoints[i] += 1 + return + case AggregationStrategyMin: + if dpi.IntValue() > val { + dpi.SetIntValue(val) + } + return + case AggregationStrategyMax: + if dpi.IntValue() < val { + dpi.SetIntValue(val) + } + return + } + } + } + dp.SetIntValue(val) + m.aggDataPoints = append(m.aggDataPoints, 1) + dp.MoveTo(dps.AppendEmpty()) } // updateCapacity saves max length of data point slices that will be used for the slice capacity. @@ -1900,6 +2734,11 @@ func (m *metricVcenterHostCPUUsage) updateCapacity() { // emit appends recorded metric data to a metrics slice and prepares it for recording another set of data points. func (m *metricVcenterHostCPUUsage) emit(metrics pmetric.MetricSlice) { if m.config.Enabled && m.data.Sum().DataPoints().Len() > 0 { + if m.config.AggregationStrategy == AggregationStrategyAvg { + for i, aggCount := range m.aggDataPoints { + m.data.Sum().DataPoints().At(i).SetIntValue(m.data.Sum().DataPoints().At(i).IntValue() / aggCount) + } + } m.updateCapacity() m.data.MoveTo(metrics.AppendEmpty()) m.init() @@ -1917,9 +2756,10 @@ func newMetricVcenterHostCPUUsage(cfg MetricConfig) metricVcenterHostCPUUsage { } type metricVcenterHostCPUUtilization struct { - data pmetric.Metric // data buffer for generated metric. - config MetricConfig // metric config provided by user. - capacity int // max observed number of data points added to the metric. + data pmetric.Metric // data buffer for generated metric. + config MetricConfig // metric config provided by user. + capacity int // max observed number of data points added to the metric. + aggDataPoints []float64 // slice containing number of aggregated datapoints at each index } // init fills vcenter.host.cpu.utilization metric with initial data. @@ -1928,16 +2768,45 @@ func (m *metricVcenterHostCPUUtilization) init() { m.data.SetDescription("The CPU utilization of the host system.") m.data.SetUnit("%") m.data.SetEmptyGauge() + m.aggDataPoints = m.aggDataPoints[:0] } func (m *metricVcenterHostCPUUtilization) recordDataPoint(start pcommon.Timestamp, ts pcommon.Timestamp, val float64) { if !m.config.Enabled { return } - dp := m.data.Gauge().DataPoints().AppendEmpty() + + dp := pmetric.NewNumberDataPoint() dp.SetStartTimestamp(start) dp.SetTimestamp(ts) + + var s string + dps := m.data.Gauge().DataPoints() + for i := 0; i < dps.Len(); i++ { + dpi := dps.At(i) + if dp.Attributes().Equal(dpi.Attributes()) && dp.StartTimestamp() == dpi.StartTimestamp() && dp.Timestamp() == dpi.Timestamp() { + switch s = m.config.AggregationStrategy; s { + case AggregationStrategySum, AggregationStrategyAvg: + dpi.SetDoubleValue(dpi.DoubleValue() + val) + m.aggDataPoints[i] += 1 + return + case AggregationStrategyMin: + if dpi.DoubleValue() > val { + dpi.SetDoubleValue(val) + } + return + case AggregationStrategyMax: + if dpi.DoubleValue() < val { + dpi.SetDoubleValue(val) + } + return + } + } + } + dp.SetDoubleValue(val) + m.aggDataPoints = append(m.aggDataPoints, 1) + dp.MoveTo(dps.AppendEmpty()) } // updateCapacity saves max length of data point slices that will be used for the slice capacity. @@ -1950,6 +2819,11 @@ func (m *metricVcenterHostCPUUtilization) updateCapacity() { // emit appends recorded metric data to a metrics slice and prepares it for recording another set of data points. func (m *metricVcenterHostCPUUtilization) emit(metrics pmetric.MetricSlice) { if m.config.Enabled && m.data.Gauge().DataPoints().Len() > 0 { + if m.config.AggregationStrategy == AggregationStrategyAvg { + for i, aggCount := range m.aggDataPoints { + m.data.Gauge().DataPoints().At(i).SetDoubleValue(m.data.Gauge().DataPoints().At(i).DoubleValue() / aggCount) + } + } m.updateCapacity() m.data.MoveTo(metrics.AppendEmpty()) m.init() @@ -1967,9 +2841,10 @@ func newMetricVcenterHostCPUUtilization(cfg MetricConfig) metricVcenterHostCPUUt } type metricVcenterHostDiskLatencyAvg struct { - data pmetric.Metric // data buffer for generated metric. - config MetricConfig // metric config provided by user. - capacity int // max observed number of data points added to the metric. + data pmetric.Metric // data buffer for generated metric. + config MetricConfig // metric config provided by user. + capacity int // max observed number of data points added to the metric. + aggDataPoints []int64 // slice containing number of aggregated datapoints at each index } // init fills vcenter.host.disk.latency.avg metric with initial data. @@ -1979,18 +2854,51 @@ func (m *metricVcenterHostDiskLatencyAvg) init() { m.data.SetUnit("ms") m.data.SetEmptyGauge() m.data.Gauge().DataPoints().EnsureCapacity(m.capacity) + m.aggDataPoints = m.aggDataPoints[:0] } func (m *metricVcenterHostDiskLatencyAvg) recordDataPoint(start pcommon.Timestamp, ts pcommon.Timestamp, val int64, diskDirectionAttributeValue string, objectNameAttributeValue string) { if !m.config.Enabled { return } - dp := m.data.Gauge().DataPoints().AppendEmpty() + + dp := pmetric.NewNumberDataPoint() dp.SetStartTimestamp(start) dp.SetTimestamp(ts) + if slices.Contains(m.config.EnabledAttributes, "direction") { + dp.Attributes().PutStr("direction", diskDirectionAttributeValue) + } + if slices.Contains(m.config.EnabledAttributes, "object") { + dp.Attributes().PutStr("object", objectNameAttributeValue) + } + + var s string + dps := m.data.Gauge().DataPoints() + for i := 0; i < dps.Len(); i++ { + dpi := dps.At(i) + if dp.Attributes().Equal(dpi.Attributes()) && dp.StartTimestamp() == dpi.StartTimestamp() && dp.Timestamp() == dpi.Timestamp() { + switch s = m.config.AggregationStrategy; s { + case AggregationStrategySum, AggregationStrategyAvg: + dpi.SetIntValue(dpi.IntValue() + val) + m.aggDataPoints[i] += 1 + return + case AggregationStrategyMin: + if dpi.IntValue() > val { + dpi.SetIntValue(val) + } + return + case AggregationStrategyMax: + if dpi.IntValue() < val { + dpi.SetIntValue(val) + } + return + } + } + } + dp.SetIntValue(val) - dp.Attributes().PutStr("direction", diskDirectionAttributeValue) - dp.Attributes().PutStr("object", objectNameAttributeValue) + m.aggDataPoints = append(m.aggDataPoints, 1) + dp.MoveTo(dps.AppendEmpty()) } // updateCapacity saves max length of data point slices that will be used for the slice capacity. @@ -2003,6 +2911,11 @@ func (m *metricVcenterHostDiskLatencyAvg) updateCapacity() { // emit appends recorded metric data to a metrics slice and prepares it for recording another set of data points. func (m *metricVcenterHostDiskLatencyAvg) emit(metrics pmetric.MetricSlice) { if m.config.Enabled && m.data.Gauge().DataPoints().Len() > 0 { + if m.config.AggregationStrategy == AggregationStrategyAvg { + for i, aggCount := range m.aggDataPoints { + m.data.Gauge().DataPoints().At(i).SetIntValue(m.data.Gauge().DataPoints().At(i).IntValue() / aggCount) + } + } m.updateCapacity() m.data.MoveTo(metrics.AppendEmpty()) m.init() @@ -2020,9 +2933,10 @@ func newMetricVcenterHostDiskLatencyAvg(cfg MetricConfig) metricVcenterHostDiskL } type metricVcenterHostDiskLatencyMax struct { - data pmetric.Metric // data buffer for generated metric. - config MetricConfig // metric config provided by user. - capacity int // max observed number of data points added to the metric. + data pmetric.Metric // data buffer for generated metric. + config MetricConfig // metric config provided by user. + capacity int // max observed number of data points added to the metric. + aggDataPoints []int64 // slice containing number of aggregated datapoints at each index } // init fills vcenter.host.disk.latency.max metric with initial data. @@ -2032,17 +2946,48 @@ func (m *metricVcenterHostDiskLatencyMax) init() { m.data.SetUnit("ms") m.data.SetEmptyGauge() m.data.Gauge().DataPoints().EnsureCapacity(m.capacity) + m.aggDataPoints = m.aggDataPoints[:0] } func (m *metricVcenterHostDiskLatencyMax) recordDataPoint(start pcommon.Timestamp, ts pcommon.Timestamp, val int64, objectNameAttributeValue string) { if !m.config.Enabled { return } - dp := m.data.Gauge().DataPoints().AppendEmpty() + + dp := pmetric.NewNumberDataPoint() dp.SetStartTimestamp(start) dp.SetTimestamp(ts) + if slices.Contains(m.config.EnabledAttributes, "object") { + dp.Attributes().PutStr("object", objectNameAttributeValue) + } + + var s string + dps := m.data.Gauge().DataPoints() + for i := 0; i < dps.Len(); i++ { + dpi := dps.At(i) + if dp.Attributes().Equal(dpi.Attributes()) && dp.StartTimestamp() == dpi.StartTimestamp() && dp.Timestamp() == dpi.Timestamp() { + switch s = m.config.AggregationStrategy; s { + case AggregationStrategySum, AggregationStrategyAvg: + dpi.SetIntValue(dpi.IntValue() + val) + m.aggDataPoints[i] += 1 + return + case AggregationStrategyMin: + if dpi.IntValue() > val { + dpi.SetIntValue(val) + } + return + case AggregationStrategyMax: + if dpi.IntValue() < val { + dpi.SetIntValue(val) + } + return + } + } + } + dp.SetIntValue(val) - dp.Attributes().PutStr("object", objectNameAttributeValue) + m.aggDataPoints = append(m.aggDataPoints, 1) + dp.MoveTo(dps.AppendEmpty()) } // updateCapacity saves max length of data point slices that will be used for the slice capacity. @@ -2055,6 +3000,11 @@ func (m *metricVcenterHostDiskLatencyMax) updateCapacity() { // emit appends recorded metric data to a metrics slice and prepares it for recording another set of data points. func (m *metricVcenterHostDiskLatencyMax) emit(metrics pmetric.MetricSlice) { if m.config.Enabled && m.data.Gauge().DataPoints().Len() > 0 { + if m.config.AggregationStrategy == AggregationStrategyAvg { + for i, aggCount := range m.aggDataPoints { + m.data.Gauge().DataPoints().At(i).SetIntValue(m.data.Gauge().DataPoints().At(i).IntValue() / aggCount) + } + } m.updateCapacity() m.data.MoveTo(metrics.AppendEmpty()) m.init() @@ -2072,9 +3022,10 @@ func newMetricVcenterHostDiskLatencyMax(cfg MetricConfig) metricVcenterHostDiskL } type metricVcenterHostDiskThroughput struct { - data pmetric.Metric // data buffer for generated metric. - config MetricConfig // metric config provided by user. - capacity int // max observed number of data points added to the metric. + data pmetric.Metric // data buffer for generated metric. + config MetricConfig // metric config provided by user. + capacity int // max observed number of data points added to the metric. + aggDataPoints []int64 // slice containing number of aggregated datapoints at each index } // init fills vcenter.host.disk.throughput metric with initial data. @@ -2086,18 +3037,51 @@ func (m *metricVcenterHostDiskThroughput) init() { m.data.Sum().SetIsMonotonic(false) m.data.Sum().SetAggregationTemporality(pmetric.AggregationTemporalityCumulative) m.data.Sum().DataPoints().EnsureCapacity(m.capacity) + m.aggDataPoints = m.aggDataPoints[:0] } func (m *metricVcenterHostDiskThroughput) recordDataPoint(start pcommon.Timestamp, ts pcommon.Timestamp, val int64, diskDirectionAttributeValue string, objectNameAttributeValue string) { if !m.config.Enabled { return } - dp := m.data.Sum().DataPoints().AppendEmpty() + + dp := pmetric.NewNumberDataPoint() dp.SetStartTimestamp(start) dp.SetTimestamp(ts) + if slices.Contains(m.config.EnabledAttributes, "direction") { + dp.Attributes().PutStr("direction", diskDirectionAttributeValue) + } + if slices.Contains(m.config.EnabledAttributes, "object") { + dp.Attributes().PutStr("object", objectNameAttributeValue) + } + + var s string + dps := m.data.Sum().DataPoints() + for i := 0; i < dps.Len(); i++ { + dpi := dps.At(i) + if dp.Attributes().Equal(dpi.Attributes()) && dp.StartTimestamp() == dpi.StartTimestamp() && dp.Timestamp() == dpi.Timestamp() { + switch s = m.config.AggregationStrategy; s { + case AggregationStrategySum, AggregationStrategyAvg: + dpi.SetIntValue(dpi.IntValue() + val) + m.aggDataPoints[i] += 1 + return + case AggregationStrategyMin: + if dpi.IntValue() > val { + dpi.SetIntValue(val) + } + return + case AggregationStrategyMax: + if dpi.IntValue() < val { + dpi.SetIntValue(val) + } + return + } + } + } + dp.SetIntValue(val) - dp.Attributes().PutStr("direction", diskDirectionAttributeValue) - dp.Attributes().PutStr("object", objectNameAttributeValue) + m.aggDataPoints = append(m.aggDataPoints, 1) + dp.MoveTo(dps.AppendEmpty()) } // updateCapacity saves max length of data point slices that will be used for the slice capacity. @@ -2110,6 +3094,11 @@ func (m *metricVcenterHostDiskThroughput) updateCapacity() { // emit appends recorded metric data to a metrics slice and prepares it for recording another set of data points. func (m *metricVcenterHostDiskThroughput) emit(metrics pmetric.MetricSlice) { if m.config.Enabled && m.data.Sum().DataPoints().Len() > 0 { + if m.config.AggregationStrategy == AggregationStrategyAvg { + for i, aggCount := range m.aggDataPoints { + m.data.Sum().DataPoints().At(i).SetIntValue(m.data.Sum().DataPoints().At(i).IntValue() / aggCount) + } + } m.updateCapacity() m.data.MoveTo(metrics.AppendEmpty()) m.init() @@ -2127,9 +3116,10 @@ func newMetricVcenterHostDiskThroughput(cfg MetricConfig) metricVcenterHostDiskT } type metricVcenterHostMemoryCapacity struct { - data pmetric.Metric // data buffer for generated metric. - config MetricConfig // metric config provided by user. - capacity int // max observed number of data points added to the metric. + data pmetric.Metric // data buffer for generated metric. + config MetricConfig // metric config provided by user. + capacity int // max observed number of data points added to the metric. + aggDataPoints []float64 // slice containing number of aggregated datapoints at each index } // init fills vcenter.host.memory.capacity metric with initial data. @@ -2140,16 +3130,45 @@ func (m *metricVcenterHostMemoryCapacity) init() { m.data.SetEmptySum() m.data.Sum().SetIsMonotonic(false) m.data.Sum().SetAggregationTemporality(pmetric.AggregationTemporalityCumulative) + m.aggDataPoints = m.aggDataPoints[:0] } func (m *metricVcenterHostMemoryCapacity) recordDataPoint(start pcommon.Timestamp, ts pcommon.Timestamp, val float64) { if !m.config.Enabled { return } - dp := m.data.Sum().DataPoints().AppendEmpty() + + dp := pmetric.NewNumberDataPoint() dp.SetStartTimestamp(start) dp.SetTimestamp(ts) + + var s string + dps := m.data.Sum().DataPoints() + for i := 0; i < dps.Len(); i++ { + dpi := dps.At(i) + if dp.Attributes().Equal(dpi.Attributes()) && dp.StartTimestamp() == dpi.StartTimestamp() && dp.Timestamp() == dpi.Timestamp() { + switch s = m.config.AggregationStrategy; s { + case AggregationStrategySum, AggregationStrategyAvg: + dpi.SetDoubleValue(dpi.DoubleValue() + val) + m.aggDataPoints[i] += 1 + return + case AggregationStrategyMin: + if dpi.DoubleValue() > val { + dpi.SetDoubleValue(val) + } + return + case AggregationStrategyMax: + if dpi.DoubleValue() < val { + dpi.SetDoubleValue(val) + } + return + } + } + } + dp.SetDoubleValue(val) + m.aggDataPoints = append(m.aggDataPoints, 1) + dp.MoveTo(dps.AppendEmpty()) } // updateCapacity saves max length of data point slices that will be used for the slice capacity. @@ -2162,6 +3181,11 @@ func (m *metricVcenterHostMemoryCapacity) updateCapacity() { // emit appends recorded metric data to a metrics slice and prepares it for recording another set of data points. func (m *metricVcenterHostMemoryCapacity) emit(metrics pmetric.MetricSlice) { if m.config.Enabled && m.data.Sum().DataPoints().Len() > 0 { + if m.config.AggregationStrategy == AggregationStrategyAvg { + for i, aggCount := range m.aggDataPoints { + m.data.Sum().DataPoints().At(i).SetDoubleValue(m.data.Sum().DataPoints().At(i).DoubleValue() / aggCount) + } + } m.updateCapacity() m.data.MoveTo(metrics.AppendEmpty()) m.init() @@ -2179,9 +3203,10 @@ func newMetricVcenterHostMemoryCapacity(cfg MetricConfig) metricVcenterHostMemor } type metricVcenterHostMemoryUsage struct { - data pmetric.Metric // data buffer for generated metric. - config MetricConfig // metric config provided by user. - capacity int // max observed number of data points added to the metric. + data pmetric.Metric // data buffer for generated metric. + config MetricConfig // metric config provided by user. + capacity int // max observed number of data points added to the metric. + aggDataPoints []int64 // slice containing number of aggregated datapoints at each index } // init fills vcenter.host.memory.usage metric with initial data. @@ -2192,16 +3217,45 @@ func (m *metricVcenterHostMemoryUsage) init() { m.data.SetEmptySum() m.data.Sum().SetIsMonotonic(false) m.data.Sum().SetAggregationTemporality(pmetric.AggregationTemporalityCumulative) + m.aggDataPoints = m.aggDataPoints[:0] } func (m *metricVcenterHostMemoryUsage) recordDataPoint(start pcommon.Timestamp, ts pcommon.Timestamp, val int64) { if !m.config.Enabled { return } - dp := m.data.Sum().DataPoints().AppendEmpty() + + dp := pmetric.NewNumberDataPoint() dp.SetStartTimestamp(start) dp.SetTimestamp(ts) + + var s string + dps := m.data.Sum().DataPoints() + for i := 0; i < dps.Len(); i++ { + dpi := dps.At(i) + if dp.Attributes().Equal(dpi.Attributes()) && dp.StartTimestamp() == dpi.StartTimestamp() && dp.Timestamp() == dpi.Timestamp() { + switch s = m.config.AggregationStrategy; s { + case AggregationStrategySum, AggregationStrategyAvg: + dpi.SetIntValue(dpi.IntValue() + val) + m.aggDataPoints[i] += 1 + return + case AggregationStrategyMin: + if dpi.IntValue() > val { + dpi.SetIntValue(val) + } + return + case AggregationStrategyMax: + if dpi.IntValue() < val { + dpi.SetIntValue(val) + } + return + } + } + } + dp.SetIntValue(val) + m.aggDataPoints = append(m.aggDataPoints, 1) + dp.MoveTo(dps.AppendEmpty()) } // updateCapacity saves max length of data point slices that will be used for the slice capacity. @@ -2214,6 +3268,11 @@ func (m *metricVcenterHostMemoryUsage) updateCapacity() { // emit appends recorded metric data to a metrics slice and prepares it for recording another set of data points. func (m *metricVcenterHostMemoryUsage) emit(metrics pmetric.MetricSlice) { if m.config.Enabled && m.data.Sum().DataPoints().Len() > 0 { + if m.config.AggregationStrategy == AggregationStrategyAvg { + for i, aggCount := range m.aggDataPoints { + m.data.Sum().DataPoints().At(i).SetIntValue(m.data.Sum().DataPoints().At(i).IntValue() / aggCount) + } + } m.updateCapacity() m.data.MoveTo(metrics.AppendEmpty()) m.init() @@ -2231,9 +3290,10 @@ func newMetricVcenterHostMemoryUsage(cfg MetricConfig) metricVcenterHostMemoryUs } type metricVcenterHostMemoryUtilization struct { - data pmetric.Metric // data buffer for generated metric. - config MetricConfig // metric config provided by user. - capacity int // max observed number of data points added to the metric. + data pmetric.Metric // data buffer for generated metric. + config MetricConfig // metric config provided by user. + capacity int // max observed number of data points added to the metric. + aggDataPoints []float64 // slice containing number of aggregated datapoints at each index } // init fills vcenter.host.memory.utilization metric with initial data. @@ -2242,16 +3302,45 @@ func (m *metricVcenterHostMemoryUtilization) init() { m.data.SetDescription("The percentage of the host system's memory capacity that is being utilized.") m.data.SetUnit("%") m.data.SetEmptyGauge() + m.aggDataPoints = m.aggDataPoints[:0] } func (m *metricVcenterHostMemoryUtilization) recordDataPoint(start pcommon.Timestamp, ts pcommon.Timestamp, val float64) { if !m.config.Enabled { return } - dp := m.data.Gauge().DataPoints().AppendEmpty() + + dp := pmetric.NewNumberDataPoint() dp.SetStartTimestamp(start) dp.SetTimestamp(ts) + + var s string + dps := m.data.Gauge().DataPoints() + for i := 0; i < dps.Len(); i++ { + dpi := dps.At(i) + if dp.Attributes().Equal(dpi.Attributes()) && dp.StartTimestamp() == dpi.StartTimestamp() && dp.Timestamp() == dpi.Timestamp() { + switch s = m.config.AggregationStrategy; s { + case AggregationStrategySum, AggregationStrategyAvg: + dpi.SetDoubleValue(dpi.DoubleValue() + val) + m.aggDataPoints[i] += 1 + return + case AggregationStrategyMin: + if dpi.DoubleValue() > val { + dpi.SetDoubleValue(val) + } + return + case AggregationStrategyMax: + if dpi.DoubleValue() < val { + dpi.SetDoubleValue(val) + } + return + } + } + } + dp.SetDoubleValue(val) + m.aggDataPoints = append(m.aggDataPoints, 1) + dp.MoveTo(dps.AppendEmpty()) } // updateCapacity saves max length of data point slices that will be used for the slice capacity. @@ -2264,6 +3353,11 @@ func (m *metricVcenterHostMemoryUtilization) updateCapacity() { // emit appends recorded metric data to a metrics slice and prepares it for recording another set of data points. func (m *metricVcenterHostMemoryUtilization) emit(metrics pmetric.MetricSlice) { if m.config.Enabled && m.data.Gauge().DataPoints().Len() > 0 { + if m.config.AggregationStrategy == AggregationStrategyAvg { + for i, aggCount := range m.aggDataPoints { + m.data.Gauge().DataPoints().At(i).SetDoubleValue(m.data.Gauge().DataPoints().At(i).DoubleValue() / aggCount) + } + } m.updateCapacity() m.data.MoveTo(metrics.AppendEmpty()) m.init() @@ -2281,9 +3375,10 @@ func newMetricVcenterHostMemoryUtilization(cfg MetricConfig) metricVcenterHostMe } type metricVcenterHostNetworkPacketDropRate struct { - data pmetric.Metric // data buffer for generated metric. - config MetricConfig // metric config provided by user. - capacity int // max observed number of data points added to the metric. + data pmetric.Metric // data buffer for generated metric. + config MetricConfig // metric config provided by user. + capacity int // max observed number of data points added to the metric. + aggDataPoints []float64 // slice containing number of aggregated datapoints at each index } // init fills vcenter.host.network.packet.drop.rate metric with initial data. @@ -2293,18 +3388,51 @@ func (m *metricVcenterHostNetworkPacketDropRate) init() { m.data.SetUnit("{packets/s}") m.data.SetEmptyGauge() m.data.Gauge().DataPoints().EnsureCapacity(m.capacity) + m.aggDataPoints = m.aggDataPoints[:0] } func (m *metricVcenterHostNetworkPacketDropRate) recordDataPoint(start pcommon.Timestamp, ts pcommon.Timestamp, val float64, throughputDirectionAttributeValue string, objectNameAttributeValue string) { if !m.config.Enabled { return } - dp := m.data.Gauge().DataPoints().AppendEmpty() + + dp := pmetric.NewNumberDataPoint() dp.SetStartTimestamp(start) dp.SetTimestamp(ts) + if slices.Contains(m.config.EnabledAttributes, "direction") { + dp.Attributes().PutStr("direction", throughputDirectionAttributeValue) + } + if slices.Contains(m.config.EnabledAttributes, "object") { + dp.Attributes().PutStr("object", objectNameAttributeValue) + } + + var s string + dps := m.data.Gauge().DataPoints() + for i := 0; i < dps.Len(); i++ { + dpi := dps.At(i) + if dp.Attributes().Equal(dpi.Attributes()) && dp.StartTimestamp() == dpi.StartTimestamp() && dp.Timestamp() == dpi.Timestamp() { + switch s = m.config.AggregationStrategy; s { + case AggregationStrategySum, AggregationStrategyAvg: + dpi.SetDoubleValue(dpi.DoubleValue() + val) + m.aggDataPoints[i] += 1 + return + case AggregationStrategyMin: + if dpi.DoubleValue() > val { + dpi.SetDoubleValue(val) + } + return + case AggregationStrategyMax: + if dpi.DoubleValue() < val { + dpi.SetDoubleValue(val) + } + return + } + } + } + dp.SetDoubleValue(val) - dp.Attributes().PutStr("direction", throughputDirectionAttributeValue) - dp.Attributes().PutStr("object", objectNameAttributeValue) + m.aggDataPoints = append(m.aggDataPoints, 1) + dp.MoveTo(dps.AppendEmpty()) } // updateCapacity saves max length of data point slices that will be used for the slice capacity. @@ -2317,6 +3445,11 @@ func (m *metricVcenterHostNetworkPacketDropRate) updateCapacity() { // emit appends recorded metric data to a metrics slice and prepares it for recording another set of data points. func (m *metricVcenterHostNetworkPacketDropRate) emit(metrics pmetric.MetricSlice) { if m.config.Enabled && m.data.Gauge().DataPoints().Len() > 0 { + if m.config.AggregationStrategy == AggregationStrategyAvg { + for i, aggCount := range m.aggDataPoints { + m.data.Gauge().DataPoints().At(i).SetDoubleValue(m.data.Gauge().DataPoints().At(i).DoubleValue() / aggCount) + } + } m.updateCapacity() m.data.MoveTo(metrics.AppendEmpty()) m.init() @@ -2334,9 +3467,10 @@ func newMetricVcenterHostNetworkPacketDropRate(cfg MetricConfig) metricVcenterHo } type metricVcenterHostNetworkPacketErrorRate struct { - data pmetric.Metric // data buffer for generated metric. - config MetricConfig // metric config provided by user. - capacity int // max observed number of data points added to the metric. + data pmetric.Metric // data buffer for generated metric. + config MetricConfig // metric config provided by user. + capacity int // max observed number of data points added to the metric. + aggDataPoints []float64 // slice containing number of aggregated datapoints at each index } // init fills vcenter.host.network.packet.error.rate metric with initial data. @@ -2346,18 +3480,51 @@ func (m *metricVcenterHostNetworkPacketErrorRate) init() { m.data.SetUnit("{errors/s}") m.data.SetEmptyGauge() m.data.Gauge().DataPoints().EnsureCapacity(m.capacity) + m.aggDataPoints = m.aggDataPoints[:0] } func (m *metricVcenterHostNetworkPacketErrorRate) recordDataPoint(start pcommon.Timestamp, ts pcommon.Timestamp, val float64, throughputDirectionAttributeValue string, objectNameAttributeValue string) { if !m.config.Enabled { return } - dp := m.data.Gauge().DataPoints().AppendEmpty() + + dp := pmetric.NewNumberDataPoint() dp.SetStartTimestamp(start) dp.SetTimestamp(ts) + if slices.Contains(m.config.EnabledAttributes, "direction") { + dp.Attributes().PutStr("direction", throughputDirectionAttributeValue) + } + if slices.Contains(m.config.EnabledAttributes, "object") { + dp.Attributes().PutStr("object", objectNameAttributeValue) + } + + var s string + dps := m.data.Gauge().DataPoints() + for i := 0; i < dps.Len(); i++ { + dpi := dps.At(i) + if dp.Attributes().Equal(dpi.Attributes()) && dp.StartTimestamp() == dpi.StartTimestamp() && dp.Timestamp() == dpi.Timestamp() { + switch s = m.config.AggregationStrategy; s { + case AggregationStrategySum, AggregationStrategyAvg: + dpi.SetDoubleValue(dpi.DoubleValue() + val) + m.aggDataPoints[i] += 1 + return + case AggregationStrategyMin: + if dpi.DoubleValue() > val { + dpi.SetDoubleValue(val) + } + return + case AggregationStrategyMax: + if dpi.DoubleValue() < val { + dpi.SetDoubleValue(val) + } + return + } + } + } + dp.SetDoubleValue(val) - dp.Attributes().PutStr("direction", throughputDirectionAttributeValue) - dp.Attributes().PutStr("object", objectNameAttributeValue) + m.aggDataPoints = append(m.aggDataPoints, 1) + dp.MoveTo(dps.AppendEmpty()) } // updateCapacity saves max length of data point slices that will be used for the slice capacity. @@ -2370,6 +3537,11 @@ func (m *metricVcenterHostNetworkPacketErrorRate) updateCapacity() { // emit appends recorded metric data to a metrics slice and prepares it for recording another set of data points. func (m *metricVcenterHostNetworkPacketErrorRate) emit(metrics pmetric.MetricSlice) { if m.config.Enabled && m.data.Gauge().DataPoints().Len() > 0 { + if m.config.AggregationStrategy == AggregationStrategyAvg { + for i, aggCount := range m.aggDataPoints { + m.data.Gauge().DataPoints().At(i).SetDoubleValue(m.data.Gauge().DataPoints().At(i).DoubleValue() / aggCount) + } + } m.updateCapacity() m.data.MoveTo(metrics.AppendEmpty()) m.init() @@ -2387,9 +3559,10 @@ func newMetricVcenterHostNetworkPacketErrorRate(cfg MetricConfig) metricVcenterH } type metricVcenterHostNetworkPacketRate struct { - data pmetric.Metric // data buffer for generated metric. - config MetricConfig // metric config provided by user. - capacity int // max observed number of data points added to the metric. + data pmetric.Metric // data buffer for generated metric. + config MetricConfig // metric config provided by user. + capacity int // max observed number of data points added to the metric. + aggDataPoints []float64 // slice containing number of aggregated datapoints at each index } // init fills vcenter.host.network.packet.rate metric with initial data. @@ -2399,18 +3572,51 @@ func (m *metricVcenterHostNetworkPacketRate) init() { m.data.SetUnit("{packets/s}") m.data.SetEmptyGauge() m.data.Gauge().DataPoints().EnsureCapacity(m.capacity) + m.aggDataPoints = m.aggDataPoints[:0] } func (m *metricVcenterHostNetworkPacketRate) recordDataPoint(start pcommon.Timestamp, ts pcommon.Timestamp, val float64, throughputDirectionAttributeValue string, objectNameAttributeValue string) { if !m.config.Enabled { return } - dp := m.data.Gauge().DataPoints().AppendEmpty() + + dp := pmetric.NewNumberDataPoint() dp.SetStartTimestamp(start) dp.SetTimestamp(ts) + if slices.Contains(m.config.EnabledAttributes, "direction") { + dp.Attributes().PutStr("direction", throughputDirectionAttributeValue) + } + if slices.Contains(m.config.EnabledAttributes, "object") { + dp.Attributes().PutStr("object", objectNameAttributeValue) + } + + var s string + dps := m.data.Gauge().DataPoints() + for i := 0; i < dps.Len(); i++ { + dpi := dps.At(i) + if dp.Attributes().Equal(dpi.Attributes()) && dp.StartTimestamp() == dpi.StartTimestamp() && dp.Timestamp() == dpi.Timestamp() { + switch s = m.config.AggregationStrategy; s { + case AggregationStrategySum, AggregationStrategyAvg: + dpi.SetDoubleValue(dpi.DoubleValue() + val) + m.aggDataPoints[i] += 1 + return + case AggregationStrategyMin: + if dpi.DoubleValue() > val { + dpi.SetDoubleValue(val) + } + return + case AggregationStrategyMax: + if dpi.DoubleValue() < val { + dpi.SetDoubleValue(val) + } + return + } + } + } + dp.SetDoubleValue(val) - dp.Attributes().PutStr("direction", throughputDirectionAttributeValue) - dp.Attributes().PutStr("object", objectNameAttributeValue) + m.aggDataPoints = append(m.aggDataPoints, 1) + dp.MoveTo(dps.AppendEmpty()) } // updateCapacity saves max length of data point slices that will be used for the slice capacity. @@ -2423,6 +3629,11 @@ func (m *metricVcenterHostNetworkPacketRate) updateCapacity() { // emit appends recorded metric data to a metrics slice and prepares it for recording another set of data points. func (m *metricVcenterHostNetworkPacketRate) emit(metrics pmetric.MetricSlice) { if m.config.Enabled && m.data.Gauge().DataPoints().Len() > 0 { + if m.config.AggregationStrategy == AggregationStrategyAvg { + for i, aggCount := range m.aggDataPoints { + m.data.Gauge().DataPoints().At(i).SetDoubleValue(m.data.Gauge().DataPoints().At(i).DoubleValue() / aggCount) + } + } m.updateCapacity() m.data.MoveTo(metrics.AppendEmpty()) m.init() @@ -2440,9 +3651,10 @@ func newMetricVcenterHostNetworkPacketRate(cfg MetricConfig) metricVcenterHostNe } type metricVcenterHostNetworkThroughput struct { - data pmetric.Metric // data buffer for generated metric. - config MetricConfig // metric config provided by user. - capacity int // max observed number of data points added to the metric. + data pmetric.Metric // data buffer for generated metric. + config MetricConfig // metric config provided by user. + capacity int // max observed number of data points added to the metric. + aggDataPoints []int64 // slice containing number of aggregated datapoints at each index } // init fills vcenter.host.network.throughput metric with initial data. @@ -2454,18 +3666,51 @@ func (m *metricVcenterHostNetworkThroughput) init() { m.data.Sum().SetIsMonotonic(false) m.data.Sum().SetAggregationTemporality(pmetric.AggregationTemporalityCumulative) m.data.Sum().DataPoints().EnsureCapacity(m.capacity) + m.aggDataPoints = m.aggDataPoints[:0] } func (m *metricVcenterHostNetworkThroughput) recordDataPoint(start pcommon.Timestamp, ts pcommon.Timestamp, val int64, throughputDirectionAttributeValue string, objectNameAttributeValue string) { if !m.config.Enabled { return } - dp := m.data.Sum().DataPoints().AppendEmpty() + + dp := pmetric.NewNumberDataPoint() dp.SetStartTimestamp(start) dp.SetTimestamp(ts) + if slices.Contains(m.config.EnabledAttributes, "direction") { + dp.Attributes().PutStr("direction", throughputDirectionAttributeValue) + } + if slices.Contains(m.config.EnabledAttributes, "object") { + dp.Attributes().PutStr("object", objectNameAttributeValue) + } + + var s string + dps := m.data.Sum().DataPoints() + for i := 0; i < dps.Len(); i++ { + dpi := dps.At(i) + if dp.Attributes().Equal(dpi.Attributes()) && dp.StartTimestamp() == dpi.StartTimestamp() && dp.Timestamp() == dpi.Timestamp() { + switch s = m.config.AggregationStrategy; s { + case AggregationStrategySum, AggregationStrategyAvg: + dpi.SetIntValue(dpi.IntValue() + val) + m.aggDataPoints[i] += 1 + return + case AggregationStrategyMin: + if dpi.IntValue() > val { + dpi.SetIntValue(val) + } + return + case AggregationStrategyMax: + if dpi.IntValue() < val { + dpi.SetIntValue(val) + } + return + } + } + } + dp.SetIntValue(val) - dp.Attributes().PutStr("direction", throughputDirectionAttributeValue) - dp.Attributes().PutStr("object", objectNameAttributeValue) + m.aggDataPoints = append(m.aggDataPoints, 1) + dp.MoveTo(dps.AppendEmpty()) } // updateCapacity saves max length of data point slices that will be used for the slice capacity. @@ -2478,7 +3723,12 @@ func (m *metricVcenterHostNetworkThroughput) updateCapacity() { // emit appends recorded metric data to a metrics slice and prepares it for recording another set of data points. func (m *metricVcenterHostNetworkThroughput) emit(metrics pmetric.MetricSlice) { if m.config.Enabled && m.data.Sum().DataPoints().Len() > 0 { - m.updateCapacity() + if m.config.AggregationStrategy == AggregationStrategyAvg { + for i, aggCount := range m.aggDataPoints { + m.data.Sum().DataPoints().At(i).SetIntValue(m.data.Sum().DataPoints().At(i).IntValue() / aggCount) + } + } + m.updateCapacity() m.data.MoveTo(metrics.AppendEmpty()) m.init() } @@ -2495,9 +3745,10 @@ func newMetricVcenterHostNetworkThroughput(cfg MetricConfig) metricVcenterHostNe } type metricVcenterHostNetworkUsage struct { - data pmetric.Metric // data buffer for generated metric. - config MetricConfig // metric config provided by user. - capacity int // max observed number of data points added to the metric. + data pmetric.Metric // data buffer for generated metric. + config MetricConfig // metric config provided by user. + capacity int // max observed number of data points added to the metric. + aggDataPoints []int64 // slice containing number of aggregated datapoints at each index } // init fills vcenter.host.network.usage metric with initial data. @@ -2509,17 +3760,48 @@ func (m *metricVcenterHostNetworkUsage) init() { m.data.Sum().SetIsMonotonic(false) m.data.Sum().SetAggregationTemporality(pmetric.AggregationTemporalityCumulative) m.data.Sum().DataPoints().EnsureCapacity(m.capacity) + m.aggDataPoints = m.aggDataPoints[:0] } func (m *metricVcenterHostNetworkUsage) recordDataPoint(start pcommon.Timestamp, ts pcommon.Timestamp, val int64, objectNameAttributeValue string) { if !m.config.Enabled { return } - dp := m.data.Sum().DataPoints().AppendEmpty() + + dp := pmetric.NewNumberDataPoint() dp.SetStartTimestamp(start) dp.SetTimestamp(ts) + if slices.Contains(m.config.EnabledAttributes, "object") { + dp.Attributes().PutStr("object", objectNameAttributeValue) + } + + var s string + dps := m.data.Sum().DataPoints() + for i := 0; i < dps.Len(); i++ { + dpi := dps.At(i) + if dp.Attributes().Equal(dpi.Attributes()) && dp.StartTimestamp() == dpi.StartTimestamp() && dp.Timestamp() == dpi.Timestamp() { + switch s = m.config.AggregationStrategy; s { + case AggregationStrategySum, AggregationStrategyAvg: + dpi.SetIntValue(dpi.IntValue() + val) + m.aggDataPoints[i] += 1 + return + case AggregationStrategyMin: + if dpi.IntValue() > val { + dpi.SetIntValue(val) + } + return + case AggregationStrategyMax: + if dpi.IntValue() < val { + dpi.SetIntValue(val) + } + return + } + } + } + dp.SetIntValue(val) - dp.Attributes().PutStr("object", objectNameAttributeValue) + m.aggDataPoints = append(m.aggDataPoints, 1) + dp.MoveTo(dps.AppendEmpty()) } // updateCapacity saves max length of data point slices that will be used for the slice capacity. @@ -2532,6 +3814,11 @@ func (m *metricVcenterHostNetworkUsage) updateCapacity() { // emit appends recorded metric data to a metrics slice and prepares it for recording another set of data points. func (m *metricVcenterHostNetworkUsage) emit(metrics pmetric.MetricSlice) { if m.config.Enabled && m.data.Sum().DataPoints().Len() > 0 { + if m.config.AggregationStrategy == AggregationStrategyAvg { + for i, aggCount := range m.aggDataPoints { + m.data.Sum().DataPoints().At(i).SetIntValue(m.data.Sum().DataPoints().At(i).IntValue() / aggCount) + } + } m.updateCapacity() m.data.MoveTo(metrics.AppendEmpty()) m.init() @@ -2549,9 +3836,10 @@ func newMetricVcenterHostNetworkUsage(cfg MetricConfig) metricVcenterHostNetwork } type metricVcenterHostVsanCacheHitRate struct { - data pmetric.Metric // data buffer for generated metric. - config MetricConfig // metric config provided by user. - capacity int // max observed number of data points added to the metric. + data pmetric.Metric // data buffer for generated metric. + config MetricConfig // metric config provided by user. + capacity int // max observed number of data points added to the metric. + aggDataPoints []int64 // slice containing number of aggregated datapoints at each index } // init fills vcenter.host.vsan.cache.hit_rate metric with initial data. @@ -2560,16 +3848,45 @@ func (m *metricVcenterHostVsanCacheHitRate) init() { m.data.SetDescription("The host's read IOs which could be satisfied by the local client cache.") m.data.SetUnit("%") m.data.SetEmptyGauge() + m.aggDataPoints = m.aggDataPoints[:0] } func (m *metricVcenterHostVsanCacheHitRate) recordDataPoint(start pcommon.Timestamp, ts pcommon.Timestamp, val int64) { if !m.config.Enabled { return } - dp := m.data.Gauge().DataPoints().AppendEmpty() + + dp := pmetric.NewNumberDataPoint() dp.SetStartTimestamp(start) dp.SetTimestamp(ts) + + var s string + dps := m.data.Gauge().DataPoints() + for i := 0; i < dps.Len(); i++ { + dpi := dps.At(i) + if dp.Attributes().Equal(dpi.Attributes()) && dp.StartTimestamp() == dpi.StartTimestamp() && dp.Timestamp() == dpi.Timestamp() { + switch s = m.config.AggregationStrategy; s { + case AggregationStrategySum, AggregationStrategyAvg: + dpi.SetIntValue(dpi.IntValue() + val) + m.aggDataPoints[i] += 1 + return + case AggregationStrategyMin: + if dpi.IntValue() > val { + dpi.SetIntValue(val) + } + return + case AggregationStrategyMax: + if dpi.IntValue() < val { + dpi.SetIntValue(val) + } + return + } + } + } + dp.SetIntValue(val) + m.aggDataPoints = append(m.aggDataPoints, 1) + dp.MoveTo(dps.AppendEmpty()) } // updateCapacity saves max length of data point slices that will be used for the slice capacity. @@ -2582,6 +3899,11 @@ func (m *metricVcenterHostVsanCacheHitRate) updateCapacity() { // emit appends recorded metric data to a metrics slice and prepares it for recording another set of data points. func (m *metricVcenterHostVsanCacheHitRate) emit(metrics pmetric.MetricSlice) { if m.config.Enabled && m.data.Gauge().DataPoints().Len() > 0 { + if m.config.AggregationStrategy == AggregationStrategyAvg { + for i, aggCount := range m.aggDataPoints { + m.data.Gauge().DataPoints().At(i).SetIntValue(m.data.Gauge().DataPoints().At(i).IntValue() / aggCount) + } + } m.updateCapacity() m.data.MoveTo(metrics.AppendEmpty()) m.init() @@ -2599,9 +3921,10 @@ func newMetricVcenterHostVsanCacheHitRate(cfg MetricConfig) metricVcenterHostVsa } type metricVcenterHostVsanCongestions struct { - data pmetric.Metric // data buffer for generated metric. - config MetricConfig // metric config provided by user. - capacity int // max observed number of data points added to the metric. + data pmetric.Metric // data buffer for generated metric. + config MetricConfig // metric config provided by user. + capacity int // max observed number of data points added to the metric. + aggDataPoints []float64 // slice containing number of aggregated datapoints at each index } // init fills vcenter.host.vsan.congestions metric with initial data. @@ -2610,16 +3933,45 @@ func (m *metricVcenterHostVsanCongestions) init() { m.data.SetDescription("The congestions of IOs generated by all vSAN clients in the host.") m.data.SetUnit("{congestions/s}") m.data.SetEmptyGauge() + m.aggDataPoints = m.aggDataPoints[:0] } func (m *metricVcenterHostVsanCongestions) recordDataPoint(start pcommon.Timestamp, ts pcommon.Timestamp, val float64) { if !m.config.Enabled { return } - dp := m.data.Gauge().DataPoints().AppendEmpty() + + dp := pmetric.NewNumberDataPoint() dp.SetStartTimestamp(start) dp.SetTimestamp(ts) + + var s string + dps := m.data.Gauge().DataPoints() + for i := 0; i < dps.Len(); i++ { + dpi := dps.At(i) + if dp.Attributes().Equal(dpi.Attributes()) && dp.StartTimestamp() == dpi.StartTimestamp() && dp.Timestamp() == dpi.Timestamp() { + switch s = m.config.AggregationStrategy; s { + case AggregationStrategySum, AggregationStrategyAvg: + dpi.SetDoubleValue(dpi.DoubleValue() + val) + m.aggDataPoints[i] += 1 + return + case AggregationStrategyMin: + if dpi.DoubleValue() > val { + dpi.SetDoubleValue(val) + } + return + case AggregationStrategyMax: + if dpi.DoubleValue() < val { + dpi.SetDoubleValue(val) + } + return + } + } + } + dp.SetDoubleValue(val) + m.aggDataPoints = append(m.aggDataPoints, 1) + dp.MoveTo(dps.AppendEmpty()) } // updateCapacity saves max length of data point slices that will be used for the slice capacity. @@ -2632,6 +3984,11 @@ func (m *metricVcenterHostVsanCongestions) updateCapacity() { // emit appends recorded metric data to a metrics slice and prepares it for recording another set of data points. func (m *metricVcenterHostVsanCongestions) emit(metrics pmetric.MetricSlice) { if m.config.Enabled && m.data.Gauge().DataPoints().Len() > 0 { + if m.config.AggregationStrategy == AggregationStrategyAvg { + for i, aggCount := range m.aggDataPoints { + m.data.Gauge().DataPoints().At(i).SetDoubleValue(m.data.Gauge().DataPoints().At(i).DoubleValue() / aggCount) + } + } m.updateCapacity() m.data.MoveTo(metrics.AppendEmpty()) m.init() @@ -2649,9 +4006,10 @@ func newMetricVcenterHostVsanCongestions(cfg MetricConfig) metricVcenterHostVsan } type metricVcenterHostVsanLatencyAvg struct { - data pmetric.Metric // data buffer for generated metric. - config MetricConfig // metric config provided by user. - capacity int // max observed number of data points added to the metric. + data pmetric.Metric // data buffer for generated metric. + config MetricConfig // metric config provided by user. + capacity int // max observed number of data points added to the metric. + aggDataPoints []int64 // slice containing number of aggregated datapoints at each index } // init fills vcenter.host.vsan.latency.avg metric with initial data. @@ -2661,17 +4019,48 @@ func (m *metricVcenterHostVsanLatencyAvg) init() { m.data.SetUnit("us") m.data.SetEmptyGauge() m.data.Gauge().DataPoints().EnsureCapacity(m.capacity) + m.aggDataPoints = m.aggDataPoints[:0] } func (m *metricVcenterHostVsanLatencyAvg) recordDataPoint(start pcommon.Timestamp, ts pcommon.Timestamp, val int64, vsanLatencyTypeAttributeValue string) { if !m.config.Enabled { return } - dp := m.data.Gauge().DataPoints().AppendEmpty() + + dp := pmetric.NewNumberDataPoint() dp.SetStartTimestamp(start) dp.SetTimestamp(ts) + if slices.Contains(m.config.EnabledAttributes, "type") { + dp.Attributes().PutStr("type", vsanLatencyTypeAttributeValue) + } + + var s string + dps := m.data.Gauge().DataPoints() + for i := 0; i < dps.Len(); i++ { + dpi := dps.At(i) + if dp.Attributes().Equal(dpi.Attributes()) && dp.StartTimestamp() == dpi.StartTimestamp() && dp.Timestamp() == dpi.Timestamp() { + switch s = m.config.AggregationStrategy; s { + case AggregationStrategySum, AggregationStrategyAvg: + dpi.SetIntValue(dpi.IntValue() + val) + m.aggDataPoints[i] += 1 + return + case AggregationStrategyMin: + if dpi.IntValue() > val { + dpi.SetIntValue(val) + } + return + case AggregationStrategyMax: + if dpi.IntValue() < val { + dpi.SetIntValue(val) + } + return + } + } + } + dp.SetIntValue(val) - dp.Attributes().PutStr("type", vsanLatencyTypeAttributeValue) + m.aggDataPoints = append(m.aggDataPoints, 1) + dp.MoveTo(dps.AppendEmpty()) } // updateCapacity saves max length of data point slices that will be used for the slice capacity. @@ -2684,6 +4073,11 @@ func (m *metricVcenterHostVsanLatencyAvg) updateCapacity() { // emit appends recorded metric data to a metrics slice and prepares it for recording another set of data points. func (m *metricVcenterHostVsanLatencyAvg) emit(metrics pmetric.MetricSlice) { if m.config.Enabled && m.data.Gauge().DataPoints().Len() > 0 { + if m.config.AggregationStrategy == AggregationStrategyAvg { + for i, aggCount := range m.aggDataPoints { + m.data.Gauge().DataPoints().At(i).SetIntValue(m.data.Gauge().DataPoints().At(i).IntValue() / aggCount) + } + } m.updateCapacity() m.data.MoveTo(metrics.AppendEmpty()) m.init() @@ -2701,9 +4095,10 @@ func newMetricVcenterHostVsanLatencyAvg(cfg MetricConfig) metricVcenterHostVsanL } type metricVcenterHostVsanOperations struct { - data pmetric.Metric // data buffer for generated metric. - config MetricConfig // metric config provided by user. - capacity int // max observed number of data points added to the metric. + data pmetric.Metric // data buffer for generated metric. + config MetricConfig // metric config provided by user. + capacity int // max observed number of data points added to the metric. + aggDataPoints []int64 // slice containing number of aggregated datapoints at each index } // init fills vcenter.host.vsan.operations metric with initial data. @@ -2713,17 +4108,48 @@ func (m *metricVcenterHostVsanOperations) init() { m.data.SetUnit("{operations/s}") m.data.SetEmptyGauge() m.data.Gauge().DataPoints().EnsureCapacity(m.capacity) + m.aggDataPoints = m.aggDataPoints[:0] } func (m *metricVcenterHostVsanOperations) recordDataPoint(start pcommon.Timestamp, ts pcommon.Timestamp, val int64, vsanOperationTypeAttributeValue string) { if !m.config.Enabled { return } - dp := m.data.Gauge().DataPoints().AppendEmpty() + + dp := pmetric.NewNumberDataPoint() dp.SetStartTimestamp(start) dp.SetTimestamp(ts) + if slices.Contains(m.config.EnabledAttributes, "type") { + dp.Attributes().PutStr("type", vsanOperationTypeAttributeValue) + } + + var s string + dps := m.data.Gauge().DataPoints() + for i := 0; i < dps.Len(); i++ { + dpi := dps.At(i) + if dp.Attributes().Equal(dpi.Attributes()) && dp.StartTimestamp() == dpi.StartTimestamp() && dp.Timestamp() == dpi.Timestamp() { + switch s = m.config.AggregationStrategy; s { + case AggregationStrategySum, AggregationStrategyAvg: + dpi.SetIntValue(dpi.IntValue() + val) + m.aggDataPoints[i] += 1 + return + case AggregationStrategyMin: + if dpi.IntValue() > val { + dpi.SetIntValue(val) + } + return + case AggregationStrategyMax: + if dpi.IntValue() < val { + dpi.SetIntValue(val) + } + return + } + } + } + dp.SetIntValue(val) - dp.Attributes().PutStr("type", vsanOperationTypeAttributeValue) + m.aggDataPoints = append(m.aggDataPoints, 1) + dp.MoveTo(dps.AppendEmpty()) } // updateCapacity saves max length of data point slices that will be used for the slice capacity. @@ -2736,6 +4162,11 @@ func (m *metricVcenterHostVsanOperations) updateCapacity() { // emit appends recorded metric data to a metrics slice and prepares it for recording another set of data points. func (m *metricVcenterHostVsanOperations) emit(metrics pmetric.MetricSlice) { if m.config.Enabled && m.data.Gauge().DataPoints().Len() > 0 { + if m.config.AggregationStrategy == AggregationStrategyAvg { + for i, aggCount := range m.aggDataPoints { + m.data.Gauge().DataPoints().At(i).SetIntValue(m.data.Gauge().DataPoints().At(i).IntValue() / aggCount) + } + } m.updateCapacity() m.data.MoveTo(metrics.AppendEmpty()) m.init() @@ -2753,9 +4184,10 @@ func newMetricVcenterHostVsanOperations(cfg MetricConfig) metricVcenterHostVsanO } type metricVcenterHostVsanThroughput struct { - data pmetric.Metric // data buffer for generated metric. - config MetricConfig // metric config provided by user. - capacity int // max observed number of data points added to the metric. + data pmetric.Metric // data buffer for generated metric. + config MetricConfig // metric config provided by user. + capacity int // max observed number of data points added to the metric. + aggDataPoints []float64 // slice containing number of aggregated datapoints at each index } // init fills vcenter.host.vsan.throughput metric with initial data. @@ -2765,17 +4197,48 @@ func (m *metricVcenterHostVsanThroughput) init() { m.data.SetUnit("By/s") m.data.SetEmptyGauge() m.data.Gauge().DataPoints().EnsureCapacity(m.capacity) + m.aggDataPoints = m.aggDataPoints[:0] } func (m *metricVcenterHostVsanThroughput) recordDataPoint(start pcommon.Timestamp, ts pcommon.Timestamp, val float64, vsanThroughputDirectionAttributeValue string) { if !m.config.Enabled { return } - dp := m.data.Gauge().DataPoints().AppendEmpty() + + dp := pmetric.NewNumberDataPoint() dp.SetStartTimestamp(start) dp.SetTimestamp(ts) + if slices.Contains(m.config.EnabledAttributes, "direction") { + dp.Attributes().PutStr("direction", vsanThroughputDirectionAttributeValue) + } + + var s string + dps := m.data.Gauge().DataPoints() + for i := 0; i < dps.Len(); i++ { + dpi := dps.At(i) + if dp.Attributes().Equal(dpi.Attributes()) && dp.StartTimestamp() == dpi.StartTimestamp() && dp.Timestamp() == dpi.Timestamp() { + switch s = m.config.AggregationStrategy; s { + case AggregationStrategySum, AggregationStrategyAvg: + dpi.SetDoubleValue(dpi.DoubleValue() + val) + m.aggDataPoints[i] += 1 + return + case AggregationStrategyMin: + if dpi.DoubleValue() > val { + dpi.SetDoubleValue(val) + } + return + case AggregationStrategyMax: + if dpi.DoubleValue() < val { + dpi.SetDoubleValue(val) + } + return + } + } + } + dp.SetDoubleValue(val) - dp.Attributes().PutStr("direction", vsanThroughputDirectionAttributeValue) + m.aggDataPoints = append(m.aggDataPoints, 1) + dp.MoveTo(dps.AppendEmpty()) } // updateCapacity saves max length of data point slices that will be used for the slice capacity. @@ -2788,6 +4251,11 @@ func (m *metricVcenterHostVsanThroughput) updateCapacity() { // emit appends recorded metric data to a metrics slice and prepares it for recording another set of data points. func (m *metricVcenterHostVsanThroughput) emit(metrics pmetric.MetricSlice) { if m.config.Enabled && m.data.Gauge().DataPoints().Len() > 0 { + if m.config.AggregationStrategy == AggregationStrategyAvg { + for i, aggCount := range m.aggDataPoints { + m.data.Gauge().DataPoints().At(i).SetDoubleValue(m.data.Gauge().DataPoints().At(i).DoubleValue() / aggCount) + } + } m.updateCapacity() m.data.MoveTo(metrics.AppendEmpty()) m.init() @@ -2805,9 +4273,10 @@ func newMetricVcenterHostVsanThroughput(cfg MetricConfig) metricVcenterHostVsanT } type metricVcenterResourcePoolCPUShares struct { - data pmetric.Metric // data buffer for generated metric. - config MetricConfig // metric config provided by user. - capacity int // max observed number of data points added to the metric. + data pmetric.Metric // data buffer for generated metric. + config MetricConfig // metric config provided by user. + capacity int // max observed number of data points added to the metric. + aggDataPoints []int64 // slice containing number of aggregated datapoints at each index } // init fills vcenter.resource_pool.cpu.shares metric with initial data. @@ -2818,16 +4287,45 @@ func (m *metricVcenterResourcePoolCPUShares) init() { m.data.SetEmptySum() m.data.Sum().SetIsMonotonic(false) m.data.Sum().SetAggregationTemporality(pmetric.AggregationTemporalityCumulative) + m.aggDataPoints = m.aggDataPoints[:0] } func (m *metricVcenterResourcePoolCPUShares) recordDataPoint(start pcommon.Timestamp, ts pcommon.Timestamp, val int64) { if !m.config.Enabled { return } - dp := m.data.Sum().DataPoints().AppendEmpty() + + dp := pmetric.NewNumberDataPoint() dp.SetStartTimestamp(start) dp.SetTimestamp(ts) + + var s string + dps := m.data.Sum().DataPoints() + for i := 0; i < dps.Len(); i++ { + dpi := dps.At(i) + if dp.Attributes().Equal(dpi.Attributes()) && dp.StartTimestamp() == dpi.StartTimestamp() && dp.Timestamp() == dpi.Timestamp() { + switch s = m.config.AggregationStrategy; s { + case AggregationStrategySum, AggregationStrategyAvg: + dpi.SetIntValue(dpi.IntValue() + val) + m.aggDataPoints[i] += 1 + return + case AggregationStrategyMin: + if dpi.IntValue() > val { + dpi.SetIntValue(val) + } + return + case AggregationStrategyMax: + if dpi.IntValue() < val { + dpi.SetIntValue(val) + } + return + } + } + } + dp.SetIntValue(val) + m.aggDataPoints = append(m.aggDataPoints, 1) + dp.MoveTo(dps.AppendEmpty()) } // updateCapacity saves max length of data point slices that will be used for the slice capacity. @@ -2840,6 +4338,11 @@ func (m *metricVcenterResourcePoolCPUShares) updateCapacity() { // emit appends recorded metric data to a metrics slice and prepares it for recording another set of data points. func (m *metricVcenterResourcePoolCPUShares) emit(metrics pmetric.MetricSlice) { if m.config.Enabled && m.data.Sum().DataPoints().Len() > 0 { + if m.config.AggregationStrategy == AggregationStrategyAvg { + for i, aggCount := range m.aggDataPoints { + m.data.Sum().DataPoints().At(i).SetIntValue(m.data.Sum().DataPoints().At(i).IntValue() / aggCount) + } + } m.updateCapacity() m.data.MoveTo(metrics.AppendEmpty()) m.init() @@ -2857,9 +4360,10 @@ func newMetricVcenterResourcePoolCPUShares(cfg MetricConfig) metricVcenterResour } type metricVcenterResourcePoolCPUUsage struct { - data pmetric.Metric // data buffer for generated metric. - config MetricConfig // metric config provided by user. - capacity int // max observed number of data points added to the metric. + data pmetric.Metric // data buffer for generated metric. + config MetricConfig // metric config provided by user. + capacity int // max observed number of data points added to the metric. + aggDataPoints []int64 // slice containing number of aggregated datapoints at each index } // init fills vcenter.resource_pool.cpu.usage metric with initial data. @@ -2870,16 +4374,45 @@ func (m *metricVcenterResourcePoolCPUUsage) init() { m.data.SetEmptySum() m.data.Sum().SetIsMonotonic(false) m.data.Sum().SetAggregationTemporality(pmetric.AggregationTemporalityCumulative) + m.aggDataPoints = m.aggDataPoints[:0] } func (m *metricVcenterResourcePoolCPUUsage) recordDataPoint(start pcommon.Timestamp, ts pcommon.Timestamp, val int64) { if !m.config.Enabled { return } - dp := m.data.Sum().DataPoints().AppendEmpty() + + dp := pmetric.NewNumberDataPoint() dp.SetStartTimestamp(start) dp.SetTimestamp(ts) + + var s string + dps := m.data.Sum().DataPoints() + for i := 0; i < dps.Len(); i++ { + dpi := dps.At(i) + if dp.Attributes().Equal(dpi.Attributes()) && dp.StartTimestamp() == dpi.StartTimestamp() && dp.Timestamp() == dpi.Timestamp() { + switch s = m.config.AggregationStrategy; s { + case AggregationStrategySum, AggregationStrategyAvg: + dpi.SetIntValue(dpi.IntValue() + val) + m.aggDataPoints[i] += 1 + return + case AggregationStrategyMin: + if dpi.IntValue() > val { + dpi.SetIntValue(val) + } + return + case AggregationStrategyMax: + if dpi.IntValue() < val { + dpi.SetIntValue(val) + } + return + } + } + } + dp.SetIntValue(val) + m.aggDataPoints = append(m.aggDataPoints, 1) + dp.MoveTo(dps.AppendEmpty()) } // updateCapacity saves max length of data point slices that will be used for the slice capacity. @@ -2892,6 +4425,11 @@ func (m *metricVcenterResourcePoolCPUUsage) updateCapacity() { // emit appends recorded metric data to a metrics slice and prepares it for recording another set of data points. func (m *metricVcenterResourcePoolCPUUsage) emit(metrics pmetric.MetricSlice) { if m.config.Enabled && m.data.Sum().DataPoints().Len() > 0 { + if m.config.AggregationStrategy == AggregationStrategyAvg { + for i, aggCount := range m.aggDataPoints { + m.data.Sum().DataPoints().At(i).SetIntValue(m.data.Sum().DataPoints().At(i).IntValue() / aggCount) + } + } m.updateCapacity() m.data.MoveTo(metrics.AppendEmpty()) m.init() @@ -2909,9 +4447,10 @@ func newMetricVcenterResourcePoolCPUUsage(cfg MetricConfig) metricVcenterResourc } type metricVcenterResourcePoolMemoryBallooned struct { - data pmetric.Metric // data buffer for generated metric. - config MetricConfig // metric config provided by user. - capacity int // max observed number of data points added to the metric. + data pmetric.Metric // data buffer for generated metric. + config MetricConfig // metric config provided by user. + capacity int // max observed number of data points added to the metric. + aggDataPoints []int64 // slice containing number of aggregated datapoints at each index } // init fills vcenter.resource_pool.memory.ballooned metric with initial data. @@ -2922,16 +4461,45 @@ func (m *metricVcenterResourcePoolMemoryBallooned) init() { m.data.SetEmptySum() m.data.Sum().SetIsMonotonic(false) m.data.Sum().SetAggregationTemporality(pmetric.AggregationTemporalityCumulative) + m.aggDataPoints = m.aggDataPoints[:0] } func (m *metricVcenterResourcePoolMemoryBallooned) recordDataPoint(start pcommon.Timestamp, ts pcommon.Timestamp, val int64) { if !m.config.Enabled { return } - dp := m.data.Sum().DataPoints().AppendEmpty() + + dp := pmetric.NewNumberDataPoint() dp.SetStartTimestamp(start) dp.SetTimestamp(ts) + + var s string + dps := m.data.Sum().DataPoints() + for i := 0; i < dps.Len(); i++ { + dpi := dps.At(i) + if dp.Attributes().Equal(dpi.Attributes()) && dp.StartTimestamp() == dpi.StartTimestamp() && dp.Timestamp() == dpi.Timestamp() { + switch s = m.config.AggregationStrategy; s { + case AggregationStrategySum, AggregationStrategyAvg: + dpi.SetIntValue(dpi.IntValue() + val) + m.aggDataPoints[i] += 1 + return + case AggregationStrategyMin: + if dpi.IntValue() > val { + dpi.SetIntValue(val) + } + return + case AggregationStrategyMax: + if dpi.IntValue() < val { + dpi.SetIntValue(val) + } + return + } + } + } + dp.SetIntValue(val) + m.aggDataPoints = append(m.aggDataPoints, 1) + dp.MoveTo(dps.AppendEmpty()) } // updateCapacity saves max length of data point slices that will be used for the slice capacity. @@ -2944,6 +4512,11 @@ func (m *metricVcenterResourcePoolMemoryBallooned) updateCapacity() { // emit appends recorded metric data to a metrics slice and prepares it for recording another set of data points. func (m *metricVcenterResourcePoolMemoryBallooned) emit(metrics pmetric.MetricSlice) { if m.config.Enabled && m.data.Sum().DataPoints().Len() > 0 { + if m.config.AggregationStrategy == AggregationStrategyAvg { + for i, aggCount := range m.aggDataPoints { + m.data.Sum().DataPoints().At(i).SetIntValue(m.data.Sum().DataPoints().At(i).IntValue() / aggCount) + } + } m.updateCapacity() m.data.MoveTo(metrics.AppendEmpty()) m.init() @@ -2961,9 +4534,10 @@ func newMetricVcenterResourcePoolMemoryBallooned(cfg MetricConfig) metricVcenter } type metricVcenterResourcePoolMemoryGranted struct { - data pmetric.Metric // data buffer for generated metric. - config MetricConfig // metric config provided by user. - capacity int // max observed number of data points added to the metric. + data pmetric.Metric // data buffer for generated metric. + config MetricConfig // metric config provided by user. + capacity int // max observed number of data points added to the metric. + aggDataPoints []int64 // slice containing number of aggregated datapoints at each index } // init fills vcenter.resource_pool.memory.granted metric with initial data. @@ -2975,17 +4549,48 @@ func (m *metricVcenterResourcePoolMemoryGranted) init() { m.data.Sum().SetIsMonotonic(false) m.data.Sum().SetAggregationTemporality(pmetric.AggregationTemporalityCumulative) m.data.Sum().DataPoints().EnsureCapacity(m.capacity) + m.aggDataPoints = m.aggDataPoints[:0] } func (m *metricVcenterResourcePoolMemoryGranted) recordDataPoint(start pcommon.Timestamp, ts pcommon.Timestamp, val int64, memoryGrantedTypeAttributeValue string) { if !m.config.Enabled { return } - dp := m.data.Sum().DataPoints().AppendEmpty() + + dp := pmetric.NewNumberDataPoint() dp.SetStartTimestamp(start) dp.SetTimestamp(ts) + if slices.Contains(m.config.EnabledAttributes, "type") { + dp.Attributes().PutStr("type", memoryGrantedTypeAttributeValue) + } + + var s string + dps := m.data.Sum().DataPoints() + for i := 0; i < dps.Len(); i++ { + dpi := dps.At(i) + if dp.Attributes().Equal(dpi.Attributes()) && dp.StartTimestamp() == dpi.StartTimestamp() && dp.Timestamp() == dpi.Timestamp() { + switch s = m.config.AggregationStrategy; s { + case AggregationStrategySum, AggregationStrategyAvg: + dpi.SetIntValue(dpi.IntValue() + val) + m.aggDataPoints[i] += 1 + return + case AggregationStrategyMin: + if dpi.IntValue() > val { + dpi.SetIntValue(val) + } + return + case AggregationStrategyMax: + if dpi.IntValue() < val { + dpi.SetIntValue(val) + } + return + } + } + } + dp.SetIntValue(val) - dp.Attributes().PutStr("type", memoryGrantedTypeAttributeValue) + m.aggDataPoints = append(m.aggDataPoints, 1) + dp.MoveTo(dps.AppendEmpty()) } // updateCapacity saves max length of data point slices that will be used for the slice capacity. @@ -2998,6 +4603,11 @@ func (m *metricVcenterResourcePoolMemoryGranted) updateCapacity() { // emit appends recorded metric data to a metrics slice and prepares it for recording another set of data points. func (m *metricVcenterResourcePoolMemoryGranted) emit(metrics pmetric.MetricSlice) { if m.config.Enabled && m.data.Sum().DataPoints().Len() > 0 { + if m.config.AggregationStrategy == AggregationStrategyAvg { + for i, aggCount := range m.aggDataPoints { + m.data.Sum().DataPoints().At(i).SetIntValue(m.data.Sum().DataPoints().At(i).IntValue() / aggCount) + } + } m.updateCapacity() m.data.MoveTo(metrics.AppendEmpty()) m.init() @@ -3015,9 +4625,10 @@ func newMetricVcenterResourcePoolMemoryGranted(cfg MetricConfig) metricVcenterRe } type metricVcenterResourcePoolMemoryShares struct { - data pmetric.Metric // data buffer for generated metric. - config MetricConfig // metric config provided by user. - capacity int // max observed number of data points added to the metric. + data pmetric.Metric // data buffer for generated metric. + config MetricConfig // metric config provided by user. + capacity int // max observed number of data points added to the metric. + aggDataPoints []int64 // slice containing number of aggregated datapoints at each index } // init fills vcenter.resource_pool.memory.shares metric with initial data. @@ -3028,16 +4639,45 @@ func (m *metricVcenterResourcePoolMemoryShares) init() { m.data.SetEmptySum() m.data.Sum().SetIsMonotonic(false) m.data.Sum().SetAggregationTemporality(pmetric.AggregationTemporalityCumulative) + m.aggDataPoints = m.aggDataPoints[:0] } func (m *metricVcenterResourcePoolMemoryShares) recordDataPoint(start pcommon.Timestamp, ts pcommon.Timestamp, val int64) { if !m.config.Enabled { return } - dp := m.data.Sum().DataPoints().AppendEmpty() + + dp := pmetric.NewNumberDataPoint() dp.SetStartTimestamp(start) dp.SetTimestamp(ts) + + var s string + dps := m.data.Sum().DataPoints() + for i := 0; i < dps.Len(); i++ { + dpi := dps.At(i) + if dp.Attributes().Equal(dpi.Attributes()) && dp.StartTimestamp() == dpi.StartTimestamp() && dp.Timestamp() == dpi.Timestamp() { + switch s = m.config.AggregationStrategy; s { + case AggregationStrategySum, AggregationStrategyAvg: + dpi.SetIntValue(dpi.IntValue() + val) + m.aggDataPoints[i] += 1 + return + case AggregationStrategyMin: + if dpi.IntValue() > val { + dpi.SetIntValue(val) + } + return + case AggregationStrategyMax: + if dpi.IntValue() < val { + dpi.SetIntValue(val) + } + return + } + } + } + dp.SetIntValue(val) + m.aggDataPoints = append(m.aggDataPoints, 1) + dp.MoveTo(dps.AppendEmpty()) } // updateCapacity saves max length of data point slices that will be used for the slice capacity. @@ -3050,6 +4690,11 @@ func (m *metricVcenterResourcePoolMemoryShares) updateCapacity() { // emit appends recorded metric data to a metrics slice and prepares it for recording another set of data points. func (m *metricVcenterResourcePoolMemoryShares) emit(metrics pmetric.MetricSlice) { if m.config.Enabled && m.data.Sum().DataPoints().Len() > 0 { + if m.config.AggregationStrategy == AggregationStrategyAvg { + for i, aggCount := range m.aggDataPoints { + m.data.Sum().DataPoints().At(i).SetIntValue(m.data.Sum().DataPoints().At(i).IntValue() / aggCount) + } + } m.updateCapacity() m.data.MoveTo(metrics.AppendEmpty()) m.init() @@ -3067,9 +4712,10 @@ func newMetricVcenterResourcePoolMemoryShares(cfg MetricConfig) metricVcenterRes } type metricVcenterResourcePoolMemorySwapped struct { - data pmetric.Metric // data buffer for generated metric. - config MetricConfig // metric config provided by user. - capacity int // max observed number of data points added to the metric. + data pmetric.Metric // data buffer for generated metric. + config MetricConfig // metric config provided by user. + capacity int // max observed number of data points added to the metric. + aggDataPoints []int64 // slice containing number of aggregated datapoints at each index } // init fills vcenter.resource_pool.memory.swapped metric with initial data. @@ -3080,16 +4726,45 @@ func (m *metricVcenterResourcePoolMemorySwapped) init() { m.data.SetEmptySum() m.data.Sum().SetIsMonotonic(false) m.data.Sum().SetAggregationTemporality(pmetric.AggregationTemporalityCumulative) + m.aggDataPoints = m.aggDataPoints[:0] } func (m *metricVcenterResourcePoolMemorySwapped) recordDataPoint(start pcommon.Timestamp, ts pcommon.Timestamp, val int64) { if !m.config.Enabled { return } - dp := m.data.Sum().DataPoints().AppendEmpty() + + dp := pmetric.NewNumberDataPoint() dp.SetStartTimestamp(start) dp.SetTimestamp(ts) + + var s string + dps := m.data.Sum().DataPoints() + for i := 0; i < dps.Len(); i++ { + dpi := dps.At(i) + if dp.Attributes().Equal(dpi.Attributes()) && dp.StartTimestamp() == dpi.StartTimestamp() && dp.Timestamp() == dpi.Timestamp() { + switch s = m.config.AggregationStrategy; s { + case AggregationStrategySum, AggregationStrategyAvg: + dpi.SetIntValue(dpi.IntValue() + val) + m.aggDataPoints[i] += 1 + return + case AggregationStrategyMin: + if dpi.IntValue() > val { + dpi.SetIntValue(val) + } + return + case AggregationStrategyMax: + if dpi.IntValue() < val { + dpi.SetIntValue(val) + } + return + } + } + } + dp.SetIntValue(val) + m.aggDataPoints = append(m.aggDataPoints, 1) + dp.MoveTo(dps.AppendEmpty()) } // updateCapacity saves max length of data point slices that will be used for the slice capacity. @@ -3102,6 +4777,11 @@ func (m *metricVcenterResourcePoolMemorySwapped) updateCapacity() { // emit appends recorded metric data to a metrics slice and prepares it for recording another set of data points. func (m *metricVcenterResourcePoolMemorySwapped) emit(metrics pmetric.MetricSlice) { if m.config.Enabled && m.data.Sum().DataPoints().Len() > 0 { + if m.config.AggregationStrategy == AggregationStrategyAvg { + for i, aggCount := range m.aggDataPoints { + m.data.Sum().DataPoints().At(i).SetIntValue(m.data.Sum().DataPoints().At(i).IntValue() / aggCount) + } + } m.updateCapacity() m.data.MoveTo(metrics.AppendEmpty()) m.init() @@ -3119,9 +4799,10 @@ func newMetricVcenterResourcePoolMemorySwapped(cfg MetricConfig) metricVcenterRe } type metricVcenterResourcePoolMemoryUsage struct { - data pmetric.Metric // data buffer for generated metric. - config MetricConfig // metric config provided by user. - capacity int // max observed number of data points added to the metric. + data pmetric.Metric // data buffer for generated metric. + config MetricConfig // metric config provided by user. + capacity int // max observed number of data points added to the metric. + aggDataPoints []int64 // slice containing number of aggregated datapoints at each index } // init fills vcenter.resource_pool.memory.usage metric with initial data. @@ -3133,17 +4814,48 @@ func (m *metricVcenterResourcePoolMemoryUsage) init() { m.data.Sum().SetIsMonotonic(false) m.data.Sum().SetAggregationTemporality(pmetric.AggregationTemporalityCumulative) m.data.Sum().DataPoints().EnsureCapacity(m.capacity) + m.aggDataPoints = m.aggDataPoints[:0] } func (m *metricVcenterResourcePoolMemoryUsage) recordDataPoint(start pcommon.Timestamp, ts pcommon.Timestamp, val int64, memoryUsageTypeAttributeValue string) { if !m.config.Enabled { return } - dp := m.data.Sum().DataPoints().AppendEmpty() + + dp := pmetric.NewNumberDataPoint() dp.SetStartTimestamp(start) dp.SetTimestamp(ts) + if slices.Contains(m.config.EnabledAttributes, "type") { + dp.Attributes().PutStr("type", memoryUsageTypeAttributeValue) + } + + var s string + dps := m.data.Sum().DataPoints() + for i := 0; i < dps.Len(); i++ { + dpi := dps.At(i) + if dp.Attributes().Equal(dpi.Attributes()) && dp.StartTimestamp() == dpi.StartTimestamp() && dp.Timestamp() == dpi.Timestamp() { + switch s = m.config.AggregationStrategy; s { + case AggregationStrategySum, AggregationStrategyAvg: + dpi.SetIntValue(dpi.IntValue() + val) + m.aggDataPoints[i] += 1 + return + case AggregationStrategyMin: + if dpi.IntValue() > val { + dpi.SetIntValue(val) + } + return + case AggregationStrategyMax: + if dpi.IntValue() < val { + dpi.SetIntValue(val) + } + return + } + } + } + dp.SetIntValue(val) - dp.Attributes().PutStr("type", memoryUsageTypeAttributeValue) + m.aggDataPoints = append(m.aggDataPoints, 1) + dp.MoveTo(dps.AppendEmpty()) } // updateCapacity saves max length of data point slices that will be used for the slice capacity. @@ -3156,6 +4868,11 @@ func (m *metricVcenterResourcePoolMemoryUsage) updateCapacity() { // emit appends recorded metric data to a metrics slice and prepares it for recording another set of data points. func (m *metricVcenterResourcePoolMemoryUsage) emit(metrics pmetric.MetricSlice) { if m.config.Enabled && m.data.Sum().DataPoints().Len() > 0 { + if m.config.AggregationStrategy == AggregationStrategyAvg { + for i, aggCount := range m.aggDataPoints { + m.data.Sum().DataPoints().At(i).SetIntValue(m.data.Sum().DataPoints().At(i).IntValue() / aggCount) + } + } m.updateCapacity() m.data.MoveTo(metrics.AppendEmpty()) m.init() @@ -3173,9 +4890,10 @@ func newMetricVcenterResourcePoolMemoryUsage(cfg MetricConfig) metricVcenterReso } type metricVcenterVMCPUReadiness struct { - data pmetric.Metric // data buffer for generated metric. - config MetricConfig // metric config provided by user. - capacity int // max observed number of data points added to the metric. + data pmetric.Metric // data buffer for generated metric. + config MetricConfig // metric config provided by user. + capacity int // max observed number of data points added to the metric. + aggDataPoints []int64 // slice containing number of aggregated datapoints at each index } // init fills vcenter.vm.cpu.readiness metric with initial data. @@ -3184,16 +4902,45 @@ func (m *metricVcenterVMCPUReadiness) init() { m.data.SetDescription("Percentage of time that the virtual machine was ready, but could not get scheduled to run on the physical CPU.") m.data.SetUnit("%") m.data.SetEmptyGauge() + m.aggDataPoints = m.aggDataPoints[:0] } func (m *metricVcenterVMCPUReadiness) recordDataPoint(start pcommon.Timestamp, ts pcommon.Timestamp, val int64) { if !m.config.Enabled { return } - dp := m.data.Gauge().DataPoints().AppendEmpty() + + dp := pmetric.NewNumberDataPoint() dp.SetStartTimestamp(start) dp.SetTimestamp(ts) + + var s string + dps := m.data.Gauge().DataPoints() + for i := 0; i < dps.Len(); i++ { + dpi := dps.At(i) + if dp.Attributes().Equal(dpi.Attributes()) && dp.StartTimestamp() == dpi.StartTimestamp() && dp.Timestamp() == dpi.Timestamp() { + switch s = m.config.AggregationStrategy; s { + case AggregationStrategySum, AggregationStrategyAvg: + dpi.SetIntValue(dpi.IntValue() + val) + m.aggDataPoints[i] += 1 + return + case AggregationStrategyMin: + if dpi.IntValue() > val { + dpi.SetIntValue(val) + } + return + case AggregationStrategyMax: + if dpi.IntValue() < val { + dpi.SetIntValue(val) + } + return + } + } + } + dp.SetIntValue(val) + m.aggDataPoints = append(m.aggDataPoints, 1) + dp.MoveTo(dps.AppendEmpty()) } // updateCapacity saves max length of data point slices that will be used for the slice capacity. @@ -3206,6 +4953,11 @@ func (m *metricVcenterVMCPUReadiness) updateCapacity() { // emit appends recorded metric data to a metrics slice and prepares it for recording another set of data points. func (m *metricVcenterVMCPUReadiness) emit(metrics pmetric.MetricSlice) { if m.config.Enabled && m.data.Gauge().DataPoints().Len() > 0 { + if m.config.AggregationStrategy == AggregationStrategyAvg { + for i, aggCount := range m.aggDataPoints { + m.data.Gauge().DataPoints().At(i).SetIntValue(m.data.Gauge().DataPoints().At(i).IntValue() / aggCount) + } + } m.updateCapacity() m.data.MoveTo(metrics.AppendEmpty()) m.init() @@ -3223,9 +4975,10 @@ func newMetricVcenterVMCPUReadiness(cfg MetricConfig) metricVcenterVMCPUReadines } type metricVcenterVMCPUTime struct { - data pmetric.Metric // data buffer for generated metric. - config MetricConfig // metric config provided by user. - capacity int // max observed number of data points added to the metric. + data pmetric.Metric // data buffer for generated metric. + config MetricConfig // metric config provided by user. + capacity int // max observed number of data points added to the metric. + aggDataPoints []float64 // slice containing number of aggregated datapoints at each index } // init fills vcenter.vm.cpu.time metric with initial data. @@ -3235,18 +4988,51 @@ func (m *metricVcenterVMCPUTime) init() { m.data.SetUnit("%") m.data.SetEmptyGauge() m.data.Gauge().DataPoints().EnsureCapacity(m.capacity) + m.aggDataPoints = m.aggDataPoints[:0] } func (m *metricVcenterVMCPUTime) recordDataPoint(start pcommon.Timestamp, ts pcommon.Timestamp, val float64, cpuStateAttributeValue string, objectNameAttributeValue string) { if !m.config.Enabled { return } - dp := m.data.Gauge().DataPoints().AppendEmpty() + + dp := pmetric.NewNumberDataPoint() dp.SetStartTimestamp(start) dp.SetTimestamp(ts) + if slices.Contains(m.config.EnabledAttributes, "cpu_state") { + dp.Attributes().PutStr("cpu_state", cpuStateAttributeValue) + } + if slices.Contains(m.config.EnabledAttributes, "object") { + dp.Attributes().PutStr("object", objectNameAttributeValue) + } + + var s string + dps := m.data.Gauge().DataPoints() + for i := 0; i < dps.Len(); i++ { + dpi := dps.At(i) + if dp.Attributes().Equal(dpi.Attributes()) && dp.StartTimestamp() == dpi.StartTimestamp() && dp.Timestamp() == dpi.Timestamp() { + switch s = m.config.AggregationStrategy; s { + case AggregationStrategySum, AggregationStrategyAvg: + dpi.SetDoubleValue(dpi.DoubleValue() + val) + m.aggDataPoints[i] += 1 + return + case AggregationStrategyMin: + if dpi.DoubleValue() > val { + dpi.SetDoubleValue(val) + } + return + case AggregationStrategyMax: + if dpi.DoubleValue() < val { + dpi.SetDoubleValue(val) + } + return + } + } + } + dp.SetDoubleValue(val) - dp.Attributes().PutStr("cpu_state", cpuStateAttributeValue) - dp.Attributes().PutStr("object", objectNameAttributeValue) + m.aggDataPoints = append(m.aggDataPoints, 1) + dp.MoveTo(dps.AppendEmpty()) } // updateCapacity saves max length of data point slices that will be used for the slice capacity. @@ -3259,6 +5045,11 @@ func (m *metricVcenterVMCPUTime) updateCapacity() { // emit appends recorded metric data to a metrics slice and prepares it for recording another set of data points. func (m *metricVcenterVMCPUTime) emit(metrics pmetric.MetricSlice) { if m.config.Enabled && m.data.Gauge().DataPoints().Len() > 0 { + if m.config.AggregationStrategy == AggregationStrategyAvg { + for i, aggCount := range m.aggDataPoints { + m.data.Gauge().DataPoints().At(i).SetDoubleValue(m.data.Gauge().DataPoints().At(i).DoubleValue() / aggCount) + } + } m.updateCapacity() m.data.MoveTo(metrics.AppendEmpty()) m.init() @@ -3276,9 +5067,10 @@ func newMetricVcenterVMCPUTime(cfg MetricConfig) metricVcenterVMCPUTime { } type metricVcenterVMCPUUsage struct { - data pmetric.Metric // data buffer for generated metric. - config MetricConfig // metric config provided by user. - capacity int // max observed number of data points added to the metric. + data pmetric.Metric // data buffer for generated metric. + config MetricConfig // metric config provided by user. + capacity int // max observed number of data points added to the metric. + aggDataPoints []int64 // slice containing number of aggregated datapoints at each index } // init fills vcenter.vm.cpu.usage metric with initial data. @@ -3289,16 +5081,45 @@ func (m *metricVcenterVMCPUUsage) init() { m.data.SetEmptySum() m.data.Sum().SetIsMonotonic(false) m.data.Sum().SetAggregationTemporality(pmetric.AggregationTemporalityCumulative) + m.aggDataPoints = m.aggDataPoints[:0] } func (m *metricVcenterVMCPUUsage) recordDataPoint(start pcommon.Timestamp, ts pcommon.Timestamp, val int64) { if !m.config.Enabled { return } - dp := m.data.Sum().DataPoints().AppendEmpty() + + dp := pmetric.NewNumberDataPoint() dp.SetStartTimestamp(start) dp.SetTimestamp(ts) + + var s string + dps := m.data.Sum().DataPoints() + for i := 0; i < dps.Len(); i++ { + dpi := dps.At(i) + if dp.Attributes().Equal(dpi.Attributes()) && dp.StartTimestamp() == dpi.StartTimestamp() && dp.Timestamp() == dpi.Timestamp() { + switch s = m.config.AggregationStrategy; s { + case AggregationStrategySum, AggregationStrategyAvg: + dpi.SetIntValue(dpi.IntValue() + val) + m.aggDataPoints[i] += 1 + return + case AggregationStrategyMin: + if dpi.IntValue() > val { + dpi.SetIntValue(val) + } + return + case AggregationStrategyMax: + if dpi.IntValue() < val { + dpi.SetIntValue(val) + } + return + } + } + } + dp.SetIntValue(val) + m.aggDataPoints = append(m.aggDataPoints, 1) + dp.MoveTo(dps.AppendEmpty()) } // updateCapacity saves max length of data point slices that will be used for the slice capacity. @@ -3311,6 +5132,11 @@ func (m *metricVcenterVMCPUUsage) updateCapacity() { // emit appends recorded metric data to a metrics slice and prepares it for recording another set of data points. func (m *metricVcenterVMCPUUsage) emit(metrics pmetric.MetricSlice) { if m.config.Enabled && m.data.Sum().DataPoints().Len() > 0 { + if m.config.AggregationStrategy == AggregationStrategyAvg { + for i, aggCount := range m.aggDataPoints { + m.data.Sum().DataPoints().At(i).SetIntValue(m.data.Sum().DataPoints().At(i).IntValue() / aggCount) + } + } m.updateCapacity() m.data.MoveTo(metrics.AppendEmpty()) m.init() @@ -3328,9 +5154,10 @@ func newMetricVcenterVMCPUUsage(cfg MetricConfig) metricVcenterVMCPUUsage { } type metricVcenterVMCPUUtilization struct { - data pmetric.Metric // data buffer for generated metric. - config MetricConfig // metric config provided by user. - capacity int // max observed number of data points added to the metric. + data pmetric.Metric // data buffer for generated metric. + config MetricConfig // metric config provided by user. + capacity int // max observed number of data points added to the metric. + aggDataPoints []float64 // slice containing number of aggregated datapoints at each index } // init fills vcenter.vm.cpu.utilization metric with initial data. @@ -3339,16 +5166,45 @@ func (m *metricVcenterVMCPUUtilization) init() { m.data.SetDescription("The CPU utilization of the VM.") m.data.SetUnit("%") m.data.SetEmptyGauge() + m.aggDataPoints = m.aggDataPoints[:0] } func (m *metricVcenterVMCPUUtilization) recordDataPoint(start pcommon.Timestamp, ts pcommon.Timestamp, val float64) { if !m.config.Enabled { return } - dp := m.data.Gauge().DataPoints().AppendEmpty() + + dp := pmetric.NewNumberDataPoint() dp.SetStartTimestamp(start) dp.SetTimestamp(ts) + + var s string + dps := m.data.Gauge().DataPoints() + for i := 0; i < dps.Len(); i++ { + dpi := dps.At(i) + if dp.Attributes().Equal(dpi.Attributes()) && dp.StartTimestamp() == dpi.StartTimestamp() && dp.Timestamp() == dpi.Timestamp() { + switch s = m.config.AggregationStrategy; s { + case AggregationStrategySum, AggregationStrategyAvg: + dpi.SetDoubleValue(dpi.DoubleValue() + val) + m.aggDataPoints[i] += 1 + return + case AggregationStrategyMin: + if dpi.DoubleValue() > val { + dpi.SetDoubleValue(val) + } + return + case AggregationStrategyMax: + if dpi.DoubleValue() < val { + dpi.SetDoubleValue(val) + } + return + } + } + } + dp.SetDoubleValue(val) + m.aggDataPoints = append(m.aggDataPoints, 1) + dp.MoveTo(dps.AppendEmpty()) } // updateCapacity saves max length of data point slices that will be used for the slice capacity. @@ -3361,6 +5217,11 @@ func (m *metricVcenterVMCPUUtilization) updateCapacity() { // emit appends recorded metric data to a metrics slice and prepares it for recording another set of data points. func (m *metricVcenterVMCPUUtilization) emit(metrics pmetric.MetricSlice) { if m.config.Enabled && m.data.Gauge().DataPoints().Len() > 0 { + if m.config.AggregationStrategy == AggregationStrategyAvg { + for i, aggCount := range m.aggDataPoints { + m.data.Gauge().DataPoints().At(i).SetDoubleValue(m.data.Gauge().DataPoints().At(i).DoubleValue() / aggCount) + } + } m.updateCapacity() m.data.MoveTo(metrics.AppendEmpty()) m.init() @@ -3378,9 +5239,10 @@ func newMetricVcenterVMCPUUtilization(cfg MetricConfig) metricVcenterVMCPUUtiliz } type metricVcenterVMDiskLatencyAvg struct { - data pmetric.Metric // data buffer for generated metric. - config MetricConfig // metric config provided by user. - capacity int // max observed number of data points added to the metric. + data pmetric.Metric // data buffer for generated metric. + config MetricConfig // metric config provided by user. + capacity int // max observed number of data points added to the metric. + aggDataPoints []int64 // slice containing number of aggregated datapoints at each index } // init fills vcenter.vm.disk.latency.avg metric with initial data. @@ -3390,19 +5252,54 @@ func (m *metricVcenterVMDiskLatencyAvg) init() { m.data.SetUnit("ms") m.data.SetEmptyGauge() m.data.Gauge().DataPoints().EnsureCapacity(m.capacity) + m.aggDataPoints = m.aggDataPoints[:0] } func (m *metricVcenterVMDiskLatencyAvg) recordDataPoint(start pcommon.Timestamp, ts pcommon.Timestamp, val int64, diskDirectionAttributeValue string, diskTypeAttributeValue string, objectNameAttributeValue string) { if !m.config.Enabled { return } - dp := m.data.Gauge().DataPoints().AppendEmpty() + + dp := pmetric.NewNumberDataPoint() dp.SetStartTimestamp(start) dp.SetTimestamp(ts) + if slices.Contains(m.config.EnabledAttributes, "direction") { + dp.Attributes().PutStr("direction", diskDirectionAttributeValue) + } + if slices.Contains(m.config.EnabledAttributes, "disk_type") { + dp.Attributes().PutStr("disk_type", diskTypeAttributeValue) + } + if slices.Contains(m.config.EnabledAttributes, "object") { + dp.Attributes().PutStr("object", objectNameAttributeValue) + } + + var s string + dps := m.data.Gauge().DataPoints() + for i := 0; i < dps.Len(); i++ { + dpi := dps.At(i) + if dp.Attributes().Equal(dpi.Attributes()) && dp.StartTimestamp() == dpi.StartTimestamp() && dp.Timestamp() == dpi.Timestamp() { + switch s = m.config.AggregationStrategy; s { + case AggregationStrategySum, AggregationStrategyAvg: + dpi.SetIntValue(dpi.IntValue() + val) + m.aggDataPoints[i] += 1 + return + case AggregationStrategyMin: + if dpi.IntValue() > val { + dpi.SetIntValue(val) + } + return + case AggregationStrategyMax: + if dpi.IntValue() < val { + dpi.SetIntValue(val) + } + return + } + } + } + dp.SetIntValue(val) - dp.Attributes().PutStr("direction", diskDirectionAttributeValue) - dp.Attributes().PutStr("disk_type", diskTypeAttributeValue) - dp.Attributes().PutStr("object", objectNameAttributeValue) + m.aggDataPoints = append(m.aggDataPoints, 1) + dp.MoveTo(dps.AppendEmpty()) } // updateCapacity saves max length of data point slices that will be used for the slice capacity. @@ -3415,6 +5312,11 @@ func (m *metricVcenterVMDiskLatencyAvg) updateCapacity() { // emit appends recorded metric data to a metrics slice and prepares it for recording another set of data points. func (m *metricVcenterVMDiskLatencyAvg) emit(metrics pmetric.MetricSlice) { if m.config.Enabled && m.data.Gauge().DataPoints().Len() > 0 { + if m.config.AggregationStrategy == AggregationStrategyAvg { + for i, aggCount := range m.aggDataPoints { + m.data.Gauge().DataPoints().At(i).SetIntValue(m.data.Gauge().DataPoints().At(i).IntValue() / aggCount) + } + } m.updateCapacity() m.data.MoveTo(metrics.AppendEmpty()) m.init() @@ -3432,9 +5334,10 @@ func newMetricVcenterVMDiskLatencyAvg(cfg MetricConfig) metricVcenterVMDiskLaten } type metricVcenterVMDiskLatencyMax struct { - data pmetric.Metric // data buffer for generated metric. - config MetricConfig // metric config provided by user. - capacity int // max observed number of data points added to the metric. + data pmetric.Metric // data buffer for generated metric. + config MetricConfig // metric config provided by user. + capacity int // max observed number of data points added to the metric. + aggDataPoints []int64 // slice containing number of aggregated datapoints at each index } // init fills vcenter.vm.disk.latency.max metric with initial data. @@ -3444,17 +5347,48 @@ func (m *metricVcenterVMDiskLatencyMax) init() { m.data.SetUnit("ms") m.data.SetEmptyGauge() m.data.Gauge().DataPoints().EnsureCapacity(m.capacity) + m.aggDataPoints = m.aggDataPoints[:0] } func (m *metricVcenterVMDiskLatencyMax) recordDataPoint(start pcommon.Timestamp, ts pcommon.Timestamp, val int64, objectNameAttributeValue string) { if !m.config.Enabled { return } - dp := m.data.Gauge().DataPoints().AppendEmpty() + + dp := pmetric.NewNumberDataPoint() dp.SetStartTimestamp(start) dp.SetTimestamp(ts) + if slices.Contains(m.config.EnabledAttributes, "object") { + dp.Attributes().PutStr("object", objectNameAttributeValue) + } + + var s string + dps := m.data.Gauge().DataPoints() + for i := 0; i < dps.Len(); i++ { + dpi := dps.At(i) + if dp.Attributes().Equal(dpi.Attributes()) && dp.StartTimestamp() == dpi.StartTimestamp() && dp.Timestamp() == dpi.Timestamp() { + switch s = m.config.AggregationStrategy; s { + case AggregationStrategySum, AggregationStrategyAvg: + dpi.SetIntValue(dpi.IntValue() + val) + m.aggDataPoints[i] += 1 + return + case AggregationStrategyMin: + if dpi.IntValue() > val { + dpi.SetIntValue(val) + } + return + case AggregationStrategyMax: + if dpi.IntValue() < val { + dpi.SetIntValue(val) + } + return + } + } + } + dp.SetIntValue(val) - dp.Attributes().PutStr("object", objectNameAttributeValue) + m.aggDataPoints = append(m.aggDataPoints, 1) + dp.MoveTo(dps.AppendEmpty()) } // updateCapacity saves max length of data point slices that will be used for the slice capacity. @@ -3467,6 +5401,11 @@ func (m *metricVcenterVMDiskLatencyMax) updateCapacity() { // emit appends recorded metric data to a metrics slice and prepares it for recording another set of data points. func (m *metricVcenterVMDiskLatencyMax) emit(metrics pmetric.MetricSlice) { if m.config.Enabled && m.data.Gauge().DataPoints().Len() > 0 { + if m.config.AggregationStrategy == AggregationStrategyAvg { + for i, aggCount := range m.aggDataPoints { + m.data.Gauge().DataPoints().At(i).SetIntValue(m.data.Gauge().DataPoints().At(i).IntValue() / aggCount) + } + } m.updateCapacity() m.data.MoveTo(metrics.AppendEmpty()) m.init() @@ -3484,9 +5423,10 @@ func newMetricVcenterVMDiskLatencyMax(cfg MetricConfig) metricVcenterVMDiskLaten } type metricVcenterVMDiskThroughput struct { - data pmetric.Metric // data buffer for generated metric. - config MetricConfig // metric config provided by user. - capacity int // max observed number of data points added to the metric. + data pmetric.Metric // data buffer for generated metric. + config MetricConfig // metric config provided by user. + capacity int // max observed number of data points added to the metric. + aggDataPoints []int64 // slice containing number of aggregated datapoints at each index } // init fills vcenter.vm.disk.throughput metric with initial data. @@ -3496,18 +5436,51 @@ func (m *metricVcenterVMDiskThroughput) init() { m.data.SetUnit("{KiBy/s}") m.data.SetEmptyGauge() m.data.Gauge().DataPoints().EnsureCapacity(m.capacity) + m.aggDataPoints = m.aggDataPoints[:0] } func (m *metricVcenterVMDiskThroughput) recordDataPoint(start pcommon.Timestamp, ts pcommon.Timestamp, val int64, diskDirectionAttributeValue string, objectNameAttributeValue string) { if !m.config.Enabled { return } - dp := m.data.Gauge().DataPoints().AppendEmpty() + + dp := pmetric.NewNumberDataPoint() dp.SetStartTimestamp(start) dp.SetTimestamp(ts) + if slices.Contains(m.config.EnabledAttributes, "direction") { + dp.Attributes().PutStr("direction", diskDirectionAttributeValue) + } + if slices.Contains(m.config.EnabledAttributes, "object") { + dp.Attributes().PutStr("object", objectNameAttributeValue) + } + + var s string + dps := m.data.Gauge().DataPoints() + for i := 0; i < dps.Len(); i++ { + dpi := dps.At(i) + if dp.Attributes().Equal(dpi.Attributes()) && dp.StartTimestamp() == dpi.StartTimestamp() && dp.Timestamp() == dpi.Timestamp() { + switch s = m.config.AggregationStrategy; s { + case AggregationStrategySum, AggregationStrategyAvg: + dpi.SetIntValue(dpi.IntValue() + val) + m.aggDataPoints[i] += 1 + return + case AggregationStrategyMin: + if dpi.IntValue() > val { + dpi.SetIntValue(val) + } + return + case AggregationStrategyMax: + if dpi.IntValue() < val { + dpi.SetIntValue(val) + } + return + } + } + } + dp.SetIntValue(val) - dp.Attributes().PutStr("direction", diskDirectionAttributeValue) - dp.Attributes().PutStr("object", objectNameAttributeValue) + m.aggDataPoints = append(m.aggDataPoints, 1) + dp.MoveTo(dps.AppendEmpty()) } // updateCapacity saves max length of data point slices that will be used for the slice capacity. @@ -3520,6 +5493,11 @@ func (m *metricVcenterVMDiskThroughput) updateCapacity() { // emit appends recorded metric data to a metrics slice and prepares it for recording another set of data points. func (m *metricVcenterVMDiskThroughput) emit(metrics pmetric.MetricSlice) { if m.config.Enabled && m.data.Gauge().DataPoints().Len() > 0 { + if m.config.AggregationStrategy == AggregationStrategyAvg { + for i, aggCount := range m.aggDataPoints { + m.data.Gauge().DataPoints().At(i).SetIntValue(m.data.Gauge().DataPoints().At(i).IntValue() / aggCount) + } + } m.updateCapacity() m.data.MoveTo(metrics.AppendEmpty()) m.init() @@ -3537,9 +5515,10 @@ func newMetricVcenterVMDiskThroughput(cfg MetricConfig) metricVcenterVMDiskThrou } type metricVcenterVMDiskUsage struct { - data pmetric.Metric // data buffer for generated metric. - config MetricConfig // metric config provided by user. - capacity int // max observed number of data points added to the metric. + data pmetric.Metric // data buffer for generated metric. + config MetricConfig // metric config provided by user. + capacity int // max observed number of data points added to the metric. + aggDataPoints []int64 // slice containing number of aggregated datapoints at each index } // init fills vcenter.vm.disk.usage metric with initial data. @@ -3551,17 +5530,48 @@ func (m *metricVcenterVMDiskUsage) init() { m.data.Sum().SetIsMonotonic(false) m.data.Sum().SetAggregationTemporality(pmetric.AggregationTemporalityCumulative) m.data.Sum().DataPoints().EnsureCapacity(m.capacity) + m.aggDataPoints = m.aggDataPoints[:0] } func (m *metricVcenterVMDiskUsage) recordDataPoint(start pcommon.Timestamp, ts pcommon.Timestamp, val int64, diskStateAttributeValue string) { if !m.config.Enabled { return } - dp := m.data.Sum().DataPoints().AppendEmpty() + + dp := pmetric.NewNumberDataPoint() dp.SetStartTimestamp(start) dp.SetTimestamp(ts) + if slices.Contains(m.config.EnabledAttributes, "disk_state") { + dp.Attributes().PutStr("disk_state", diskStateAttributeValue) + } + + var s string + dps := m.data.Sum().DataPoints() + for i := 0; i < dps.Len(); i++ { + dpi := dps.At(i) + if dp.Attributes().Equal(dpi.Attributes()) && dp.StartTimestamp() == dpi.StartTimestamp() && dp.Timestamp() == dpi.Timestamp() { + switch s = m.config.AggregationStrategy; s { + case AggregationStrategySum, AggregationStrategyAvg: + dpi.SetIntValue(dpi.IntValue() + val) + m.aggDataPoints[i] += 1 + return + case AggregationStrategyMin: + if dpi.IntValue() > val { + dpi.SetIntValue(val) + } + return + case AggregationStrategyMax: + if dpi.IntValue() < val { + dpi.SetIntValue(val) + } + return + } + } + } + dp.SetIntValue(val) - dp.Attributes().PutStr("disk_state", diskStateAttributeValue) + m.aggDataPoints = append(m.aggDataPoints, 1) + dp.MoveTo(dps.AppendEmpty()) } // updateCapacity saves max length of data point slices that will be used for the slice capacity. @@ -3574,6 +5584,11 @@ func (m *metricVcenterVMDiskUsage) updateCapacity() { // emit appends recorded metric data to a metrics slice and prepares it for recording another set of data points. func (m *metricVcenterVMDiskUsage) emit(metrics pmetric.MetricSlice) { if m.config.Enabled && m.data.Sum().DataPoints().Len() > 0 { + if m.config.AggregationStrategy == AggregationStrategyAvg { + for i, aggCount := range m.aggDataPoints { + m.data.Sum().DataPoints().At(i).SetIntValue(m.data.Sum().DataPoints().At(i).IntValue() / aggCount) + } + } m.updateCapacity() m.data.MoveTo(metrics.AppendEmpty()) m.init() @@ -3591,9 +5606,10 @@ func newMetricVcenterVMDiskUsage(cfg MetricConfig) metricVcenterVMDiskUsage { } type metricVcenterVMDiskUtilization struct { - data pmetric.Metric // data buffer for generated metric. - config MetricConfig // metric config provided by user. - capacity int // max observed number of data points added to the metric. + data pmetric.Metric // data buffer for generated metric. + config MetricConfig // metric config provided by user. + capacity int // max observed number of data points added to the metric. + aggDataPoints []float64 // slice containing number of aggregated datapoints at each index } // init fills vcenter.vm.disk.utilization metric with initial data. @@ -3602,16 +5618,45 @@ func (m *metricVcenterVMDiskUtilization) init() { m.data.SetDescription("The utilization of storage on the virtual machine.") m.data.SetUnit("%") m.data.SetEmptyGauge() + m.aggDataPoints = m.aggDataPoints[:0] } func (m *metricVcenterVMDiskUtilization) recordDataPoint(start pcommon.Timestamp, ts pcommon.Timestamp, val float64) { if !m.config.Enabled { return } - dp := m.data.Gauge().DataPoints().AppendEmpty() + + dp := pmetric.NewNumberDataPoint() dp.SetStartTimestamp(start) dp.SetTimestamp(ts) + + var s string + dps := m.data.Gauge().DataPoints() + for i := 0; i < dps.Len(); i++ { + dpi := dps.At(i) + if dp.Attributes().Equal(dpi.Attributes()) && dp.StartTimestamp() == dpi.StartTimestamp() && dp.Timestamp() == dpi.Timestamp() { + switch s = m.config.AggregationStrategy; s { + case AggregationStrategySum, AggregationStrategyAvg: + dpi.SetDoubleValue(dpi.DoubleValue() + val) + m.aggDataPoints[i] += 1 + return + case AggregationStrategyMin: + if dpi.DoubleValue() > val { + dpi.SetDoubleValue(val) + } + return + case AggregationStrategyMax: + if dpi.DoubleValue() < val { + dpi.SetDoubleValue(val) + } + return + } + } + } + dp.SetDoubleValue(val) + m.aggDataPoints = append(m.aggDataPoints, 1) + dp.MoveTo(dps.AppendEmpty()) } // updateCapacity saves max length of data point slices that will be used for the slice capacity. @@ -3624,6 +5669,11 @@ func (m *metricVcenterVMDiskUtilization) updateCapacity() { // emit appends recorded metric data to a metrics slice and prepares it for recording another set of data points. func (m *metricVcenterVMDiskUtilization) emit(metrics pmetric.MetricSlice) { if m.config.Enabled && m.data.Gauge().DataPoints().Len() > 0 { + if m.config.AggregationStrategy == AggregationStrategyAvg { + for i, aggCount := range m.aggDataPoints { + m.data.Gauge().DataPoints().At(i).SetDoubleValue(m.data.Gauge().DataPoints().At(i).DoubleValue() / aggCount) + } + } m.updateCapacity() m.data.MoveTo(metrics.AppendEmpty()) m.init() @@ -3641,9 +5691,10 @@ func newMetricVcenterVMDiskUtilization(cfg MetricConfig) metricVcenterVMDiskUtil } type metricVcenterVMMemoryBallooned struct { - data pmetric.Metric // data buffer for generated metric. - config MetricConfig // metric config provided by user. - capacity int // max observed number of data points added to the metric. + data pmetric.Metric // data buffer for generated metric. + config MetricConfig // metric config provided by user. + capacity int // max observed number of data points added to the metric. + aggDataPoints []int64 // slice containing number of aggregated datapoints at each index } // init fills vcenter.vm.memory.ballooned metric with initial data. @@ -3654,16 +5705,45 @@ func (m *metricVcenterVMMemoryBallooned) init() { m.data.SetEmptySum() m.data.Sum().SetIsMonotonic(false) m.data.Sum().SetAggregationTemporality(pmetric.AggregationTemporalityCumulative) + m.aggDataPoints = m.aggDataPoints[:0] } func (m *metricVcenterVMMemoryBallooned) recordDataPoint(start pcommon.Timestamp, ts pcommon.Timestamp, val int64) { if !m.config.Enabled { return } - dp := m.data.Sum().DataPoints().AppendEmpty() + + dp := pmetric.NewNumberDataPoint() dp.SetStartTimestamp(start) dp.SetTimestamp(ts) + + var s string + dps := m.data.Sum().DataPoints() + for i := 0; i < dps.Len(); i++ { + dpi := dps.At(i) + if dp.Attributes().Equal(dpi.Attributes()) && dp.StartTimestamp() == dpi.StartTimestamp() && dp.Timestamp() == dpi.Timestamp() { + switch s = m.config.AggregationStrategy; s { + case AggregationStrategySum, AggregationStrategyAvg: + dpi.SetIntValue(dpi.IntValue() + val) + m.aggDataPoints[i] += 1 + return + case AggregationStrategyMin: + if dpi.IntValue() > val { + dpi.SetIntValue(val) + } + return + case AggregationStrategyMax: + if dpi.IntValue() < val { + dpi.SetIntValue(val) + } + return + } + } + } + dp.SetIntValue(val) + m.aggDataPoints = append(m.aggDataPoints, 1) + dp.MoveTo(dps.AppendEmpty()) } // updateCapacity saves max length of data point slices that will be used for the slice capacity. @@ -3676,6 +5756,11 @@ func (m *metricVcenterVMMemoryBallooned) updateCapacity() { // emit appends recorded metric data to a metrics slice and prepares it for recording another set of data points. func (m *metricVcenterVMMemoryBallooned) emit(metrics pmetric.MetricSlice) { if m.config.Enabled && m.data.Sum().DataPoints().Len() > 0 { + if m.config.AggregationStrategy == AggregationStrategyAvg { + for i, aggCount := range m.aggDataPoints { + m.data.Sum().DataPoints().At(i).SetIntValue(m.data.Sum().DataPoints().At(i).IntValue() / aggCount) + } + } m.updateCapacity() m.data.MoveTo(metrics.AppendEmpty()) m.init() @@ -3693,9 +5778,10 @@ func newMetricVcenterVMMemoryBallooned(cfg MetricConfig) metricVcenterVMMemoryBa } type metricVcenterVMMemoryGranted struct { - data pmetric.Metric // data buffer for generated metric. - config MetricConfig // metric config provided by user. - capacity int // max observed number of data points added to the metric. + data pmetric.Metric // data buffer for generated metric. + config MetricConfig // metric config provided by user. + capacity int // max observed number of data points added to the metric. + aggDataPoints []int64 // slice containing number of aggregated datapoints at each index } // init fills vcenter.vm.memory.granted metric with initial data. @@ -3706,16 +5792,45 @@ func (m *metricVcenterVMMemoryGranted) init() { m.data.SetEmptySum() m.data.Sum().SetIsMonotonic(false) m.data.Sum().SetAggregationTemporality(pmetric.AggregationTemporalityCumulative) + m.aggDataPoints = m.aggDataPoints[:0] } func (m *metricVcenterVMMemoryGranted) recordDataPoint(start pcommon.Timestamp, ts pcommon.Timestamp, val int64) { if !m.config.Enabled { return } - dp := m.data.Sum().DataPoints().AppendEmpty() + + dp := pmetric.NewNumberDataPoint() dp.SetStartTimestamp(start) dp.SetTimestamp(ts) + + var s string + dps := m.data.Sum().DataPoints() + for i := 0; i < dps.Len(); i++ { + dpi := dps.At(i) + if dp.Attributes().Equal(dpi.Attributes()) && dp.StartTimestamp() == dpi.StartTimestamp() && dp.Timestamp() == dpi.Timestamp() { + switch s = m.config.AggregationStrategy; s { + case AggregationStrategySum, AggregationStrategyAvg: + dpi.SetIntValue(dpi.IntValue() + val) + m.aggDataPoints[i] += 1 + return + case AggregationStrategyMin: + if dpi.IntValue() > val { + dpi.SetIntValue(val) + } + return + case AggregationStrategyMax: + if dpi.IntValue() < val { + dpi.SetIntValue(val) + } + return + } + } + } + dp.SetIntValue(val) + m.aggDataPoints = append(m.aggDataPoints, 1) + dp.MoveTo(dps.AppendEmpty()) } // updateCapacity saves max length of data point slices that will be used for the slice capacity. @@ -3728,6 +5843,11 @@ func (m *metricVcenterVMMemoryGranted) updateCapacity() { // emit appends recorded metric data to a metrics slice and prepares it for recording another set of data points. func (m *metricVcenterVMMemoryGranted) emit(metrics pmetric.MetricSlice) { if m.config.Enabled && m.data.Sum().DataPoints().Len() > 0 { + if m.config.AggregationStrategy == AggregationStrategyAvg { + for i, aggCount := range m.aggDataPoints { + m.data.Sum().DataPoints().At(i).SetIntValue(m.data.Sum().DataPoints().At(i).IntValue() / aggCount) + } + } m.updateCapacity() m.data.MoveTo(metrics.AppendEmpty()) m.init() @@ -3745,9 +5865,10 @@ func newMetricVcenterVMMemoryGranted(cfg MetricConfig) metricVcenterVMMemoryGran } type metricVcenterVMMemorySwapped struct { - data pmetric.Metric // data buffer for generated metric. - config MetricConfig // metric config provided by user. - capacity int // max observed number of data points added to the metric. + data pmetric.Metric // data buffer for generated metric. + config MetricConfig // metric config provided by user. + capacity int // max observed number of data points added to the metric. + aggDataPoints []int64 // slice containing number of aggregated datapoints at each index } // init fills vcenter.vm.memory.swapped metric with initial data. @@ -3758,16 +5879,45 @@ func (m *metricVcenterVMMemorySwapped) init() { m.data.SetEmptySum() m.data.Sum().SetIsMonotonic(false) m.data.Sum().SetAggregationTemporality(pmetric.AggregationTemporalityCumulative) + m.aggDataPoints = m.aggDataPoints[:0] } func (m *metricVcenterVMMemorySwapped) recordDataPoint(start pcommon.Timestamp, ts pcommon.Timestamp, val int64) { if !m.config.Enabled { return } - dp := m.data.Sum().DataPoints().AppendEmpty() + + dp := pmetric.NewNumberDataPoint() dp.SetStartTimestamp(start) dp.SetTimestamp(ts) + + var s string + dps := m.data.Sum().DataPoints() + for i := 0; i < dps.Len(); i++ { + dpi := dps.At(i) + if dp.Attributes().Equal(dpi.Attributes()) && dp.StartTimestamp() == dpi.StartTimestamp() && dp.Timestamp() == dpi.Timestamp() { + switch s = m.config.AggregationStrategy; s { + case AggregationStrategySum, AggregationStrategyAvg: + dpi.SetIntValue(dpi.IntValue() + val) + m.aggDataPoints[i] += 1 + return + case AggregationStrategyMin: + if dpi.IntValue() > val { + dpi.SetIntValue(val) + } + return + case AggregationStrategyMax: + if dpi.IntValue() < val { + dpi.SetIntValue(val) + } + return + } + } + } + dp.SetIntValue(val) + m.aggDataPoints = append(m.aggDataPoints, 1) + dp.MoveTo(dps.AppendEmpty()) } // updateCapacity saves max length of data point slices that will be used for the slice capacity. @@ -3780,6 +5930,11 @@ func (m *metricVcenterVMMemorySwapped) updateCapacity() { // emit appends recorded metric data to a metrics slice and prepares it for recording another set of data points. func (m *metricVcenterVMMemorySwapped) emit(metrics pmetric.MetricSlice) { if m.config.Enabled && m.data.Sum().DataPoints().Len() > 0 { + if m.config.AggregationStrategy == AggregationStrategyAvg { + for i, aggCount := range m.aggDataPoints { + m.data.Sum().DataPoints().At(i).SetIntValue(m.data.Sum().DataPoints().At(i).IntValue() / aggCount) + } + } m.updateCapacity() m.data.MoveTo(metrics.AppendEmpty()) m.init() @@ -3797,9 +5952,10 @@ func newMetricVcenterVMMemorySwapped(cfg MetricConfig) metricVcenterVMMemorySwap } type metricVcenterVMMemorySwappedSsd struct { - data pmetric.Metric // data buffer for generated metric. - config MetricConfig // metric config provided by user. - capacity int // max observed number of data points added to the metric. + data pmetric.Metric // data buffer for generated metric. + config MetricConfig // metric config provided by user. + capacity int // max observed number of data points added to the metric. + aggDataPoints []int64 // slice containing number of aggregated datapoints at each index } // init fills vcenter.vm.memory.swapped_ssd metric with initial data. @@ -3810,16 +5966,45 @@ func (m *metricVcenterVMMemorySwappedSsd) init() { m.data.SetEmptySum() m.data.Sum().SetIsMonotonic(false) m.data.Sum().SetAggregationTemporality(pmetric.AggregationTemporalityCumulative) + m.aggDataPoints = m.aggDataPoints[:0] } func (m *metricVcenterVMMemorySwappedSsd) recordDataPoint(start pcommon.Timestamp, ts pcommon.Timestamp, val int64) { if !m.config.Enabled { return } - dp := m.data.Sum().DataPoints().AppendEmpty() + + dp := pmetric.NewNumberDataPoint() dp.SetStartTimestamp(start) dp.SetTimestamp(ts) + + var s string + dps := m.data.Sum().DataPoints() + for i := 0; i < dps.Len(); i++ { + dpi := dps.At(i) + if dp.Attributes().Equal(dpi.Attributes()) && dp.StartTimestamp() == dpi.StartTimestamp() && dp.Timestamp() == dpi.Timestamp() { + switch s = m.config.AggregationStrategy; s { + case AggregationStrategySum, AggregationStrategyAvg: + dpi.SetIntValue(dpi.IntValue() + val) + m.aggDataPoints[i] += 1 + return + case AggregationStrategyMin: + if dpi.IntValue() > val { + dpi.SetIntValue(val) + } + return + case AggregationStrategyMax: + if dpi.IntValue() < val { + dpi.SetIntValue(val) + } + return + } + } + } + dp.SetIntValue(val) + m.aggDataPoints = append(m.aggDataPoints, 1) + dp.MoveTo(dps.AppendEmpty()) } // updateCapacity saves max length of data point slices that will be used for the slice capacity. @@ -3832,6 +6017,11 @@ func (m *metricVcenterVMMemorySwappedSsd) updateCapacity() { // emit appends recorded metric data to a metrics slice and prepares it for recording another set of data points. func (m *metricVcenterVMMemorySwappedSsd) emit(metrics pmetric.MetricSlice) { if m.config.Enabled && m.data.Sum().DataPoints().Len() > 0 { + if m.config.AggregationStrategy == AggregationStrategyAvg { + for i, aggCount := range m.aggDataPoints { + m.data.Sum().DataPoints().At(i).SetIntValue(m.data.Sum().DataPoints().At(i).IntValue() / aggCount) + } + } m.updateCapacity() m.data.MoveTo(metrics.AppendEmpty()) m.init() @@ -3849,9 +6039,10 @@ func newMetricVcenterVMMemorySwappedSsd(cfg MetricConfig) metricVcenterVMMemoryS } type metricVcenterVMMemoryUsage struct { - data pmetric.Metric // data buffer for generated metric. - config MetricConfig // metric config provided by user. - capacity int // max observed number of data points added to the metric. + data pmetric.Metric // data buffer for generated metric. + config MetricConfig // metric config provided by user. + capacity int // max observed number of data points added to the metric. + aggDataPoints []int64 // slice containing number of aggregated datapoints at each index } // init fills vcenter.vm.memory.usage metric with initial data. @@ -3862,16 +6053,45 @@ func (m *metricVcenterVMMemoryUsage) init() { m.data.SetEmptySum() m.data.Sum().SetIsMonotonic(false) m.data.Sum().SetAggregationTemporality(pmetric.AggregationTemporalityCumulative) + m.aggDataPoints = m.aggDataPoints[:0] } func (m *metricVcenterVMMemoryUsage) recordDataPoint(start pcommon.Timestamp, ts pcommon.Timestamp, val int64) { if !m.config.Enabled { return } - dp := m.data.Sum().DataPoints().AppendEmpty() + + dp := pmetric.NewNumberDataPoint() dp.SetStartTimestamp(start) dp.SetTimestamp(ts) + + var s string + dps := m.data.Sum().DataPoints() + for i := 0; i < dps.Len(); i++ { + dpi := dps.At(i) + if dp.Attributes().Equal(dpi.Attributes()) && dp.StartTimestamp() == dpi.StartTimestamp() && dp.Timestamp() == dpi.Timestamp() { + switch s = m.config.AggregationStrategy; s { + case AggregationStrategySum, AggregationStrategyAvg: + dpi.SetIntValue(dpi.IntValue() + val) + m.aggDataPoints[i] += 1 + return + case AggregationStrategyMin: + if dpi.IntValue() > val { + dpi.SetIntValue(val) + } + return + case AggregationStrategyMax: + if dpi.IntValue() < val { + dpi.SetIntValue(val) + } + return + } + } + } + dp.SetIntValue(val) + m.aggDataPoints = append(m.aggDataPoints, 1) + dp.MoveTo(dps.AppendEmpty()) } // updateCapacity saves max length of data point slices that will be used for the slice capacity. @@ -3884,6 +6104,11 @@ func (m *metricVcenterVMMemoryUsage) updateCapacity() { // emit appends recorded metric data to a metrics slice and prepares it for recording another set of data points. func (m *metricVcenterVMMemoryUsage) emit(metrics pmetric.MetricSlice) { if m.config.Enabled && m.data.Sum().DataPoints().Len() > 0 { + if m.config.AggregationStrategy == AggregationStrategyAvg { + for i, aggCount := range m.aggDataPoints { + m.data.Sum().DataPoints().At(i).SetIntValue(m.data.Sum().DataPoints().At(i).IntValue() / aggCount) + } + } m.updateCapacity() m.data.MoveTo(metrics.AppendEmpty()) m.init() @@ -3901,9 +6126,10 @@ func newMetricVcenterVMMemoryUsage(cfg MetricConfig) metricVcenterVMMemoryUsage } type metricVcenterVMMemoryUtilization struct { - data pmetric.Metric // data buffer for generated metric. - config MetricConfig // metric config provided by user. - capacity int // max observed number of data points added to the metric. + data pmetric.Metric // data buffer for generated metric. + config MetricConfig // metric config provided by user. + capacity int // max observed number of data points added to the metric. + aggDataPoints []float64 // slice containing number of aggregated datapoints at each index } // init fills vcenter.vm.memory.utilization metric with initial data. @@ -3912,16 +6138,45 @@ func (m *metricVcenterVMMemoryUtilization) init() { m.data.SetDescription("The memory utilization of the VM.") m.data.SetUnit("%") m.data.SetEmptyGauge() + m.aggDataPoints = m.aggDataPoints[:0] } func (m *metricVcenterVMMemoryUtilization) recordDataPoint(start pcommon.Timestamp, ts pcommon.Timestamp, val float64) { if !m.config.Enabled { return } - dp := m.data.Gauge().DataPoints().AppendEmpty() + + dp := pmetric.NewNumberDataPoint() dp.SetStartTimestamp(start) dp.SetTimestamp(ts) + + var s string + dps := m.data.Gauge().DataPoints() + for i := 0; i < dps.Len(); i++ { + dpi := dps.At(i) + if dp.Attributes().Equal(dpi.Attributes()) && dp.StartTimestamp() == dpi.StartTimestamp() && dp.Timestamp() == dpi.Timestamp() { + switch s = m.config.AggregationStrategy; s { + case AggregationStrategySum, AggregationStrategyAvg: + dpi.SetDoubleValue(dpi.DoubleValue() + val) + m.aggDataPoints[i] += 1 + return + case AggregationStrategyMin: + if dpi.DoubleValue() > val { + dpi.SetDoubleValue(val) + } + return + case AggregationStrategyMax: + if dpi.DoubleValue() < val { + dpi.SetDoubleValue(val) + } + return + } + } + } + dp.SetDoubleValue(val) + m.aggDataPoints = append(m.aggDataPoints, 1) + dp.MoveTo(dps.AppendEmpty()) } // updateCapacity saves max length of data point slices that will be used for the slice capacity. @@ -3934,6 +6189,11 @@ func (m *metricVcenterVMMemoryUtilization) updateCapacity() { // emit appends recorded metric data to a metrics slice and prepares it for recording another set of data points. func (m *metricVcenterVMMemoryUtilization) emit(metrics pmetric.MetricSlice) { if m.config.Enabled && m.data.Gauge().DataPoints().Len() > 0 { + if m.config.AggregationStrategy == AggregationStrategyAvg { + for i, aggCount := range m.aggDataPoints { + m.data.Gauge().DataPoints().At(i).SetDoubleValue(m.data.Gauge().DataPoints().At(i).DoubleValue() / aggCount) + } + } m.updateCapacity() m.data.MoveTo(metrics.AppendEmpty()) m.init() @@ -3951,9 +6211,10 @@ func newMetricVcenterVMMemoryUtilization(cfg MetricConfig) metricVcenterVMMemory } type metricVcenterVMNetworkBroadcastPacketRate struct { - data pmetric.Metric // data buffer for generated metric. - config MetricConfig // metric config provided by user. - capacity int // max observed number of data points added to the metric. + data pmetric.Metric // data buffer for generated metric. + config MetricConfig // metric config provided by user. + capacity int // max observed number of data points added to the metric. + aggDataPoints []float64 // slice containing number of aggregated datapoints at each index } // init fills vcenter.vm.network.broadcast.packet.rate metric with initial data. @@ -3963,18 +6224,51 @@ func (m *metricVcenterVMNetworkBroadcastPacketRate) init() { m.data.SetUnit("{packets/s}") m.data.SetEmptyGauge() m.data.Gauge().DataPoints().EnsureCapacity(m.capacity) + m.aggDataPoints = m.aggDataPoints[:0] } func (m *metricVcenterVMNetworkBroadcastPacketRate) recordDataPoint(start pcommon.Timestamp, ts pcommon.Timestamp, val float64, throughputDirectionAttributeValue string, objectNameAttributeValue string) { if !m.config.Enabled { return } - dp := m.data.Gauge().DataPoints().AppendEmpty() + + dp := pmetric.NewNumberDataPoint() dp.SetStartTimestamp(start) dp.SetTimestamp(ts) + if slices.Contains(m.config.EnabledAttributes, "direction") { + dp.Attributes().PutStr("direction", throughputDirectionAttributeValue) + } + if slices.Contains(m.config.EnabledAttributes, "object") { + dp.Attributes().PutStr("object", objectNameAttributeValue) + } + + var s string + dps := m.data.Gauge().DataPoints() + for i := 0; i < dps.Len(); i++ { + dpi := dps.At(i) + if dp.Attributes().Equal(dpi.Attributes()) && dp.StartTimestamp() == dpi.StartTimestamp() && dp.Timestamp() == dpi.Timestamp() { + switch s = m.config.AggregationStrategy; s { + case AggregationStrategySum, AggregationStrategyAvg: + dpi.SetDoubleValue(dpi.DoubleValue() + val) + m.aggDataPoints[i] += 1 + return + case AggregationStrategyMin: + if dpi.DoubleValue() > val { + dpi.SetDoubleValue(val) + } + return + case AggregationStrategyMax: + if dpi.DoubleValue() < val { + dpi.SetDoubleValue(val) + } + return + } + } + } + dp.SetDoubleValue(val) - dp.Attributes().PutStr("direction", throughputDirectionAttributeValue) - dp.Attributes().PutStr("object", objectNameAttributeValue) + m.aggDataPoints = append(m.aggDataPoints, 1) + dp.MoveTo(dps.AppendEmpty()) } // updateCapacity saves max length of data point slices that will be used for the slice capacity. @@ -3987,6 +6281,11 @@ func (m *metricVcenterVMNetworkBroadcastPacketRate) updateCapacity() { // emit appends recorded metric data to a metrics slice and prepares it for recording another set of data points. func (m *metricVcenterVMNetworkBroadcastPacketRate) emit(metrics pmetric.MetricSlice) { if m.config.Enabled && m.data.Gauge().DataPoints().Len() > 0 { + if m.config.AggregationStrategy == AggregationStrategyAvg { + for i, aggCount := range m.aggDataPoints { + m.data.Gauge().DataPoints().At(i).SetDoubleValue(m.data.Gauge().DataPoints().At(i).DoubleValue() / aggCount) + } + } m.updateCapacity() m.data.MoveTo(metrics.AppendEmpty()) m.init() @@ -4004,9 +6303,10 @@ func newMetricVcenterVMNetworkBroadcastPacketRate(cfg MetricConfig) metricVcente } type metricVcenterVMNetworkMulticastPacketRate struct { - data pmetric.Metric // data buffer for generated metric. - config MetricConfig // metric config provided by user. - capacity int // max observed number of data points added to the metric. + data pmetric.Metric // data buffer for generated metric. + config MetricConfig // metric config provided by user. + capacity int // max observed number of data points added to the metric. + aggDataPoints []float64 // slice containing number of aggregated datapoints at each index } // init fills vcenter.vm.network.multicast.packet.rate metric with initial data. @@ -4016,18 +6316,51 @@ func (m *metricVcenterVMNetworkMulticastPacketRate) init() { m.data.SetUnit("{packets/s}") m.data.SetEmptyGauge() m.data.Gauge().DataPoints().EnsureCapacity(m.capacity) + m.aggDataPoints = m.aggDataPoints[:0] } func (m *metricVcenterVMNetworkMulticastPacketRate) recordDataPoint(start pcommon.Timestamp, ts pcommon.Timestamp, val float64, throughputDirectionAttributeValue string, objectNameAttributeValue string) { if !m.config.Enabled { return } - dp := m.data.Gauge().DataPoints().AppendEmpty() + + dp := pmetric.NewNumberDataPoint() dp.SetStartTimestamp(start) dp.SetTimestamp(ts) + if slices.Contains(m.config.EnabledAttributes, "direction") { + dp.Attributes().PutStr("direction", throughputDirectionAttributeValue) + } + if slices.Contains(m.config.EnabledAttributes, "object") { + dp.Attributes().PutStr("object", objectNameAttributeValue) + } + + var s string + dps := m.data.Gauge().DataPoints() + for i := 0; i < dps.Len(); i++ { + dpi := dps.At(i) + if dp.Attributes().Equal(dpi.Attributes()) && dp.StartTimestamp() == dpi.StartTimestamp() && dp.Timestamp() == dpi.Timestamp() { + switch s = m.config.AggregationStrategy; s { + case AggregationStrategySum, AggregationStrategyAvg: + dpi.SetDoubleValue(dpi.DoubleValue() + val) + m.aggDataPoints[i] += 1 + return + case AggregationStrategyMin: + if dpi.DoubleValue() > val { + dpi.SetDoubleValue(val) + } + return + case AggregationStrategyMax: + if dpi.DoubleValue() < val { + dpi.SetDoubleValue(val) + } + return + } + } + } + dp.SetDoubleValue(val) - dp.Attributes().PutStr("direction", throughputDirectionAttributeValue) - dp.Attributes().PutStr("object", objectNameAttributeValue) + m.aggDataPoints = append(m.aggDataPoints, 1) + dp.MoveTo(dps.AppendEmpty()) } // updateCapacity saves max length of data point slices that will be used for the slice capacity. @@ -4040,6 +6373,11 @@ func (m *metricVcenterVMNetworkMulticastPacketRate) updateCapacity() { // emit appends recorded metric data to a metrics slice and prepares it for recording another set of data points. func (m *metricVcenterVMNetworkMulticastPacketRate) emit(metrics pmetric.MetricSlice) { if m.config.Enabled && m.data.Gauge().DataPoints().Len() > 0 { + if m.config.AggregationStrategy == AggregationStrategyAvg { + for i, aggCount := range m.aggDataPoints { + m.data.Gauge().DataPoints().At(i).SetDoubleValue(m.data.Gauge().DataPoints().At(i).DoubleValue() / aggCount) + } + } m.updateCapacity() m.data.MoveTo(metrics.AppendEmpty()) m.init() @@ -4057,9 +6395,10 @@ func newMetricVcenterVMNetworkMulticastPacketRate(cfg MetricConfig) metricVcente } type metricVcenterVMNetworkPacketDropRate struct { - data pmetric.Metric // data buffer for generated metric. - config MetricConfig // metric config provided by user. - capacity int // max observed number of data points added to the metric. + data pmetric.Metric // data buffer for generated metric. + config MetricConfig // metric config provided by user. + capacity int // max observed number of data points added to the metric. + aggDataPoints []float64 // slice containing number of aggregated datapoints at each index } // init fills vcenter.vm.network.packet.drop.rate metric with initial data. @@ -4069,18 +6408,51 @@ func (m *metricVcenterVMNetworkPacketDropRate) init() { m.data.SetUnit("{packets/s}") m.data.SetEmptyGauge() m.data.Gauge().DataPoints().EnsureCapacity(m.capacity) + m.aggDataPoints = m.aggDataPoints[:0] } func (m *metricVcenterVMNetworkPacketDropRate) recordDataPoint(start pcommon.Timestamp, ts pcommon.Timestamp, val float64, throughputDirectionAttributeValue string, objectNameAttributeValue string) { if !m.config.Enabled { return } - dp := m.data.Gauge().DataPoints().AppendEmpty() + + dp := pmetric.NewNumberDataPoint() dp.SetStartTimestamp(start) dp.SetTimestamp(ts) + if slices.Contains(m.config.EnabledAttributes, "direction") { + dp.Attributes().PutStr("direction", throughputDirectionAttributeValue) + } + if slices.Contains(m.config.EnabledAttributes, "object") { + dp.Attributes().PutStr("object", objectNameAttributeValue) + } + + var s string + dps := m.data.Gauge().DataPoints() + for i := 0; i < dps.Len(); i++ { + dpi := dps.At(i) + if dp.Attributes().Equal(dpi.Attributes()) && dp.StartTimestamp() == dpi.StartTimestamp() && dp.Timestamp() == dpi.Timestamp() { + switch s = m.config.AggregationStrategy; s { + case AggregationStrategySum, AggregationStrategyAvg: + dpi.SetDoubleValue(dpi.DoubleValue() + val) + m.aggDataPoints[i] += 1 + return + case AggregationStrategyMin: + if dpi.DoubleValue() > val { + dpi.SetDoubleValue(val) + } + return + case AggregationStrategyMax: + if dpi.DoubleValue() < val { + dpi.SetDoubleValue(val) + } + return + } + } + } + dp.SetDoubleValue(val) - dp.Attributes().PutStr("direction", throughputDirectionAttributeValue) - dp.Attributes().PutStr("object", objectNameAttributeValue) + m.aggDataPoints = append(m.aggDataPoints, 1) + dp.MoveTo(dps.AppendEmpty()) } // updateCapacity saves max length of data point slices that will be used for the slice capacity. @@ -4093,6 +6465,11 @@ func (m *metricVcenterVMNetworkPacketDropRate) updateCapacity() { // emit appends recorded metric data to a metrics slice and prepares it for recording another set of data points. func (m *metricVcenterVMNetworkPacketDropRate) emit(metrics pmetric.MetricSlice) { if m.config.Enabled && m.data.Gauge().DataPoints().Len() > 0 { + if m.config.AggregationStrategy == AggregationStrategyAvg { + for i, aggCount := range m.aggDataPoints { + m.data.Gauge().DataPoints().At(i).SetDoubleValue(m.data.Gauge().DataPoints().At(i).DoubleValue() / aggCount) + } + } m.updateCapacity() m.data.MoveTo(metrics.AppendEmpty()) m.init() @@ -4110,9 +6487,10 @@ func newMetricVcenterVMNetworkPacketDropRate(cfg MetricConfig) metricVcenterVMNe } type metricVcenterVMNetworkPacketRate struct { - data pmetric.Metric // data buffer for generated metric. - config MetricConfig // metric config provided by user. - capacity int // max observed number of data points added to the metric. + data pmetric.Metric // data buffer for generated metric. + config MetricConfig // metric config provided by user. + capacity int // max observed number of data points added to the metric. + aggDataPoints []float64 // slice containing number of aggregated datapoints at each index } // init fills vcenter.vm.network.packet.rate metric with initial data. @@ -4122,18 +6500,51 @@ func (m *metricVcenterVMNetworkPacketRate) init() { m.data.SetUnit("{packets/s}") m.data.SetEmptyGauge() m.data.Gauge().DataPoints().EnsureCapacity(m.capacity) + m.aggDataPoints = m.aggDataPoints[:0] } func (m *metricVcenterVMNetworkPacketRate) recordDataPoint(start pcommon.Timestamp, ts pcommon.Timestamp, val float64, throughputDirectionAttributeValue string, objectNameAttributeValue string) { if !m.config.Enabled { return } - dp := m.data.Gauge().DataPoints().AppendEmpty() + + dp := pmetric.NewNumberDataPoint() dp.SetStartTimestamp(start) dp.SetTimestamp(ts) + if slices.Contains(m.config.EnabledAttributes, "direction") { + dp.Attributes().PutStr("direction", throughputDirectionAttributeValue) + } + if slices.Contains(m.config.EnabledAttributes, "object") { + dp.Attributes().PutStr("object", objectNameAttributeValue) + } + + var s string + dps := m.data.Gauge().DataPoints() + for i := 0; i < dps.Len(); i++ { + dpi := dps.At(i) + if dp.Attributes().Equal(dpi.Attributes()) && dp.StartTimestamp() == dpi.StartTimestamp() && dp.Timestamp() == dpi.Timestamp() { + switch s = m.config.AggregationStrategy; s { + case AggregationStrategySum, AggregationStrategyAvg: + dpi.SetDoubleValue(dpi.DoubleValue() + val) + m.aggDataPoints[i] += 1 + return + case AggregationStrategyMin: + if dpi.DoubleValue() > val { + dpi.SetDoubleValue(val) + } + return + case AggregationStrategyMax: + if dpi.DoubleValue() < val { + dpi.SetDoubleValue(val) + } + return + } + } + } + dp.SetDoubleValue(val) - dp.Attributes().PutStr("direction", throughputDirectionAttributeValue) - dp.Attributes().PutStr("object", objectNameAttributeValue) + m.aggDataPoints = append(m.aggDataPoints, 1) + dp.MoveTo(dps.AppendEmpty()) } // updateCapacity saves max length of data point slices that will be used for the slice capacity. @@ -4146,6 +6557,11 @@ func (m *metricVcenterVMNetworkPacketRate) updateCapacity() { // emit appends recorded metric data to a metrics slice and prepares it for recording another set of data points. func (m *metricVcenterVMNetworkPacketRate) emit(metrics pmetric.MetricSlice) { if m.config.Enabled && m.data.Gauge().DataPoints().Len() > 0 { + if m.config.AggregationStrategy == AggregationStrategyAvg { + for i, aggCount := range m.aggDataPoints { + m.data.Gauge().DataPoints().At(i).SetDoubleValue(m.data.Gauge().DataPoints().At(i).DoubleValue() / aggCount) + } + } m.updateCapacity() m.data.MoveTo(metrics.AppendEmpty()) m.init() @@ -4163,9 +6579,10 @@ func newMetricVcenterVMNetworkPacketRate(cfg MetricConfig) metricVcenterVMNetwor } type metricVcenterVMNetworkThroughput struct { - data pmetric.Metric // data buffer for generated metric. - config MetricConfig // metric config provided by user. - capacity int // max observed number of data points added to the metric. + data pmetric.Metric // data buffer for generated metric. + config MetricConfig // metric config provided by user. + capacity int // max observed number of data points added to the metric. + aggDataPoints []int64 // slice containing number of aggregated datapoints at each index } // init fills vcenter.vm.network.throughput metric with initial data. @@ -4177,18 +6594,51 @@ func (m *metricVcenterVMNetworkThroughput) init() { m.data.Sum().SetIsMonotonic(false) m.data.Sum().SetAggregationTemporality(pmetric.AggregationTemporalityCumulative) m.data.Sum().DataPoints().EnsureCapacity(m.capacity) + m.aggDataPoints = m.aggDataPoints[:0] } func (m *metricVcenterVMNetworkThroughput) recordDataPoint(start pcommon.Timestamp, ts pcommon.Timestamp, val int64, throughputDirectionAttributeValue string, objectNameAttributeValue string) { if !m.config.Enabled { return } - dp := m.data.Sum().DataPoints().AppendEmpty() + + dp := pmetric.NewNumberDataPoint() dp.SetStartTimestamp(start) dp.SetTimestamp(ts) + if slices.Contains(m.config.EnabledAttributes, "direction") { + dp.Attributes().PutStr("direction", throughputDirectionAttributeValue) + } + if slices.Contains(m.config.EnabledAttributes, "object") { + dp.Attributes().PutStr("object", objectNameAttributeValue) + } + + var s string + dps := m.data.Sum().DataPoints() + for i := 0; i < dps.Len(); i++ { + dpi := dps.At(i) + if dp.Attributes().Equal(dpi.Attributes()) && dp.StartTimestamp() == dpi.StartTimestamp() && dp.Timestamp() == dpi.Timestamp() { + switch s = m.config.AggregationStrategy; s { + case AggregationStrategySum, AggregationStrategyAvg: + dpi.SetIntValue(dpi.IntValue() + val) + m.aggDataPoints[i] += 1 + return + case AggregationStrategyMin: + if dpi.IntValue() > val { + dpi.SetIntValue(val) + } + return + case AggregationStrategyMax: + if dpi.IntValue() < val { + dpi.SetIntValue(val) + } + return + } + } + } + dp.SetIntValue(val) - dp.Attributes().PutStr("direction", throughputDirectionAttributeValue) - dp.Attributes().PutStr("object", objectNameAttributeValue) + m.aggDataPoints = append(m.aggDataPoints, 1) + dp.MoveTo(dps.AppendEmpty()) } // updateCapacity saves max length of data point slices that will be used for the slice capacity. @@ -4201,6 +6651,11 @@ func (m *metricVcenterVMNetworkThroughput) updateCapacity() { // emit appends recorded metric data to a metrics slice and prepares it for recording another set of data points. func (m *metricVcenterVMNetworkThroughput) emit(metrics pmetric.MetricSlice) { if m.config.Enabled && m.data.Sum().DataPoints().Len() > 0 { + if m.config.AggregationStrategy == AggregationStrategyAvg { + for i, aggCount := range m.aggDataPoints { + m.data.Sum().DataPoints().At(i).SetIntValue(m.data.Sum().DataPoints().At(i).IntValue() / aggCount) + } + } m.updateCapacity() m.data.MoveTo(metrics.AppendEmpty()) m.init() @@ -4218,9 +6673,10 @@ func newMetricVcenterVMNetworkThroughput(cfg MetricConfig) metricVcenterVMNetwor } type metricVcenterVMNetworkUsage struct { - data pmetric.Metric // data buffer for generated metric. - config MetricConfig // metric config provided by user. - capacity int // max observed number of data points added to the metric. + data pmetric.Metric // data buffer for generated metric. + config MetricConfig // metric config provided by user. + capacity int // max observed number of data points added to the metric. + aggDataPoints []int64 // slice containing number of aggregated datapoints at each index } // init fills vcenter.vm.network.usage metric with initial data. @@ -4232,17 +6688,48 @@ func (m *metricVcenterVMNetworkUsage) init() { m.data.Sum().SetIsMonotonic(false) m.data.Sum().SetAggregationTemporality(pmetric.AggregationTemporalityCumulative) m.data.Sum().DataPoints().EnsureCapacity(m.capacity) + m.aggDataPoints = m.aggDataPoints[:0] } func (m *metricVcenterVMNetworkUsage) recordDataPoint(start pcommon.Timestamp, ts pcommon.Timestamp, val int64, objectNameAttributeValue string) { if !m.config.Enabled { return } - dp := m.data.Sum().DataPoints().AppendEmpty() + + dp := pmetric.NewNumberDataPoint() dp.SetStartTimestamp(start) dp.SetTimestamp(ts) + if slices.Contains(m.config.EnabledAttributes, "object") { + dp.Attributes().PutStr("object", objectNameAttributeValue) + } + + var s string + dps := m.data.Sum().DataPoints() + for i := 0; i < dps.Len(); i++ { + dpi := dps.At(i) + if dp.Attributes().Equal(dpi.Attributes()) && dp.StartTimestamp() == dpi.StartTimestamp() && dp.Timestamp() == dpi.Timestamp() { + switch s = m.config.AggregationStrategy; s { + case AggregationStrategySum, AggregationStrategyAvg: + dpi.SetIntValue(dpi.IntValue() + val) + m.aggDataPoints[i] += 1 + return + case AggregationStrategyMin: + if dpi.IntValue() > val { + dpi.SetIntValue(val) + } + return + case AggregationStrategyMax: + if dpi.IntValue() < val { + dpi.SetIntValue(val) + } + return + } + } + } + dp.SetIntValue(val) - dp.Attributes().PutStr("object", objectNameAttributeValue) + m.aggDataPoints = append(m.aggDataPoints, 1) + dp.MoveTo(dps.AppendEmpty()) } // updateCapacity saves max length of data point slices that will be used for the slice capacity. @@ -4255,6 +6742,11 @@ func (m *metricVcenterVMNetworkUsage) updateCapacity() { // emit appends recorded metric data to a metrics slice and prepares it for recording another set of data points. func (m *metricVcenterVMNetworkUsage) emit(metrics pmetric.MetricSlice) { if m.config.Enabled && m.data.Sum().DataPoints().Len() > 0 { + if m.config.AggregationStrategy == AggregationStrategyAvg { + for i, aggCount := range m.aggDataPoints { + m.data.Sum().DataPoints().At(i).SetIntValue(m.data.Sum().DataPoints().At(i).IntValue() / aggCount) + } + } m.updateCapacity() m.data.MoveTo(metrics.AppendEmpty()) m.init() @@ -4272,9 +6764,10 @@ func newMetricVcenterVMNetworkUsage(cfg MetricConfig) metricVcenterVMNetworkUsag } type metricVcenterVMVsanLatencyAvg struct { - data pmetric.Metric // data buffer for generated metric. - config MetricConfig // metric config provided by user. - capacity int // max observed number of data points added to the metric. + data pmetric.Metric // data buffer for generated metric. + config MetricConfig // metric config provided by user. + capacity int // max observed number of data points added to the metric. + aggDataPoints []int64 // slice containing number of aggregated datapoints at each index } // init fills vcenter.vm.vsan.latency.avg metric with initial data. @@ -4284,17 +6777,48 @@ func (m *metricVcenterVMVsanLatencyAvg) init() { m.data.SetUnit("us") m.data.SetEmptyGauge() m.data.Gauge().DataPoints().EnsureCapacity(m.capacity) + m.aggDataPoints = m.aggDataPoints[:0] } func (m *metricVcenterVMVsanLatencyAvg) recordDataPoint(start pcommon.Timestamp, ts pcommon.Timestamp, val int64, vsanLatencyTypeAttributeValue string) { if !m.config.Enabled { return } - dp := m.data.Gauge().DataPoints().AppendEmpty() + + dp := pmetric.NewNumberDataPoint() dp.SetStartTimestamp(start) dp.SetTimestamp(ts) + if slices.Contains(m.config.EnabledAttributes, "type") { + dp.Attributes().PutStr("type", vsanLatencyTypeAttributeValue) + } + + var s string + dps := m.data.Gauge().DataPoints() + for i := 0; i < dps.Len(); i++ { + dpi := dps.At(i) + if dp.Attributes().Equal(dpi.Attributes()) && dp.StartTimestamp() == dpi.StartTimestamp() && dp.Timestamp() == dpi.Timestamp() { + switch s = m.config.AggregationStrategy; s { + case AggregationStrategySum, AggregationStrategyAvg: + dpi.SetIntValue(dpi.IntValue() + val) + m.aggDataPoints[i] += 1 + return + case AggregationStrategyMin: + if dpi.IntValue() > val { + dpi.SetIntValue(val) + } + return + case AggregationStrategyMax: + if dpi.IntValue() < val { + dpi.SetIntValue(val) + } + return + } + } + } + dp.SetIntValue(val) - dp.Attributes().PutStr("type", vsanLatencyTypeAttributeValue) + m.aggDataPoints = append(m.aggDataPoints, 1) + dp.MoveTo(dps.AppendEmpty()) } // updateCapacity saves max length of data point slices that will be used for the slice capacity. @@ -4307,6 +6831,11 @@ func (m *metricVcenterVMVsanLatencyAvg) updateCapacity() { // emit appends recorded metric data to a metrics slice and prepares it for recording another set of data points. func (m *metricVcenterVMVsanLatencyAvg) emit(metrics pmetric.MetricSlice) { if m.config.Enabled && m.data.Gauge().DataPoints().Len() > 0 { + if m.config.AggregationStrategy == AggregationStrategyAvg { + for i, aggCount := range m.aggDataPoints { + m.data.Gauge().DataPoints().At(i).SetIntValue(m.data.Gauge().DataPoints().At(i).IntValue() / aggCount) + } + } m.updateCapacity() m.data.MoveTo(metrics.AppendEmpty()) m.init() @@ -4324,9 +6853,10 @@ func newMetricVcenterVMVsanLatencyAvg(cfg MetricConfig) metricVcenterVMVsanLaten } type metricVcenterVMVsanOperations struct { - data pmetric.Metric // data buffer for generated metric. - config MetricConfig // metric config provided by user. - capacity int // max observed number of data points added to the metric. + data pmetric.Metric // data buffer for generated metric. + config MetricConfig // metric config provided by user. + capacity int // max observed number of data points added to the metric. + aggDataPoints []int64 // slice containing number of aggregated datapoints at each index } // init fills vcenter.vm.vsan.operations metric with initial data. @@ -4336,17 +6866,48 @@ func (m *metricVcenterVMVsanOperations) init() { m.data.SetUnit("{operations/s}") m.data.SetEmptyGauge() m.data.Gauge().DataPoints().EnsureCapacity(m.capacity) + m.aggDataPoints = m.aggDataPoints[:0] } func (m *metricVcenterVMVsanOperations) recordDataPoint(start pcommon.Timestamp, ts pcommon.Timestamp, val int64, vsanOperationTypeAttributeValue string) { if !m.config.Enabled { return } - dp := m.data.Gauge().DataPoints().AppendEmpty() + + dp := pmetric.NewNumberDataPoint() dp.SetStartTimestamp(start) dp.SetTimestamp(ts) + if slices.Contains(m.config.EnabledAttributes, "type") { + dp.Attributes().PutStr("type", vsanOperationTypeAttributeValue) + } + + var s string + dps := m.data.Gauge().DataPoints() + for i := 0; i < dps.Len(); i++ { + dpi := dps.At(i) + if dp.Attributes().Equal(dpi.Attributes()) && dp.StartTimestamp() == dpi.StartTimestamp() && dp.Timestamp() == dpi.Timestamp() { + switch s = m.config.AggregationStrategy; s { + case AggregationStrategySum, AggregationStrategyAvg: + dpi.SetIntValue(dpi.IntValue() + val) + m.aggDataPoints[i] += 1 + return + case AggregationStrategyMin: + if dpi.IntValue() > val { + dpi.SetIntValue(val) + } + return + case AggregationStrategyMax: + if dpi.IntValue() < val { + dpi.SetIntValue(val) + } + return + } + } + } + dp.SetIntValue(val) - dp.Attributes().PutStr("type", vsanOperationTypeAttributeValue) + m.aggDataPoints = append(m.aggDataPoints, 1) + dp.MoveTo(dps.AppendEmpty()) } // updateCapacity saves max length of data point slices that will be used for the slice capacity. @@ -4359,6 +6920,11 @@ func (m *metricVcenterVMVsanOperations) updateCapacity() { // emit appends recorded metric data to a metrics slice and prepares it for recording another set of data points. func (m *metricVcenterVMVsanOperations) emit(metrics pmetric.MetricSlice) { if m.config.Enabled && m.data.Gauge().DataPoints().Len() > 0 { + if m.config.AggregationStrategy == AggregationStrategyAvg { + for i, aggCount := range m.aggDataPoints { + m.data.Gauge().DataPoints().At(i).SetIntValue(m.data.Gauge().DataPoints().At(i).IntValue() / aggCount) + } + } m.updateCapacity() m.data.MoveTo(metrics.AppendEmpty()) m.init() @@ -4376,9 +6942,10 @@ func newMetricVcenterVMVsanOperations(cfg MetricConfig) metricVcenterVMVsanOpera } type metricVcenterVMVsanThroughput struct { - data pmetric.Metric // data buffer for generated metric. - config MetricConfig // metric config provided by user. - capacity int // max observed number of data points added to the metric. + data pmetric.Metric // data buffer for generated metric. + config MetricConfig // metric config provided by user. + capacity int // max observed number of data points added to the metric. + aggDataPoints []float64 // slice containing number of aggregated datapoints at each index } // init fills vcenter.vm.vsan.throughput metric with initial data. @@ -4388,17 +6955,48 @@ func (m *metricVcenterVMVsanThroughput) init() { m.data.SetUnit("By/s") m.data.SetEmptyGauge() m.data.Gauge().DataPoints().EnsureCapacity(m.capacity) + m.aggDataPoints = m.aggDataPoints[:0] } func (m *metricVcenterVMVsanThroughput) recordDataPoint(start pcommon.Timestamp, ts pcommon.Timestamp, val float64, vsanThroughputDirectionAttributeValue string) { if !m.config.Enabled { return } - dp := m.data.Gauge().DataPoints().AppendEmpty() + + dp := pmetric.NewNumberDataPoint() dp.SetStartTimestamp(start) dp.SetTimestamp(ts) + if slices.Contains(m.config.EnabledAttributes, "direction") { + dp.Attributes().PutStr("direction", vsanThroughputDirectionAttributeValue) + } + + var s string + dps := m.data.Gauge().DataPoints() + for i := 0; i < dps.Len(); i++ { + dpi := dps.At(i) + if dp.Attributes().Equal(dpi.Attributes()) && dp.StartTimestamp() == dpi.StartTimestamp() && dp.Timestamp() == dpi.Timestamp() { + switch s = m.config.AggregationStrategy; s { + case AggregationStrategySum, AggregationStrategyAvg: + dpi.SetDoubleValue(dpi.DoubleValue() + val) + m.aggDataPoints[i] += 1 + return + case AggregationStrategyMin: + if dpi.DoubleValue() > val { + dpi.SetDoubleValue(val) + } + return + case AggregationStrategyMax: + if dpi.DoubleValue() < val { + dpi.SetDoubleValue(val) + } + return + } + } + } + dp.SetDoubleValue(val) - dp.Attributes().PutStr("direction", vsanThroughputDirectionAttributeValue) + m.aggDataPoints = append(m.aggDataPoints, 1) + dp.MoveTo(dps.AppendEmpty()) } // updateCapacity saves max length of data point slices that will be used for the slice capacity. @@ -4411,6 +7009,11 @@ func (m *metricVcenterVMVsanThroughput) updateCapacity() { // emit appends recorded metric data to a metrics slice and prepares it for recording another set of data points. func (m *metricVcenterVMVsanThroughput) emit(metrics pmetric.MetricSlice) { if m.config.Enabled && m.data.Gauge().DataPoints().Len() > 0 { + if m.config.AggregationStrategy == AggregationStrategyAvg { + for i, aggCount := range m.aggDataPoints { + m.data.Gauge().DataPoints().At(i).SetDoubleValue(m.data.Gauge().DataPoints().At(i).DoubleValue() / aggCount) + } + } m.updateCapacity() m.data.MoveTo(metrics.AppendEmpty()) m.init() diff --git a/receiver/vcenterreceiver/internal/metadata/generated_metrics_test.go b/receiver/vcenterreceiver/internal/metadata/generated_metrics_test.go index 13370e93711d8..fe32044705dae 100644 --- a/receiver/vcenterreceiver/internal/metadata/generated_metrics_test.go +++ b/receiver/vcenterreceiver/internal/metadata/generated_metrics_test.go @@ -19,6 +19,7 @@ const ( testDataSetDefault testDataSet = iota testDataSetAll testDataSetNone + testDataSetReag ) func TestMetricsBuilder(t *testing.T) { @@ -36,6 +37,11 @@ func TestMetricsBuilder(t *testing.T) { metricsSet: testDataSetAll, resAttrsSet: testDataSetAll, }, + { + name: "reaggregate_set", + metricsSet: testDataSetReag, + resAttrsSet: testDataSetReag, + }, { name: "none_set", metricsSet: testDataSetNone, @@ -60,9 +66,83 @@ func TestMetricsBuilder(t *testing.T) { settings := receivertest.NewNopSettings(receivertest.NopType) settings.Logger = zap.New(observedZapCore) mb := NewMetricsBuilder(loadMetricsBuilderConfig(t, tt.name), settings, WithStartTime(start)) + aggMap := make(map[string]string) // contains the aggregation strategies for each metric name + aggMap["VcenterClusterCPUEffective"] = mb.metricVcenterClusterCPUEffective.config.AggregationStrategy + aggMap["VcenterClusterCPULimit"] = mb.metricVcenterClusterCPULimit.config.AggregationStrategy + aggMap["VcenterClusterHostCount"] = mb.metricVcenterClusterHostCount.config.AggregationStrategy + aggMap["VcenterClusterMemoryEffective"] = mb.metricVcenterClusterMemoryEffective.config.AggregationStrategy + aggMap["VcenterClusterMemoryLimit"] = mb.metricVcenterClusterMemoryLimit.config.AggregationStrategy + aggMap["VcenterClusterVMCount"] = mb.metricVcenterClusterVMCount.config.AggregationStrategy + aggMap["VcenterClusterVMTemplateCount"] = mb.metricVcenterClusterVMTemplateCount.config.AggregationStrategy + aggMap["VcenterClusterVsanCongestions"] = mb.metricVcenterClusterVsanCongestions.config.AggregationStrategy + aggMap["VcenterClusterVsanLatencyAvg"] = mb.metricVcenterClusterVsanLatencyAvg.config.AggregationStrategy + aggMap["VcenterClusterVsanOperations"] = mb.metricVcenterClusterVsanOperations.config.AggregationStrategy + aggMap["VcenterClusterVsanThroughput"] = mb.metricVcenterClusterVsanThroughput.config.AggregationStrategy + aggMap["VcenterDatacenterClusterCount"] = mb.metricVcenterDatacenterClusterCount.config.AggregationStrategy + aggMap["VcenterDatacenterCPULimit"] = mb.metricVcenterDatacenterCPULimit.config.AggregationStrategy + aggMap["VcenterDatacenterDatastoreCount"] = mb.metricVcenterDatacenterDatastoreCount.config.AggregationStrategy + aggMap["VcenterDatacenterDiskSpace"] = mb.metricVcenterDatacenterDiskSpace.config.AggregationStrategy + aggMap["VcenterDatacenterHostCount"] = mb.metricVcenterDatacenterHostCount.config.AggregationStrategy + aggMap["VcenterDatacenterMemoryLimit"] = mb.metricVcenterDatacenterMemoryLimit.config.AggregationStrategy + aggMap["VcenterDatacenterVMCount"] = mb.metricVcenterDatacenterVMCount.config.AggregationStrategy + aggMap["VcenterDatastoreDiskUsage"] = mb.metricVcenterDatastoreDiskUsage.config.AggregationStrategy + aggMap["VcenterDatastoreDiskUtilization"] = mb.metricVcenterDatastoreDiskUtilization.config.AggregationStrategy + aggMap["VcenterHostCPUCapacity"] = mb.metricVcenterHostCPUCapacity.config.AggregationStrategy + aggMap["VcenterHostCPUReserved"] = mb.metricVcenterHostCPUReserved.config.AggregationStrategy + aggMap["VcenterHostCPUUsage"] = mb.metricVcenterHostCPUUsage.config.AggregationStrategy + aggMap["VcenterHostCPUUtilization"] = mb.metricVcenterHostCPUUtilization.config.AggregationStrategy + aggMap["VcenterHostDiskLatencyAvg"] = mb.metricVcenterHostDiskLatencyAvg.config.AggregationStrategy + aggMap["VcenterHostDiskLatencyMax"] = mb.metricVcenterHostDiskLatencyMax.config.AggregationStrategy + aggMap["VcenterHostDiskThroughput"] = mb.metricVcenterHostDiskThroughput.config.AggregationStrategy + aggMap["VcenterHostMemoryCapacity"] = mb.metricVcenterHostMemoryCapacity.config.AggregationStrategy + aggMap["VcenterHostMemoryUsage"] = mb.metricVcenterHostMemoryUsage.config.AggregationStrategy + aggMap["VcenterHostMemoryUtilization"] = mb.metricVcenterHostMemoryUtilization.config.AggregationStrategy + aggMap["VcenterHostNetworkPacketDropRate"] = mb.metricVcenterHostNetworkPacketDropRate.config.AggregationStrategy + aggMap["VcenterHostNetworkPacketErrorRate"] = mb.metricVcenterHostNetworkPacketErrorRate.config.AggregationStrategy + aggMap["VcenterHostNetworkPacketRate"] = mb.metricVcenterHostNetworkPacketRate.config.AggregationStrategy + aggMap["VcenterHostNetworkThroughput"] = mb.metricVcenterHostNetworkThroughput.config.AggregationStrategy + aggMap["VcenterHostNetworkUsage"] = mb.metricVcenterHostNetworkUsage.config.AggregationStrategy + aggMap["VcenterHostVsanCacheHitRate"] = mb.metricVcenterHostVsanCacheHitRate.config.AggregationStrategy + aggMap["VcenterHostVsanCongestions"] = mb.metricVcenterHostVsanCongestions.config.AggregationStrategy + aggMap["VcenterHostVsanLatencyAvg"] = mb.metricVcenterHostVsanLatencyAvg.config.AggregationStrategy + aggMap["VcenterHostVsanOperations"] = mb.metricVcenterHostVsanOperations.config.AggregationStrategy + aggMap["VcenterHostVsanThroughput"] = mb.metricVcenterHostVsanThroughput.config.AggregationStrategy + aggMap["VcenterResourcePoolCPUShares"] = mb.metricVcenterResourcePoolCPUShares.config.AggregationStrategy + aggMap["VcenterResourcePoolCPUUsage"] = mb.metricVcenterResourcePoolCPUUsage.config.AggregationStrategy + aggMap["VcenterResourcePoolMemoryBallooned"] = mb.metricVcenterResourcePoolMemoryBallooned.config.AggregationStrategy + aggMap["VcenterResourcePoolMemoryGranted"] = mb.metricVcenterResourcePoolMemoryGranted.config.AggregationStrategy + aggMap["VcenterResourcePoolMemoryShares"] = mb.metricVcenterResourcePoolMemoryShares.config.AggregationStrategy + aggMap["VcenterResourcePoolMemorySwapped"] = mb.metricVcenterResourcePoolMemorySwapped.config.AggregationStrategy + aggMap["VcenterResourcePoolMemoryUsage"] = mb.metricVcenterResourcePoolMemoryUsage.config.AggregationStrategy + aggMap["VcenterVMCPUReadiness"] = mb.metricVcenterVMCPUReadiness.config.AggregationStrategy + aggMap["VcenterVMCPUTime"] = mb.metricVcenterVMCPUTime.config.AggregationStrategy + aggMap["VcenterVMCPUUsage"] = mb.metricVcenterVMCPUUsage.config.AggregationStrategy + aggMap["VcenterVMCPUUtilization"] = mb.metricVcenterVMCPUUtilization.config.AggregationStrategy + aggMap["VcenterVMDiskLatencyAvg"] = mb.metricVcenterVMDiskLatencyAvg.config.AggregationStrategy + aggMap["VcenterVMDiskLatencyMax"] = mb.metricVcenterVMDiskLatencyMax.config.AggregationStrategy + aggMap["VcenterVMDiskThroughput"] = mb.metricVcenterVMDiskThroughput.config.AggregationStrategy + aggMap["VcenterVMDiskUsage"] = mb.metricVcenterVMDiskUsage.config.AggregationStrategy + aggMap["VcenterVMDiskUtilization"] = mb.metricVcenterVMDiskUtilization.config.AggregationStrategy + aggMap["VcenterVMMemoryBallooned"] = mb.metricVcenterVMMemoryBallooned.config.AggregationStrategy + aggMap["VcenterVMMemoryGranted"] = mb.metricVcenterVMMemoryGranted.config.AggregationStrategy + aggMap["VcenterVMMemorySwapped"] = mb.metricVcenterVMMemorySwapped.config.AggregationStrategy + aggMap["VcenterVMMemorySwappedSsd"] = mb.metricVcenterVMMemorySwappedSsd.config.AggregationStrategy + aggMap["VcenterVMMemoryUsage"] = mb.metricVcenterVMMemoryUsage.config.AggregationStrategy + aggMap["VcenterVMMemoryUtilization"] = mb.metricVcenterVMMemoryUtilization.config.AggregationStrategy + aggMap["VcenterVMNetworkBroadcastPacketRate"] = mb.metricVcenterVMNetworkBroadcastPacketRate.config.AggregationStrategy + aggMap["VcenterVMNetworkMulticastPacketRate"] = mb.metricVcenterVMNetworkMulticastPacketRate.config.AggregationStrategy + aggMap["VcenterVMNetworkPacketDropRate"] = mb.metricVcenterVMNetworkPacketDropRate.config.AggregationStrategy + aggMap["VcenterVMNetworkPacketRate"] = mb.metricVcenterVMNetworkPacketRate.config.AggregationStrategy + aggMap["VcenterVMNetworkThroughput"] = mb.metricVcenterVMNetworkThroughput.config.AggregationStrategy + aggMap["VcenterVMNetworkUsage"] = mb.metricVcenterVMNetworkUsage.config.AggregationStrategy + aggMap["VcenterVMVsanLatencyAvg"] = mb.metricVcenterVMVsanLatencyAvg.config.AggregationStrategy + aggMap["VcenterVMVsanOperations"] = mb.metricVcenterVMVsanOperations.config.AggregationStrategy + aggMap["VcenterVMVsanThroughput"] = mb.metricVcenterVMVsanThroughput.config.AggregationStrategy expectedWarnings := 0 - assert.Equal(t, expectedWarnings, observedLogs.Len()) + if tt.metricsSet != testDataSetReag { + assert.Equal(t, expectedWarnings, observedLogs.Len()) + } defaultMetricsCount := 0 allMetricsCount := 0 @@ -70,281 +150,494 @@ func TestMetricsBuilder(t *testing.T) { defaultMetricsCount++ allMetricsCount++ mb.RecordVcenterClusterCPUEffectiveDataPoint(ts, 1) + if tt.name == "reaggregate_set" { + mb.RecordVcenterClusterCPUEffectiveDataPoint(ts, 3) + } defaultMetricsCount++ allMetricsCount++ mb.RecordVcenterClusterCPULimitDataPoint(ts, 1) + if tt.name == "reaggregate_set" { + mb.RecordVcenterClusterCPULimitDataPoint(ts, 3) + } defaultMetricsCount++ allMetricsCount++ mb.RecordVcenterClusterHostCountDataPoint(ts, 1, true) + if tt.name == "reaggregate_set" { + mb.RecordVcenterClusterHostCountDataPoint(ts, 3, false) + } defaultMetricsCount++ allMetricsCount++ mb.RecordVcenterClusterMemoryEffectiveDataPoint(ts, 1) + if tt.name == "reaggregate_set" { + mb.RecordVcenterClusterMemoryEffectiveDataPoint(ts, 3) + } defaultMetricsCount++ allMetricsCount++ mb.RecordVcenterClusterMemoryLimitDataPoint(ts, 1) + if tt.name == "reaggregate_set" { + mb.RecordVcenterClusterMemoryLimitDataPoint(ts, 3) + } defaultMetricsCount++ allMetricsCount++ mb.RecordVcenterClusterVMCountDataPoint(ts, 1, AttributeVMCountPowerStateOn) + if tt.name == "reaggregate_set" { + mb.RecordVcenterClusterVMCountDataPoint(ts, 3, AttributeVMCountPowerStateOff) + } defaultMetricsCount++ allMetricsCount++ mb.RecordVcenterClusterVMTemplateCountDataPoint(ts, 1) + if tt.name == "reaggregate_set" { + mb.RecordVcenterClusterVMTemplateCountDataPoint(ts, 3) + } defaultMetricsCount++ allMetricsCount++ mb.RecordVcenterClusterVsanCongestionsDataPoint(ts, 1) + if tt.name == "reaggregate_set" { + mb.RecordVcenterClusterVsanCongestionsDataPoint(ts, 3) + } defaultMetricsCount++ allMetricsCount++ mb.RecordVcenterClusterVsanLatencyAvgDataPoint(ts, 1, AttributeVsanLatencyTypeRead) + if tt.name == "reaggregate_set" { + mb.RecordVcenterClusterVsanLatencyAvgDataPoint(ts, 3, AttributeVsanLatencyTypeWrite) + } defaultMetricsCount++ allMetricsCount++ mb.RecordVcenterClusterVsanOperationsDataPoint(ts, 1, AttributeVsanOperationTypeRead) + if tt.name == "reaggregate_set" { + mb.RecordVcenterClusterVsanOperationsDataPoint(ts, 3, AttributeVsanOperationTypeWrite) + } defaultMetricsCount++ allMetricsCount++ mb.RecordVcenterClusterVsanThroughputDataPoint(ts, 1, AttributeVsanThroughputDirectionRead) + if tt.name == "reaggregate_set" { + mb.RecordVcenterClusterVsanThroughputDataPoint(ts, 3, AttributeVsanThroughputDirectionWrite) + } defaultMetricsCount++ allMetricsCount++ mb.RecordVcenterDatacenterClusterCountDataPoint(ts, 1, AttributeEntityStatusRed) + if tt.name == "reaggregate_set" { + mb.RecordVcenterDatacenterClusterCountDataPoint(ts, 3, AttributeEntityStatusYellow) + } defaultMetricsCount++ allMetricsCount++ mb.RecordVcenterDatacenterCPULimitDataPoint(ts, 1) + if tt.name == "reaggregate_set" { + mb.RecordVcenterDatacenterCPULimitDataPoint(ts, 3) + } defaultMetricsCount++ allMetricsCount++ mb.RecordVcenterDatacenterDatastoreCountDataPoint(ts, 1) + if tt.name == "reaggregate_set" { + mb.RecordVcenterDatacenterDatastoreCountDataPoint(ts, 3) + } defaultMetricsCount++ allMetricsCount++ mb.RecordVcenterDatacenterDiskSpaceDataPoint(ts, 1, AttributeDiskStateAvailable) + if tt.name == "reaggregate_set" { + mb.RecordVcenterDatacenterDiskSpaceDataPoint(ts, 3, AttributeDiskStateUsed) + } defaultMetricsCount++ allMetricsCount++ mb.RecordVcenterDatacenterHostCountDataPoint(ts, 1, AttributeEntityStatusRed, AttributeHostPowerStateOn) + if tt.name == "reaggregate_set" { + mb.RecordVcenterDatacenterHostCountDataPoint(ts, 3, AttributeEntityStatusYellow, AttributeHostPowerStateOff) + } defaultMetricsCount++ allMetricsCount++ mb.RecordVcenterDatacenterMemoryLimitDataPoint(ts, 1) + if tt.name == "reaggregate_set" { + mb.RecordVcenterDatacenterMemoryLimitDataPoint(ts, 3) + } defaultMetricsCount++ allMetricsCount++ mb.RecordVcenterDatacenterVMCountDataPoint(ts, 1, AttributeEntityStatusRed, AttributeVMCountPowerStateOn) + if tt.name == "reaggregate_set" { + mb.RecordVcenterDatacenterVMCountDataPoint(ts, 3, AttributeEntityStatusYellow, AttributeVMCountPowerStateOff) + } defaultMetricsCount++ allMetricsCount++ mb.RecordVcenterDatastoreDiskUsageDataPoint(ts, 1, AttributeDiskStateAvailable) + if tt.name == "reaggregate_set" { + mb.RecordVcenterDatastoreDiskUsageDataPoint(ts, 3, AttributeDiskStateUsed) + } defaultMetricsCount++ allMetricsCount++ mb.RecordVcenterDatastoreDiskUtilizationDataPoint(ts, 1) + if tt.name == "reaggregate_set" { + mb.RecordVcenterDatastoreDiskUtilizationDataPoint(ts, 3) + } defaultMetricsCount++ allMetricsCount++ mb.RecordVcenterHostCPUCapacityDataPoint(ts, 1) + if tt.name == "reaggregate_set" { + mb.RecordVcenterHostCPUCapacityDataPoint(ts, 3) + } defaultMetricsCount++ allMetricsCount++ mb.RecordVcenterHostCPUReservedDataPoint(ts, 1, AttributeCPUReservationTypeTotal) + if tt.name == "reaggregate_set" { + mb.RecordVcenterHostCPUReservedDataPoint(ts, 3, AttributeCPUReservationTypeUsed) + } defaultMetricsCount++ allMetricsCount++ mb.RecordVcenterHostCPUUsageDataPoint(ts, 1) + if tt.name == "reaggregate_set" { + mb.RecordVcenterHostCPUUsageDataPoint(ts, 3) + } defaultMetricsCount++ allMetricsCount++ mb.RecordVcenterHostCPUUtilizationDataPoint(ts, 1) + if tt.name == "reaggregate_set" { + mb.RecordVcenterHostCPUUtilizationDataPoint(ts, 3) + } defaultMetricsCount++ allMetricsCount++ mb.RecordVcenterHostDiskLatencyAvgDataPoint(ts, 1, AttributeDiskDirectionRead, "object_name-val") + if tt.name == "reaggregate_set" { + mb.RecordVcenterHostDiskLatencyAvgDataPoint(ts, 3, AttributeDiskDirectionWrite, "object_name-val-2") + } defaultMetricsCount++ allMetricsCount++ mb.RecordVcenterHostDiskLatencyMaxDataPoint(ts, 1, "object_name-val") + if tt.name == "reaggregate_set" { + mb.RecordVcenterHostDiskLatencyMaxDataPoint(ts, 3, "object_name-val-2") + } defaultMetricsCount++ allMetricsCount++ mb.RecordVcenterHostDiskThroughputDataPoint(ts, 1, AttributeDiskDirectionRead, "object_name-val") + if tt.name == "reaggregate_set" { + mb.RecordVcenterHostDiskThroughputDataPoint(ts, 3, AttributeDiskDirectionWrite, "object_name-val-2") + } allMetricsCount++ mb.RecordVcenterHostMemoryCapacityDataPoint(ts, 1) + if tt.name == "reaggregate_set" { + mb.RecordVcenterHostMemoryCapacityDataPoint(ts, 3) + } defaultMetricsCount++ allMetricsCount++ mb.RecordVcenterHostMemoryUsageDataPoint(ts, 1) + if tt.name == "reaggregate_set" { + mb.RecordVcenterHostMemoryUsageDataPoint(ts, 3) + } defaultMetricsCount++ allMetricsCount++ mb.RecordVcenterHostMemoryUtilizationDataPoint(ts, 1) + if tt.name == "reaggregate_set" { + mb.RecordVcenterHostMemoryUtilizationDataPoint(ts, 3) + } defaultMetricsCount++ allMetricsCount++ mb.RecordVcenterHostNetworkPacketDropRateDataPoint(ts, 1, AttributeThroughputDirectionTransmitted, "object_name-val") + if tt.name == "reaggregate_set" { + mb.RecordVcenterHostNetworkPacketDropRateDataPoint(ts, 3, AttributeThroughputDirectionReceived, "object_name-val-2") + } defaultMetricsCount++ allMetricsCount++ mb.RecordVcenterHostNetworkPacketErrorRateDataPoint(ts, 1, AttributeThroughputDirectionTransmitted, "object_name-val") + if tt.name == "reaggregate_set" { + mb.RecordVcenterHostNetworkPacketErrorRateDataPoint(ts, 3, AttributeThroughputDirectionReceived, "object_name-val-2") + } defaultMetricsCount++ allMetricsCount++ mb.RecordVcenterHostNetworkPacketRateDataPoint(ts, 1, AttributeThroughputDirectionTransmitted, "object_name-val") + if tt.name == "reaggregate_set" { + mb.RecordVcenterHostNetworkPacketRateDataPoint(ts, 3, AttributeThroughputDirectionReceived, "object_name-val-2") + } defaultMetricsCount++ allMetricsCount++ mb.RecordVcenterHostNetworkThroughputDataPoint(ts, 1, AttributeThroughputDirectionTransmitted, "object_name-val") + if tt.name == "reaggregate_set" { + mb.RecordVcenterHostNetworkThroughputDataPoint(ts, 3, AttributeThroughputDirectionReceived, "object_name-val-2") + } defaultMetricsCount++ allMetricsCount++ mb.RecordVcenterHostNetworkUsageDataPoint(ts, 1, "object_name-val") + if tt.name == "reaggregate_set" { + mb.RecordVcenterHostNetworkUsageDataPoint(ts, 3, "object_name-val-2") + } defaultMetricsCount++ allMetricsCount++ mb.RecordVcenterHostVsanCacheHitRateDataPoint(ts, 1) + if tt.name == "reaggregate_set" { + mb.RecordVcenterHostVsanCacheHitRateDataPoint(ts, 3) + } defaultMetricsCount++ allMetricsCount++ mb.RecordVcenterHostVsanCongestionsDataPoint(ts, 1) + if tt.name == "reaggregate_set" { + mb.RecordVcenterHostVsanCongestionsDataPoint(ts, 3) + } defaultMetricsCount++ allMetricsCount++ mb.RecordVcenterHostVsanLatencyAvgDataPoint(ts, 1, AttributeVsanLatencyTypeRead) + if tt.name == "reaggregate_set" { + mb.RecordVcenterHostVsanLatencyAvgDataPoint(ts, 3, AttributeVsanLatencyTypeWrite) + } defaultMetricsCount++ allMetricsCount++ mb.RecordVcenterHostVsanOperationsDataPoint(ts, 1, AttributeVsanOperationTypeRead) + if tt.name == "reaggregate_set" { + mb.RecordVcenterHostVsanOperationsDataPoint(ts, 3, AttributeVsanOperationTypeWrite) + } defaultMetricsCount++ allMetricsCount++ mb.RecordVcenterHostVsanThroughputDataPoint(ts, 1, AttributeVsanThroughputDirectionRead) + if tt.name == "reaggregate_set" { + mb.RecordVcenterHostVsanThroughputDataPoint(ts, 3, AttributeVsanThroughputDirectionWrite) + } defaultMetricsCount++ allMetricsCount++ mb.RecordVcenterResourcePoolCPUSharesDataPoint(ts, 1) + if tt.name == "reaggregate_set" { + mb.RecordVcenterResourcePoolCPUSharesDataPoint(ts, 3) + } defaultMetricsCount++ allMetricsCount++ mb.RecordVcenterResourcePoolCPUUsageDataPoint(ts, 1) + if tt.name == "reaggregate_set" { + mb.RecordVcenterResourcePoolCPUUsageDataPoint(ts, 3) + } defaultMetricsCount++ allMetricsCount++ mb.RecordVcenterResourcePoolMemoryBalloonedDataPoint(ts, 1) + if tt.name == "reaggregate_set" { + mb.RecordVcenterResourcePoolMemoryBalloonedDataPoint(ts, 3) + } defaultMetricsCount++ allMetricsCount++ mb.RecordVcenterResourcePoolMemoryGrantedDataPoint(ts, 1, AttributeMemoryGrantedTypePrivate) + if tt.name == "reaggregate_set" { + mb.RecordVcenterResourcePoolMemoryGrantedDataPoint(ts, 3, AttributeMemoryGrantedTypeShared) + } defaultMetricsCount++ allMetricsCount++ mb.RecordVcenterResourcePoolMemorySharesDataPoint(ts, 1) + if tt.name == "reaggregate_set" { + mb.RecordVcenterResourcePoolMemorySharesDataPoint(ts, 3) + } defaultMetricsCount++ allMetricsCount++ mb.RecordVcenterResourcePoolMemorySwappedDataPoint(ts, 1) + if tt.name == "reaggregate_set" { + mb.RecordVcenterResourcePoolMemorySwappedDataPoint(ts, 3) + } defaultMetricsCount++ allMetricsCount++ mb.RecordVcenterResourcePoolMemoryUsageDataPoint(ts, 1, AttributeMemoryUsageTypeGuest) + if tt.name == "reaggregate_set" { + mb.RecordVcenterResourcePoolMemoryUsageDataPoint(ts, 3, AttributeMemoryUsageTypeHost) + } defaultMetricsCount++ allMetricsCount++ mb.RecordVcenterVMCPUReadinessDataPoint(ts, 1) + if tt.name == "reaggregate_set" { + mb.RecordVcenterVMCPUReadinessDataPoint(ts, 3) + } allMetricsCount++ mb.RecordVcenterVMCPUTimeDataPoint(ts, 1, AttributeCPUStateIdle, "object_name-val") + if tt.name == "reaggregate_set" { + mb.RecordVcenterVMCPUTimeDataPoint(ts, 3, AttributeCPUStateReady, "object_name-val-2") + } defaultMetricsCount++ allMetricsCount++ mb.RecordVcenterVMCPUUsageDataPoint(ts, 1) + if tt.name == "reaggregate_set" { + mb.RecordVcenterVMCPUUsageDataPoint(ts, 3) + } defaultMetricsCount++ allMetricsCount++ mb.RecordVcenterVMCPUUtilizationDataPoint(ts, 1) + if tt.name == "reaggregate_set" { + mb.RecordVcenterVMCPUUtilizationDataPoint(ts, 3) + } defaultMetricsCount++ allMetricsCount++ mb.RecordVcenterVMDiskLatencyAvgDataPoint(ts, 1, AttributeDiskDirectionRead, AttributeDiskTypeVirtual, "object_name-val") + if tt.name == "reaggregate_set" { + mb.RecordVcenterVMDiskLatencyAvgDataPoint(ts, 3, AttributeDiskDirectionWrite, AttributeDiskTypePhysical, "object_name-val-2") + } defaultMetricsCount++ allMetricsCount++ mb.RecordVcenterVMDiskLatencyMaxDataPoint(ts, 1, "object_name-val") + if tt.name == "reaggregate_set" { + mb.RecordVcenterVMDiskLatencyMaxDataPoint(ts, 3, "object_name-val-2") + } defaultMetricsCount++ allMetricsCount++ mb.RecordVcenterVMDiskThroughputDataPoint(ts, 1, AttributeDiskDirectionRead, "object_name-val") + if tt.name == "reaggregate_set" { + mb.RecordVcenterVMDiskThroughputDataPoint(ts, 3, AttributeDiskDirectionWrite, "object_name-val-2") + } defaultMetricsCount++ allMetricsCount++ mb.RecordVcenterVMDiskUsageDataPoint(ts, 1, AttributeDiskStateAvailable) + if tt.name == "reaggregate_set" { + mb.RecordVcenterVMDiskUsageDataPoint(ts, 3, AttributeDiskStateUsed) + } defaultMetricsCount++ allMetricsCount++ mb.RecordVcenterVMDiskUtilizationDataPoint(ts, 1) + if tt.name == "reaggregate_set" { + mb.RecordVcenterVMDiskUtilizationDataPoint(ts, 3) + } defaultMetricsCount++ allMetricsCount++ mb.RecordVcenterVMMemoryBalloonedDataPoint(ts, 1) + if tt.name == "reaggregate_set" { + mb.RecordVcenterVMMemoryBalloonedDataPoint(ts, 3) + } allMetricsCount++ mb.RecordVcenterVMMemoryGrantedDataPoint(ts, 1) + if tt.name == "reaggregate_set" { + mb.RecordVcenterVMMemoryGrantedDataPoint(ts, 3) + } defaultMetricsCount++ allMetricsCount++ mb.RecordVcenterVMMemorySwappedDataPoint(ts, 1) + if tt.name == "reaggregate_set" { + mb.RecordVcenterVMMemorySwappedDataPoint(ts, 3) + } defaultMetricsCount++ allMetricsCount++ mb.RecordVcenterVMMemorySwappedSsdDataPoint(ts, 1) + if tt.name == "reaggregate_set" { + mb.RecordVcenterVMMemorySwappedSsdDataPoint(ts, 3) + } defaultMetricsCount++ allMetricsCount++ mb.RecordVcenterVMMemoryUsageDataPoint(ts, 1) + if tt.name == "reaggregate_set" { + mb.RecordVcenterVMMemoryUsageDataPoint(ts, 3) + } defaultMetricsCount++ allMetricsCount++ mb.RecordVcenterVMMemoryUtilizationDataPoint(ts, 1) + if tt.name == "reaggregate_set" { + mb.RecordVcenterVMMemoryUtilizationDataPoint(ts, 3) + } allMetricsCount++ mb.RecordVcenterVMNetworkBroadcastPacketRateDataPoint(ts, 1, AttributeThroughputDirectionTransmitted, "object_name-val") + if tt.name == "reaggregate_set" { + mb.RecordVcenterVMNetworkBroadcastPacketRateDataPoint(ts, 3, AttributeThroughputDirectionReceived, "object_name-val-2") + } allMetricsCount++ mb.RecordVcenterVMNetworkMulticastPacketRateDataPoint(ts, 1, AttributeThroughputDirectionTransmitted, "object_name-val") + if tt.name == "reaggregate_set" { + mb.RecordVcenterVMNetworkMulticastPacketRateDataPoint(ts, 3, AttributeThroughputDirectionReceived, "object_name-val-2") + } defaultMetricsCount++ allMetricsCount++ mb.RecordVcenterVMNetworkPacketDropRateDataPoint(ts, 1, AttributeThroughputDirectionTransmitted, "object_name-val") + if tt.name == "reaggregate_set" { + mb.RecordVcenterVMNetworkPacketDropRateDataPoint(ts, 3, AttributeThroughputDirectionReceived, "object_name-val-2") + } defaultMetricsCount++ allMetricsCount++ mb.RecordVcenterVMNetworkPacketRateDataPoint(ts, 1, AttributeThroughputDirectionTransmitted, "object_name-val") + if tt.name == "reaggregate_set" { + mb.RecordVcenterVMNetworkPacketRateDataPoint(ts, 3, AttributeThroughputDirectionReceived, "object_name-val-2") + } defaultMetricsCount++ allMetricsCount++ mb.RecordVcenterVMNetworkThroughputDataPoint(ts, 1, AttributeThroughputDirectionTransmitted, "object_name-val") + if tt.name == "reaggregate_set" { + mb.RecordVcenterVMNetworkThroughputDataPoint(ts, 3, AttributeThroughputDirectionReceived, "object_name-val-2") + } defaultMetricsCount++ allMetricsCount++ mb.RecordVcenterVMNetworkUsageDataPoint(ts, 1, "object_name-val") + if tt.name == "reaggregate_set" { + mb.RecordVcenterVMNetworkUsageDataPoint(ts, 3, "object_name-val-2") + } defaultMetricsCount++ allMetricsCount++ mb.RecordVcenterVMVsanLatencyAvgDataPoint(ts, 1, AttributeVsanLatencyTypeRead) + if tt.name == "reaggregate_set" { + mb.RecordVcenterVMVsanLatencyAvgDataPoint(ts, 3, AttributeVsanLatencyTypeWrite) + } defaultMetricsCount++ allMetricsCount++ mb.RecordVcenterVMVsanOperationsDataPoint(ts, 1, AttributeVsanOperationTypeRead) + if tt.name == "reaggregate_set" { + mb.RecordVcenterVMVsanOperationsDataPoint(ts, 3, AttributeVsanOperationTypeWrite) + } defaultMetricsCount++ allMetricsCount++ mb.RecordVcenterVMVsanThroughputDataPoint(ts, 1, AttributeVsanThroughputDirectionRead) + if tt.name == "reaggregate_set" { + mb.RecordVcenterVMVsanThroughputDataPoint(ts, 3, AttributeVsanThroughputDirectionWrite) + } rb := mb.NewResourceBuilder() rb.SetVcenterClusterName("vcenter.cluster.name-val") @@ -361,6 +654,79 @@ func TestMetricsBuilder(t *testing.T) { rb.SetVcenterVMTemplateName("vcenter.vm_template.name-val") res := rb.Emit() metrics := mb.Emit(WithResource(res)) + if tt.name == "reaggregate_set" { + assert.Empty(t, mb.metricVcenterClusterCPUEffective.aggDataPoints) + assert.Empty(t, mb.metricVcenterClusterCPULimit.aggDataPoints) + assert.Empty(t, mb.metricVcenterClusterHostCount.aggDataPoints) + assert.Empty(t, mb.metricVcenterClusterMemoryEffective.aggDataPoints) + assert.Empty(t, mb.metricVcenterClusterMemoryLimit.aggDataPoints) + assert.Empty(t, mb.metricVcenterClusterVMCount.aggDataPoints) + assert.Empty(t, mb.metricVcenterClusterVMTemplateCount.aggDataPoints) + assert.Empty(t, mb.metricVcenterClusterVsanCongestions.aggDataPoints) + assert.Empty(t, mb.metricVcenterClusterVsanLatencyAvg.aggDataPoints) + assert.Empty(t, mb.metricVcenterClusterVsanOperations.aggDataPoints) + assert.Empty(t, mb.metricVcenterClusterVsanThroughput.aggDataPoints) + assert.Empty(t, mb.metricVcenterDatacenterClusterCount.aggDataPoints) + assert.Empty(t, mb.metricVcenterDatacenterCPULimit.aggDataPoints) + assert.Empty(t, mb.metricVcenterDatacenterDatastoreCount.aggDataPoints) + assert.Empty(t, mb.metricVcenterDatacenterDiskSpace.aggDataPoints) + assert.Empty(t, mb.metricVcenterDatacenterHostCount.aggDataPoints) + assert.Empty(t, mb.metricVcenterDatacenterMemoryLimit.aggDataPoints) + assert.Empty(t, mb.metricVcenterDatacenterVMCount.aggDataPoints) + assert.Empty(t, mb.metricVcenterDatastoreDiskUsage.aggDataPoints) + assert.Empty(t, mb.metricVcenterDatastoreDiskUtilization.aggDataPoints) + assert.Empty(t, mb.metricVcenterHostCPUCapacity.aggDataPoints) + assert.Empty(t, mb.metricVcenterHostCPUReserved.aggDataPoints) + assert.Empty(t, mb.metricVcenterHostCPUUsage.aggDataPoints) + assert.Empty(t, mb.metricVcenterHostCPUUtilization.aggDataPoints) + assert.Empty(t, mb.metricVcenterHostDiskLatencyAvg.aggDataPoints) + assert.Empty(t, mb.metricVcenterHostDiskLatencyMax.aggDataPoints) + assert.Empty(t, mb.metricVcenterHostDiskThroughput.aggDataPoints) + assert.Empty(t, mb.metricVcenterHostMemoryCapacity.aggDataPoints) + assert.Empty(t, mb.metricVcenterHostMemoryUsage.aggDataPoints) + assert.Empty(t, mb.metricVcenterHostMemoryUtilization.aggDataPoints) + assert.Empty(t, mb.metricVcenterHostNetworkPacketDropRate.aggDataPoints) + assert.Empty(t, mb.metricVcenterHostNetworkPacketErrorRate.aggDataPoints) + assert.Empty(t, mb.metricVcenterHostNetworkPacketRate.aggDataPoints) + assert.Empty(t, mb.metricVcenterHostNetworkThroughput.aggDataPoints) + assert.Empty(t, mb.metricVcenterHostNetworkUsage.aggDataPoints) + assert.Empty(t, mb.metricVcenterHostVsanCacheHitRate.aggDataPoints) + assert.Empty(t, mb.metricVcenterHostVsanCongestions.aggDataPoints) + assert.Empty(t, mb.metricVcenterHostVsanLatencyAvg.aggDataPoints) + assert.Empty(t, mb.metricVcenterHostVsanOperations.aggDataPoints) + assert.Empty(t, mb.metricVcenterHostVsanThroughput.aggDataPoints) + assert.Empty(t, mb.metricVcenterResourcePoolCPUShares.aggDataPoints) + assert.Empty(t, mb.metricVcenterResourcePoolCPUUsage.aggDataPoints) + assert.Empty(t, mb.metricVcenterResourcePoolMemoryBallooned.aggDataPoints) + assert.Empty(t, mb.metricVcenterResourcePoolMemoryGranted.aggDataPoints) + assert.Empty(t, mb.metricVcenterResourcePoolMemoryShares.aggDataPoints) + assert.Empty(t, mb.metricVcenterResourcePoolMemorySwapped.aggDataPoints) + assert.Empty(t, mb.metricVcenterResourcePoolMemoryUsage.aggDataPoints) + assert.Empty(t, mb.metricVcenterVMCPUReadiness.aggDataPoints) + assert.Empty(t, mb.metricVcenterVMCPUTime.aggDataPoints) + assert.Empty(t, mb.metricVcenterVMCPUUsage.aggDataPoints) + assert.Empty(t, mb.metricVcenterVMCPUUtilization.aggDataPoints) + assert.Empty(t, mb.metricVcenterVMDiskLatencyAvg.aggDataPoints) + assert.Empty(t, mb.metricVcenterVMDiskLatencyMax.aggDataPoints) + assert.Empty(t, mb.metricVcenterVMDiskThroughput.aggDataPoints) + assert.Empty(t, mb.metricVcenterVMDiskUsage.aggDataPoints) + assert.Empty(t, mb.metricVcenterVMDiskUtilization.aggDataPoints) + assert.Empty(t, mb.metricVcenterVMMemoryBallooned.aggDataPoints) + assert.Empty(t, mb.metricVcenterVMMemoryGranted.aggDataPoints) + assert.Empty(t, mb.metricVcenterVMMemorySwapped.aggDataPoints) + assert.Empty(t, mb.metricVcenterVMMemorySwappedSsd.aggDataPoints) + assert.Empty(t, mb.metricVcenterVMMemoryUsage.aggDataPoints) + assert.Empty(t, mb.metricVcenterVMMemoryUtilization.aggDataPoints) + assert.Empty(t, mb.metricVcenterVMNetworkBroadcastPacketRate.aggDataPoints) + assert.Empty(t, mb.metricVcenterVMNetworkMulticastPacketRate.aggDataPoints) + assert.Empty(t, mb.metricVcenterVMNetworkPacketDropRate.aggDataPoints) + assert.Empty(t, mb.metricVcenterVMNetworkPacketRate.aggDataPoints) + assert.Empty(t, mb.metricVcenterVMNetworkThroughput.aggDataPoints) + assert.Empty(t, mb.metricVcenterVMNetworkUsage.aggDataPoints) + assert.Empty(t, mb.metricVcenterVMVsanLatencyAvg.aggDataPoints) + assert.Empty(t, mb.metricVcenterVMVsanOperations.aggDataPoints) + assert.Empty(t, mb.metricVcenterVMVsanThroughput.aggDataPoints) + } if tt.expectEmpty { assert.Equal(t, 0, metrics.ResourceMetrics().Len()) @@ -382,1100 +748,2921 @@ func TestMetricsBuilder(t *testing.T) { for i := 0; i < ms.Len(); i++ { switch ms.At(i).Name() { case "vcenter.cluster.cpu.effective": - assert.False(t, validatedMetrics["vcenter.cluster.cpu.effective"], "Found a duplicate in the metrics slice: vcenter.cluster.cpu.effective") - validatedMetrics["vcenter.cluster.cpu.effective"] = true - assert.Equal(t, pmetric.MetricTypeSum, ms.At(i).Type()) - assert.Equal(t, 1, ms.At(i).Sum().DataPoints().Len()) - assert.Equal(t, "The effective CPU available to the cluster. This value excludes CPU from hosts in maintenance mode or are unresponsive.", ms.At(i).Description()) - assert.Equal(t, "MHz", ms.At(i).Unit()) - assert.False(t, ms.At(i).Sum().IsMonotonic()) - assert.Equal(t, pmetric.AggregationTemporalityCumulative, ms.At(i).Sum().AggregationTemporality()) - dp := ms.At(i).Sum().DataPoints().At(0) - assert.Equal(t, start, dp.StartTimestamp()) - assert.Equal(t, ts, dp.Timestamp()) - assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) - assert.Equal(t, int64(1), dp.IntValue()) + if tt.name != "reaggregate_set" { + assert.False(t, validatedMetrics["vcenter.cluster.cpu.effective"], "Found a duplicate in the metrics slice: vcenter.cluster.cpu.effective") + validatedMetrics["vcenter.cluster.cpu.effective"] = true + assert.Equal(t, pmetric.MetricTypeSum, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Sum().DataPoints().Len()) + assert.Equal(t, "The effective CPU available to the cluster. This value excludes CPU from hosts in maintenance mode or are unresponsive.", ms.At(i).Description()) + assert.Equal(t, "MHz", ms.At(i).Unit()) + assert.False(t, ms.At(i).Sum().IsMonotonic()) + assert.Equal(t, pmetric.AggregationTemporalityCumulative, ms.At(i).Sum().AggregationTemporality()) + dp := ms.At(i).Sum().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) + assert.Equal(t, int64(1), dp.IntValue()) + } else { + assert.False(t, validatedMetrics["vcenter.cluster.cpu.effective"], "Found a duplicate in the metrics slice: vcenter.cluster.cpu.effective") + validatedMetrics["vcenter.cluster.cpu.effective"] = true + assert.Equal(t, pmetric.MetricTypeSum, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Sum().DataPoints().Len()) + assert.Equal(t, "The effective CPU available to the cluster. This value excludes CPU from hosts in maintenance mode or are unresponsive.", ms.At(i).Description()) + assert.Equal(t, "MHz", ms.At(i).Unit()) + assert.False(t, ms.At(i).Sum().IsMonotonic()) + assert.Equal(t, pmetric.AggregationTemporalityCumulative, ms.At(i).Sum().AggregationTemporality()) + dp := ms.At(i).Sum().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) + switch aggMap["vcenter.cluster.cpu.effective"] { + case "sum": + assert.Equal(t, int64(4), dp.IntValue()) + case "avg": + assert.Equal(t, int64(2), dp.IntValue()) + case "min": + assert.Equal(t, int64(1), dp.IntValue()) + case "max": + assert.Equal(t, int64(3), dp.IntValue()) + } + } case "vcenter.cluster.cpu.limit": - assert.False(t, validatedMetrics["vcenter.cluster.cpu.limit"], "Found a duplicate in the metrics slice: vcenter.cluster.cpu.limit") - validatedMetrics["vcenter.cluster.cpu.limit"] = true - assert.Equal(t, pmetric.MetricTypeSum, ms.At(i).Type()) - assert.Equal(t, 1, ms.At(i).Sum().DataPoints().Len()) - assert.Equal(t, "The amount of CPU available to the cluster.", ms.At(i).Description()) - assert.Equal(t, "MHz", ms.At(i).Unit()) - assert.False(t, ms.At(i).Sum().IsMonotonic()) - assert.Equal(t, pmetric.AggregationTemporalityCumulative, ms.At(i).Sum().AggregationTemporality()) - dp := ms.At(i).Sum().DataPoints().At(0) - assert.Equal(t, start, dp.StartTimestamp()) - assert.Equal(t, ts, dp.Timestamp()) - assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) - assert.Equal(t, int64(1), dp.IntValue()) + if tt.name != "reaggregate_set" { + assert.False(t, validatedMetrics["vcenter.cluster.cpu.limit"], "Found a duplicate in the metrics slice: vcenter.cluster.cpu.limit") + validatedMetrics["vcenter.cluster.cpu.limit"] = true + assert.Equal(t, pmetric.MetricTypeSum, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Sum().DataPoints().Len()) + assert.Equal(t, "The amount of CPU available to the cluster.", ms.At(i).Description()) + assert.Equal(t, "MHz", ms.At(i).Unit()) + assert.False(t, ms.At(i).Sum().IsMonotonic()) + assert.Equal(t, pmetric.AggregationTemporalityCumulative, ms.At(i).Sum().AggregationTemporality()) + dp := ms.At(i).Sum().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) + assert.Equal(t, int64(1), dp.IntValue()) + } else { + assert.False(t, validatedMetrics["vcenter.cluster.cpu.limit"], "Found a duplicate in the metrics slice: vcenter.cluster.cpu.limit") + validatedMetrics["vcenter.cluster.cpu.limit"] = true + assert.Equal(t, pmetric.MetricTypeSum, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Sum().DataPoints().Len()) + assert.Equal(t, "The amount of CPU available to the cluster.", ms.At(i).Description()) + assert.Equal(t, "MHz", ms.At(i).Unit()) + assert.False(t, ms.At(i).Sum().IsMonotonic()) + assert.Equal(t, pmetric.AggregationTemporalityCumulative, ms.At(i).Sum().AggregationTemporality()) + dp := ms.At(i).Sum().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) + switch aggMap["vcenter.cluster.cpu.limit"] { + case "sum": + assert.Equal(t, int64(4), dp.IntValue()) + case "avg": + assert.Equal(t, int64(2), dp.IntValue()) + case "min": + assert.Equal(t, int64(1), dp.IntValue()) + case "max": + assert.Equal(t, int64(3), dp.IntValue()) + } + } case "vcenter.cluster.host.count": - assert.False(t, validatedMetrics["vcenter.cluster.host.count"], "Found a duplicate in the metrics slice: vcenter.cluster.host.count") - validatedMetrics["vcenter.cluster.host.count"] = true - assert.Equal(t, pmetric.MetricTypeSum, ms.At(i).Type()) - assert.Equal(t, 1, ms.At(i).Sum().DataPoints().Len()) - assert.Equal(t, "The number of hosts in the cluster.", ms.At(i).Description()) - assert.Equal(t, "{hosts}", ms.At(i).Unit()) - assert.False(t, ms.At(i).Sum().IsMonotonic()) - assert.Equal(t, pmetric.AggregationTemporalityCumulative, ms.At(i).Sum().AggregationTemporality()) - dp := ms.At(i).Sum().DataPoints().At(0) - assert.Equal(t, start, dp.StartTimestamp()) - assert.Equal(t, ts, dp.Timestamp()) - assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) - assert.Equal(t, int64(1), dp.IntValue()) - attrVal, ok := dp.Attributes().Get("effective") - assert.True(t, ok) - assert.True(t, attrVal.Bool()) + if tt.name != "reaggregate_set" { + assert.False(t, validatedMetrics["vcenter.cluster.host.count"], "Found a duplicate in the metrics slice: vcenter.cluster.host.count") + validatedMetrics["vcenter.cluster.host.count"] = true + assert.Equal(t, pmetric.MetricTypeSum, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Sum().DataPoints().Len()) + assert.Equal(t, "The number of hosts in the cluster.", ms.At(i).Description()) + assert.Equal(t, "{hosts}", ms.At(i).Unit()) + assert.False(t, ms.At(i).Sum().IsMonotonic()) + assert.Equal(t, pmetric.AggregationTemporalityCumulative, ms.At(i).Sum().AggregationTemporality()) + dp := ms.At(i).Sum().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) + assert.Equal(t, int64(1), dp.IntValue()) + attrVal, ok := dp.Attributes().Get("effective") + assert.True(t, ok) + assert.True(t, attrVal.Bool()) + } else { + assert.False(t, validatedMetrics["vcenter.cluster.host.count"], "Found a duplicate in the metrics slice: vcenter.cluster.host.count") + validatedMetrics["vcenter.cluster.host.count"] = true + assert.Equal(t, pmetric.MetricTypeSum, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Sum().DataPoints().Len()) + assert.Equal(t, "The number of hosts in the cluster.", ms.At(i).Description()) + assert.Equal(t, "{hosts}", ms.At(i).Unit()) + assert.False(t, ms.At(i).Sum().IsMonotonic()) + assert.Equal(t, pmetric.AggregationTemporalityCumulative, ms.At(i).Sum().AggregationTemporality()) + dp := ms.At(i).Sum().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) + switch aggMap["vcenter.cluster.host.count"] { + case "sum": + assert.Equal(t, int64(4), dp.IntValue()) + case "avg": + assert.Equal(t, int64(2), dp.IntValue()) + case "min": + assert.Equal(t, int64(1), dp.IntValue()) + case "max": + assert.Equal(t, int64(3), dp.IntValue()) + } + _, ok := dp.Attributes().Get("effective") + assert.False(t, ok) + } case "vcenter.cluster.memory.effective": - assert.False(t, validatedMetrics["vcenter.cluster.memory.effective"], "Found a duplicate in the metrics slice: vcenter.cluster.memory.effective") - validatedMetrics["vcenter.cluster.memory.effective"] = true - assert.Equal(t, pmetric.MetricTypeSum, ms.At(i).Type()) - assert.Equal(t, 1, ms.At(i).Sum().DataPoints().Len()) - assert.Equal(t, "The effective available memory of the cluster.", ms.At(i).Description()) - assert.Equal(t, "By", ms.At(i).Unit()) - assert.False(t, ms.At(i).Sum().IsMonotonic()) - assert.Equal(t, pmetric.AggregationTemporalityCumulative, ms.At(i).Sum().AggregationTemporality()) - dp := ms.At(i).Sum().DataPoints().At(0) - assert.Equal(t, start, dp.StartTimestamp()) - assert.Equal(t, ts, dp.Timestamp()) - assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) - assert.Equal(t, int64(1), dp.IntValue()) + if tt.name != "reaggregate_set" { + assert.False(t, validatedMetrics["vcenter.cluster.memory.effective"], "Found a duplicate in the metrics slice: vcenter.cluster.memory.effective") + validatedMetrics["vcenter.cluster.memory.effective"] = true + assert.Equal(t, pmetric.MetricTypeSum, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Sum().DataPoints().Len()) + assert.Equal(t, "The effective available memory of the cluster.", ms.At(i).Description()) + assert.Equal(t, "By", ms.At(i).Unit()) + assert.False(t, ms.At(i).Sum().IsMonotonic()) + assert.Equal(t, pmetric.AggregationTemporalityCumulative, ms.At(i).Sum().AggregationTemporality()) + dp := ms.At(i).Sum().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) + assert.Equal(t, int64(1), dp.IntValue()) + } else { + assert.False(t, validatedMetrics["vcenter.cluster.memory.effective"], "Found a duplicate in the metrics slice: vcenter.cluster.memory.effective") + validatedMetrics["vcenter.cluster.memory.effective"] = true + assert.Equal(t, pmetric.MetricTypeSum, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Sum().DataPoints().Len()) + assert.Equal(t, "The effective available memory of the cluster.", ms.At(i).Description()) + assert.Equal(t, "By", ms.At(i).Unit()) + assert.False(t, ms.At(i).Sum().IsMonotonic()) + assert.Equal(t, pmetric.AggregationTemporalityCumulative, ms.At(i).Sum().AggregationTemporality()) + dp := ms.At(i).Sum().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) + switch aggMap["vcenter.cluster.memory.effective"] { + case "sum": + assert.Equal(t, int64(4), dp.IntValue()) + case "avg": + assert.Equal(t, int64(2), dp.IntValue()) + case "min": + assert.Equal(t, int64(1), dp.IntValue()) + case "max": + assert.Equal(t, int64(3), dp.IntValue()) + } + } case "vcenter.cluster.memory.limit": - assert.False(t, validatedMetrics["vcenter.cluster.memory.limit"], "Found a duplicate in the metrics slice: vcenter.cluster.memory.limit") - validatedMetrics["vcenter.cluster.memory.limit"] = true - assert.Equal(t, pmetric.MetricTypeSum, ms.At(i).Type()) - assert.Equal(t, 1, ms.At(i).Sum().DataPoints().Len()) - assert.Equal(t, "The available memory of the cluster.", ms.At(i).Description()) - assert.Equal(t, "By", ms.At(i).Unit()) - assert.False(t, ms.At(i).Sum().IsMonotonic()) - assert.Equal(t, pmetric.AggregationTemporalityCumulative, ms.At(i).Sum().AggregationTemporality()) - dp := ms.At(i).Sum().DataPoints().At(0) - assert.Equal(t, start, dp.StartTimestamp()) - assert.Equal(t, ts, dp.Timestamp()) - assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) - assert.Equal(t, int64(1), dp.IntValue()) + if tt.name != "reaggregate_set" { + assert.False(t, validatedMetrics["vcenter.cluster.memory.limit"], "Found a duplicate in the metrics slice: vcenter.cluster.memory.limit") + validatedMetrics["vcenter.cluster.memory.limit"] = true + assert.Equal(t, pmetric.MetricTypeSum, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Sum().DataPoints().Len()) + assert.Equal(t, "The available memory of the cluster.", ms.At(i).Description()) + assert.Equal(t, "By", ms.At(i).Unit()) + assert.False(t, ms.At(i).Sum().IsMonotonic()) + assert.Equal(t, pmetric.AggregationTemporalityCumulative, ms.At(i).Sum().AggregationTemporality()) + dp := ms.At(i).Sum().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) + assert.Equal(t, int64(1), dp.IntValue()) + } else { + assert.False(t, validatedMetrics["vcenter.cluster.memory.limit"], "Found a duplicate in the metrics slice: vcenter.cluster.memory.limit") + validatedMetrics["vcenter.cluster.memory.limit"] = true + assert.Equal(t, pmetric.MetricTypeSum, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Sum().DataPoints().Len()) + assert.Equal(t, "The available memory of the cluster.", ms.At(i).Description()) + assert.Equal(t, "By", ms.At(i).Unit()) + assert.False(t, ms.At(i).Sum().IsMonotonic()) + assert.Equal(t, pmetric.AggregationTemporalityCumulative, ms.At(i).Sum().AggregationTemporality()) + dp := ms.At(i).Sum().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) + switch aggMap["vcenter.cluster.memory.limit"] { + case "sum": + assert.Equal(t, int64(4), dp.IntValue()) + case "avg": + assert.Equal(t, int64(2), dp.IntValue()) + case "min": + assert.Equal(t, int64(1), dp.IntValue()) + case "max": + assert.Equal(t, int64(3), dp.IntValue()) + } + } case "vcenter.cluster.vm.count": - assert.False(t, validatedMetrics["vcenter.cluster.vm.count"], "Found a duplicate in the metrics slice: vcenter.cluster.vm.count") - validatedMetrics["vcenter.cluster.vm.count"] = true - assert.Equal(t, pmetric.MetricTypeSum, ms.At(i).Type()) - assert.Equal(t, 1, ms.At(i).Sum().DataPoints().Len()) - assert.Equal(t, "The number of virtual machines in the cluster.", ms.At(i).Description()) - assert.Equal(t, "{virtual_machines}", ms.At(i).Unit()) - assert.False(t, ms.At(i).Sum().IsMonotonic()) - assert.Equal(t, pmetric.AggregationTemporalityCumulative, ms.At(i).Sum().AggregationTemporality()) - dp := ms.At(i).Sum().DataPoints().At(0) - assert.Equal(t, start, dp.StartTimestamp()) - assert.Equal(t, ts, dp.Timestamp()) - assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) - assert.Equal(t, int64(1), dp.IntValue()) - attrVal, ok := dp.Attributes().Get("power_state") - assert.True(t, ok) - assert.Equal(t, "on", attrVal.Str()) + if tt.name != "reaggregate_set" { + assert.False(t, validatedMetrics["vcenter.cluster.vm.count"], "Found a duplicate in the metrics slice: vcenter.cluster.vm.count") + validatedMetrics["vcenter.cluster.vm.count"] = true + assert.Equal(t, pmetric.MetricTypeSum, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Sum().DataPoints().Len()) + assert.Equal(t, "The number of virtual machines in the cluster.", ms.At(i).Description()) + assert.Equal(t, "{virtual_machines}", ms.At(i).Unit()) + assert.False(t, ms.At(i).Sum().IsMonotonic()) + assert.Equal(t, pmetric.AggregationTemporalityCumulative, ms.At(i).Sum().AggregationTemporality()) + dp := ms.At(i).Sum().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) + assert.Equal(t, int64(1), dp.IntValue()) + attrVal, ok := dp.Attributes().Get("power_state") + assert.True(t, ok) + assert.Equal(t, "on", attrVal.Str()) + } else { + assert.False(t, validatedMetrics["vcenter.cluster.vm.count"], "Found a duplicate in the metrics slice: vcenter.cluster.vm.count") + validatedMetrics["vcenter.cluster.vm.count"] = true + assert.Equal(t, pmetric.MetricTypeSum, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Sum().DataPoints().Len()) + assert.Equal(t, "The number of virtual machines in the cluster.", ms.At(i).Description()) + assert.Equal(t, "{virtual_machines}", ms.At(i).Unit()) + assert.False(t, ms.At(i).Sum().IsMonotonic()) + assert.Equal(t, pmetric.AggregationTemporalityCumulative, ms.At(i).Sum().AggregationTemporality()) + dp := ms.At(i).Sum().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) + switch aggMap["vcenter.cluster.vm.count"] { + case "sum": + assert.Equal(t, int64(4), dp.IntValue()) + case "avg": + assert.Equal(t, int64(2), dp.IntValue()) + case "min": + assert.Equal(t, int64(1), dp.IntValue()) + case "max": + assert.Equal(t, int64(3), dp.IntValue()) + } + _, ok := dp.Attributes().Get("power_state") + assert.False(t, ok) + } case "vcenter.cluster.vm_template.count": - assert.False(t, validatedMetrics["vcenter.cluster.vm_template.count"], "Found a duplicate in the metrics slice: vcenter.cluster.vm_template.count") - validatedMetrics["vcenter.cluster.vm_template.count"] = true - assert.Equal(t, pmetric.MetricTypeSum, ms.At(i).Type()) - assert.Equal(t, 1, ms.At(i).Sum().DataPoints().Len()) - assert.Equal(t, "The number of virtual machine templates in the cluster.", ms.At(i).Description()) - assert.Equal(t, "{virtual_machine_templates}", ms.At(i).Unit()) - assert.False(t, ms.At(i).Sum().IsMonotonic()) - assert.Equal(t, pmetric.AggregationTemporalityCumulative, ms.At(i).Sum().AggregationTemporality()) - dp := ms.At(i).Sum().DataPoints().At(0) - assert.Equal(t, start, dp.StartTimestamp()) - assert.Equal(t, ts, dp.Timestamp()) - assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) - assert.Equal(t, int64(1), dp.IntValue()) + if tt.name != "reaggregate_set" { + assert.False(t, validatedMetrics["vcenter.cluster.vm_template.count"], "Found a duplicate in the metrics slice: vcenter.cluster.vm_template.count") + validatedMetrics["vcenter.cluster.vm_template.count"] = true + assert.Equal(t, pmetric.MetricTypeSum, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Sum().DataPoints().Len()) + assert.Equal(t, "The number of virtual machine templates in the cluster.", ms.At(i).Description()) + assert.Equal(t, "{virtual_machine_templates}", ms.At(i).Unit()) + assert.False(t, ms.At(i).Sum().IsMonotonic()) + assert.Equal(t, pmetric.AggregationTemporalityCumulative, ms.At(i).Sum().AggregationTemporality()) + dp := ms.At(i).Sum().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) + assert.Equal(t, int64(1), dp.IntValue()) + } else { + assert.False(t, validatedMetrics["vcenter.cluster.vm_template.count"], "Found a duplicate in the metrics slice: vcenter.cluster.vm_template.count") + validatedMetrics["vcenter.cluster.vm_template.count"] = true + assert.Equal(t, pmetric.MetricTypeSum, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Sum().DataPoints().Len()) + assert.Equal(t, "The number of virtual machine templates in the cluster.", ms.At(i).Description()) + assert.Equal(t, "{virtual_machine_templates}", ms.At(i).Unit()) + assert.False(t, ms.At(i).Sum().IsMonotonic()) + assert.Equal(t, pmetric.AggregationTemporalityCumulative, ms.At(i).Sum().AggregationTemporality()) + dp := ms.At(i).Sum().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) + switch aggMap["vcenter.cluster.vm_template.count"] { + case "sum": + assert.Equal(t, int64(4), dp.IntValue()) + case "avg": + assert.Equal(t, int64(2), dp.IntValue()) + case "min": + assert.Equal(t, int64(1), dp.IntValue()) + case "max": + assert.Equal(t, int64(3), dp.IntValue()) + } + } case "vcenter.cluster.vsan.congestions": - assert.False(t, validatedMetrics["vcenter.cluster.vsan.congestions"], "Found a duplicate in the metrics slice: vcenter.cluster.vsan.congestions") - validatedMetrics["vcenter.cluster.vsan.congestions"] = true - assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) - assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) - assert.Equal(t, "The congestions of IOs generated by all vSAN clients in the cluster.", ms.At(i).Description()) - assert.Equal(t, "{congestions/s}", ms.At(i).Unit()) - dp := ms.At(i).Gauge().DataPoints().At(0) - assert.Equal(t, start, dp.StartTimestamp()) - assert.Equal(t, ts, dp.Timestamp()) - assert.Equal(t, pmetric.NumberDataPointValueTypeDouble, dp.ValueType()) - assert.InDelta(t, float64(1), dp.DoubleValue(), 0.01) + if tt.name != "reaggregate_set" { + assert.False(t, validatedMetrics["vcenter.cluster.vsan.congestions"], "Found a duplicate in the metrics slice: vcenter.cluster.vsan.congestions") + validatedMetrics["vcenter.cluster.vsan.congestions"] = true + assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) + assert.Equal(t, "The congestions of IOs generated by all vSAN clients in the cluster.", ms.At(i).Description()) + assert.Equal(t, "{congestions/s}", ms.At(i).Unit()) + dp := ms.At(i).Gauge().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeDouble, dp.ValueType()) + assert.InDelta(t, float64(1), dp.DoubleValue(), 0.01) + } else { + assert.False(t, validatedMetrics["vcenter.cluster.vsan.congestions"], "Found a duplicate in the metrics slice: vcenter.cluster.vsan.congestions") + validatedMetrics["vcenter.cluster.vsan.congestions"] = true + assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) + assert.Equal(t, "The congestions of IOs generated by all vSAN clients in the cluster.", ms.At(i).Description()) + assert.Equal(t, "{congestions/s}", ms.At(i).Unit()) + dp := ms.At(i).Gauge().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeDouble, dp.ValueType()) + switch aggMap["vcenter.cluster.vsan.congestions"] { + case "sum": + assert.InDelta(t, float64(4), dp.DoubleValue(), 0.01) + case "avg": + assert.InDelta(t, float64(2), dp.DoubleValue(), 0.01) + case "min": + assert.InDelta(t, float64(1), dp.DoubleValue(), 0.01) + case "max": + assert.InDelta(t, float64(3), dp.DoubleValue(), 0.01) + } + } case "vcenter.cluster.vsan.latency.avg": - assert.False(t, validatedMetrics["vcenter.cluster.vsan.latency.avg"], "Found a duplicate in the metrics slice: vcenter.cluster.vsan.latency.avg") - validatedMetrics["vcenter.cluster.vsan.latency.avg"] = true - assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) - assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) - assert.Equal(t, "The overall cluster latency while accessing vSAN storage.", ms.At(i).Description()) - assert.Equal(t, "us", ms.At(i).Unit()) - dp := ms.At(i).Gauge().DataPoints().At(0) - assert.Equal(t, start, dp.StartTimestamp()) - assert.Equal(t, ts, dp.Timestamp()) - assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) - assert.Equal(t, int64(1), dp.IntValue()) - attrVal, ok := dp.Attributes().Get("type") - assert.True(t, ok) - assert.Equal(t, "read", attrVal.Str()) + if tt.name != "reaggregate_set" { + assert.False(t, validatedMetrics["vcenter.cluster.vsan.latency.avg"], "Found a duplicate in the metrics slice: vcenter.cluster.vsan.latency.avg") + validatedMetrics["vcenter.cluster.vsan.latency.avg"] = true + assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) + assert.Equal(t, "The overall cluster latency while accessing vSAN storage.", ms.At(i).Description()) + assert.Equal(t, "us", ms.At(i).Unit()) + dp := ms.At(i).Gauge().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) + assert.Equal(t, int64(1), dp.IntValue()) + attrVal, ok := dp.Attributes().Get("type") + assert.True(t, ok) + assert.Equal(t, "read", attrVal.Str()) + } else { + assert.False(t, validatedMetrics["vcenter.cluster.vsan.latency.avg"], "Found a duplicate in the metrics slice: vcenter.cluster.vsan.latency.avg") + validatedMetrics["vcenter.cluster.vsan.latency.avg"] = true + assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) + assert.Equal(t, "The overall cluster latency while accessing vSAN storage.", ms.At(i).Description()) + assert.Equal(t, "us", ms.At(i).Unit()) + dp := ms.At(i).Gauge().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) + switch aggMap["vcenter.cluster.vsan.latency.avg"] { + case "sum": + assert.Equal(t, int64(4), dp.IntValue()) + case "avg": + assert.Equal(t, int64(2), dp.IntValue()) + case "min": + assert.Equal(t, int64(1), dp.IntValue()) + case "max": + assert.Equal(t, int64(3), dp.IntValue()) + } + _, ok := dp.Attributes().Get("type") + assert.False(t, ok) + } case "vcenter.cluster.vsan.operations": - assert.False(t, validatedMetrics["vcenter.cluster.vsan.operations"], "Found a duplicate in the metrics slice: vcenter.cluster.vsan.operations") - validatedMetrics["vcenter.cluster.vsan.operations"] = true - assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) - assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) - assert.Equal(t, "The vSAN IOPs of a cluster.", ms.At(i).Description()) - assert.Equal(t, "{operations/s}", ms.At(i).Unit()) - dp := ms.At(i).Gauge().DataPoints().At(0) - assert.Equal(t, start, dp.StartTimestamp()) - assert.Equal(t, ts, dp.Timestamp()) - assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) - assert.Equal(t, int64(1), dp.IntValue()) - attrVal, ok := dp.Attributes().Get("type") - assert.True(t, ok) - assert.Equal(t, "read", attrVal.Str()) + if tt.name != "reaggregate_set" { + assert.False(t, validatedMetrics["vcenter.cluster.vsan.operations"], "Found a duplicate in the metrics slice: vcenter.cluster.vsan.operations") + validatedMetrics["vcenter.cluster.vsan.operations"] = true + assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) + assert.Equal(t, "The vSAN IOPs of a cluster.", ms.At(i).Description()) + assert.Equal(t, "{operations/s}", ms.At(i).Unit()) + dp := ms.At(i).Gauge().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) + assert.Equal(t, int64(1), dp.IntValue()) + attrVal, ok := dp.Attributes().Get("type") + assert.True(t, ok) + assert.Equal(t, "read", attrVal.Str()) + } else { + assert.False(t, validatedMetrics["vcenter.cluster.vsan.operations"], "Found a duplicate in the metrics slice: vcenter.cluster.vsan.operations") + validatedMetrics["vcenter.cluster.vsan.operations"] = true + assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) + assert.Equal(t, "The vSAN IOPs of a cluster.", ms.At(i).Description()) + assert.Equal(t, "{operations/s}", ms.At(i).Unit()) + dp := ms.At(i).Gauge().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) + switch aggMap["vcenter.cluster.vsan.operations"] { + case "sum": + assert.Equal(t, int64(4), dp.IntValue()) + case "avg": + assert.Equal(t, int64(2), dp.IntValue()) + case "min": + assert.Equal(t, int64(1), dp.IntValue()) + case "max": + assert.Equal(t, int64(3), dp.IntValue()) + } + _, ok := dp.Attributes().Get("type") + assert.False(t, ok) + } case "vcenter.cluster.vsan.throughput": - assert.False(t, validatedMetrics["vcenter.cluster.vsan.throughput"], "Found a duplicate in the metrics slice: vcenter.cluster.vsan.throughput") - validatedMetrics["vcenter.cluster.vsan.throughput"] = true - assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) - assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) - assert.Equal(t, "The vSAN throughput of a cluster.", ms.At(i).Description()) - assert.Equal(t, "By/s", ms.At(i).Unit()) - dp := ms.At(i).Gauge().DataPoints().At(0) - assert.Equal(t, start, dp.StartTimestamp()) - assert.Equal(t, ts, dp.Timestamp()) - assert.Equal(t, pmetric.NumberDataPointValueTypeDouble, dp.ValueType()) - assert.InDelta(t, float64(1), dp.DoubleValue(), 0.01) - attrVal, ok := dp.Attributes().Get("direction") - assert.True(t, ok) - assert.Equal(t, "read", attrVal.Str()) + if tt.name != "reaggregate_set" { + assert.False(t, validatedMetrics["vcenter.cluster.vsan.throughput"], "Found a duplicate in the metrics slice: vcenter.cluster.vsan.throughput") + validatedMetrics["vcenter.cluster.vsan.throughput"] = true + assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) + assert.Equal(t, "The vSAN throughput of a cluster.", ms.At(i).Description()) + assert.Equal(t, "By/s", ms.At(i).Unit()) + dp := ms.At(i).Gauge().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeDouble, dp.ValueType()) + assert.InDelta(t, float64(1), dp.DoubleValue(), 0.01) + attrVal, ok := dp.Attributes().Get("direction") + assert.True(t, ok) + assert.Equal(t, "read", attrVal.Str()) + } else { + assert.False(t, validatedMetrics["vcenter.cluster.vsan.throughput"], "Found a duplicate in the metrics slice: vcenter.cluster.vsan.throughput") + validatedMetrics["vcenter.cluster.vsan.throughput"] = true + assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) + assert.Equal(t, "The vSAN throughput of a cluster.", ms.At(i).Description()) + assert.Equal(t, "By/s", ms.At(i).Unit()) + dp := ms.At(i).Gauge().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeDouble, dp.ValueType()) + switch aggMap["vcenter.cluster.vsan.throughput"] { + case "sum": + assert.InDelta(t, float64(4), dp.DoubleValue(), 0.01) + case "avg": + assert.InDelta(t, float64(2), dp.DoubleValue(), 0.01) + case "min": + assert.InDelta(t, float64(1), dp.DoubleValue(), 0.01) + case "max": + assert.InDelta(t, float64(3), dp.DoubleValue(), 0.01) + } + _, ok := dp.Attributes().Get("direction") + assert.False(t, ok) + } case "vcenter.datacenter.cluster.count": - assert.False(t, validatedMetrics["vcenter.datacenter.cluster.count"], "Found a duplicate in the metrics slice: vcenter.datacenter.cluster.count") - validatedMetrics["vcenter.datacenter.cluster.count"] = true - assert.Equal(t, pmetric.MetricTypeSum, ms.At(i).Type()) - assert.Equal(t, 1, ms.At(i).Sum().DataPoints().Len()) - assert.Equal(t, "The number of clusters in the datacenter.", ms.At(i).Description()) - assert.Equal(t, "{clusters}", ms.At(i).Unit()) - assert.False(t, ms.At(i).Sum().IsMonotonic()) - assert.Equal(t, pmetric.AggregationTemporalityCumulative, ms.At(i).Sum().AggregationTemporality()) - dp := ms.At(i).Sum().DataPoints().At(0) - assert.Equal(t, start, dp.StartTimestamp()) - assert.Equal(t, ts, dp.Timestamp()) - assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) - assert.Equal(t, int64(1), dp.IntValue()) - attrVal, ok := dp.Attributes().Get("status") - assert.True(t, ok) - assert.Equal(t, "red", attrVal.Str()) + if tt.name != "reaggregate_set" { + assert.False(t, validatedMetrics["vcenter.datacenter.cluster.count"], "Found a duplicate in the metrics slice: vcenter.datacenter.cluster.count") + validatedMetrics["vcenter.datacenter.cluster.count"] = true + assert.Equal(t, pmetric.MetricTypeSum, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Sum().DataPoints().Len()) + assert.Equal(t, "The number of clusters in the datacenter.", ms.At(i).Description()) + assert.Equal(t, "{clusters}", ms.At(i).Unit()) + assert.False(t, ms.At(i).Sum().IsMonotonic()) + assert.Equal(t, pmetric.AggregationTemporalityCumulative, ms.At(i).Sum().AggregationTemporality()) + dp := ms.At(i).Sum().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) + assert.Equal(t, int64(1), dp.IntValue()) + attrVal, ok := dp.Attributes().Get("status") + assert.True(t, ok) + assert.Equal(t, "red", attrVal.Str()) + } else { + assert.False(t, validatedMetrics["vcenter.datacenter.cluster.count"], "Found a duplicate in the metrics slice: vcenter.datacenter.cluster.count") + validatedMetrics["vcenter.datacenter.cluster.count"] = true + assert.Equal(t, pmetric.MetricTypeSum, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Sum().DataPoints().Len()) + assert.Equal(t, "The number of clusters in the datacenter.", ms.At(i).Description()) + assert.Equal(t, "{clusters}", ms.At(i).Unit()) + assert.False(t, ms.At(i).Sum().IsMonotonic()) + assert.Equal(t, pmetric.AggregationTemporalityCumulative, ms.At(i).Sum().AggregationTemporality()) + dp := ms.At(i).Sum().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) + switch aggMap["vcenter.datacenter.cluster.count"] { + case "sum": + assert.Equal(t, int64(4), dp.IntValue()) + case "avg": + assert.Equal(t, int64(2), dp.IntValue()) + case "min": + assert.Equal(t, int64(1), dp.IntValue()) + case "max": + assert.Equal(t, int64(3), dp.IntValue()) + } + _, ok := dp.Attributes().Get("status") + assert.False(t, ok) + } case "vcenter.datacenter.cpu.limit": - assert.False(t, validatedMetrics["vcenter.datacenter.cpu.limit"], "Found a duplicate in the metrics slice: vcenter.datacenter.cpu.limit") - validatedMetrics["vcenter.datacenter.cpu.limit"] = true - assert.Equal(t, pmetric.MetricTypeSum, ms.At(i).Type()) - assert.Equal(t, 1, ms.At(i).Sum().DataPoints().Len()) - assert.Equal(t, "The total amount of CPU available to the datacenter.", ms.At(i).Description()) - assert.Equal(t, "MHz", ms.At(i).Unit()) - assert.False(t, ms.At(i).Sum().IsMonotonic()) - assert.Equal(t, pmetric.AggregationTemporalityCumulative, ms.At(i).Sum().AggregationTemporality()) - dp := ms.At(i).Sum().DataPoints().At(0) - assert.Equal(t, start, dp.StartTimestamp()) - assert.Equal(t, ts, dp.Timestamp()) - assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) - assert.Equal(t, int64(1), dp.IntValue()) + if tt.name != "reaggregate_set" { + assert.False(t, validatedMetrics["vcenter.datacenter.cpu.limit"], "Found a duplicate in the metrics slice: vcenter.datacenter.cpu.limit") + validatedMetrics["vcenter.datacenter.cpu.limit"] = true + assert.Equal(t, pmetric.MetricTypeSum, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Sum().DataPoints().Len()) + assert.Equal(t, "The total amount of CPU available to the datacenter.", ms.At(i).Description()) + assert.Equal(t, "MHz", ms.At(i).Unit()) + assert.False(t, ms.At(i).Sum().IsMonotonic()) + assert.Equal(t, pmetric.AggregationTemporalityCumulative, ms.At(i).Sum().AggregationTemporality()) + dp := ms.At(i).Sum().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) + assert.Equal(t, int64(1), dp.IntValue()) + } else { + assert.False(t, validatedMetrics["vcenter.datacenter.cpu.limit"], "Found a duplicate in the metrics slice: vcenter.datacenter.cpu.limit") + validatedMetrics["vcenter.datacenter.cpu.limit"] = true + assert.Equal(t, pmetric.MetricTypeSum, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Sum().DataPoints().Len()) + assert.Equal(t, "The total amount of CPU available to the datacenter.", ms.At(i).Description()) + assert.Equal(t, "MHz", ms.At(i).Unit()) + assert.False(t, ms.At(i).Sum().IsMonotonic()) + assert.Equal(t, pmetric.AggregationTemporalityCumulative, ms.At(i).Sum().AggregationTemporality()) + dp := ms.At(i).Sum().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) + switch aggMap["vcenter.datacenter.cpu.limit"] { + case "sum": + assert.Equal(t, int64(4), dp.IntValue()) + case "avg": + assert.Equal(t, int64(2), dp.IntValue()) + case "min": + assert.Equal(t, int64(1), dp.IntValue()) + case "max": + assert.Equal(t, int64(3), dp.IntValue()) + } + } case "vcenter.datacenter.datastore.count": - assert.False(t, validatedMetrics["vcenter.datacenter.datastore.count"], "Found a duplicate in the metrics slice: vcenter.datacenter.datastore.count") - validatedMetrics["vcenter.datacenter.datastore.count"] = true - assert.Equal(t, pmetric.MetricTypeSum, ms.At(i).Type()) - assert.Equal(t, 1, ms.At(i).Sum().DataPoints().Len()) - assert.Equal(t, "The number of datastores in the datacenter.", ms.At(i).Description()) - assert.Equal(t, "{datastores}", ms.At(i).Unit()) - assert.False(t, ms.At(i).Sum().IsMonotonic()) - assert.Equal(t, pmetric.AggregationTemporalityCumulative, ms.At(i).Sum().AggregationTemporality()) - dp := ms.At(i).Sum().DataPoints().At(0) - assert.Equal(t, start, dp.StartTimestamp()) - assert.Equal(t, ts, dp.Timestamp()) - assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) - assert.Equal(t, int64(1), dp.IntValue()) + if tt.name != "reaggregate_set" { + assert.False(t, validatedMetrics["vcenter.datacenter.datastore.count"], "Found a duplicate in the metrics slice: vcenter.datacenter.datastore.count") + validatedMetrics["vcenter.datacenter.datastore.count"] = true + assert.Equal(t, pmetric.MetricTypeSum, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Sum().DataPoints().Len()) + assert.Equal(t, "The number of datastores in the datacenter.", ms.At(i).Description()) + assert.Equal(t, "{datastores}", ms.At(i).Unit()) + assert.False(t, ms.At(i).Sum().IsMonotonic()) + assert.Equal(t, pmetric.AggregationTemporalityCumulative, ms.At(i).Sum().AggregationTemporality()) + dp := ms.At(i).Sum().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) + assert.Equal(t, int64(1), dp.IntValue()) + } else { + assert.False(t, validatedMetrics["vcenter.datacenter.datastore.count"], "Found a duplicate in the metrics slice: vcenter.datacenter.datastore.count") + validatedMetrics["vcenter.datacenter.datastore.count"] = true + assert.Equal(t, pmetric.MetricTypeSum, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Sum().DataPoints().Len()) + assert.Equal(t, "The number of datastores in the datacenter.", ms.At(i).Description()) + assert.Equal(t, "{datastores}", ms.At(i).Unit()) + assert.False(t, ms.At(i).Sum().IsMonotonic()) + assert.Equal(t, pmetric.AggregationTemporalityCumulative, ms.At(i).Sum().AggregationTemporality()) + dp := ms.At(i).Sum().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) + switch aggMap["vcenter.datacenter.datastore.count"] { + case "sum": + assert.Equal(t, int64(4), dp.IntValue()) + case "avg": + assert.Equal(t, int64(2), dp.IntValue()) + case "min": + assert.Equal(t, int64(1), dp.IntValue()) + case "max": + assert.Equal(t, int64(3), dp.IntValue()) + } + } case "vcenter.datacenter.disk.space": - assert.False(t, validatedMetrics["vcenter.datacenter.disk.space"], "Found a duplicate in the metrics slice: vcenter.datacenter.disk.space") - validatedMetrics["vcenter.datacenter.disk.space"] = true - assert.Equal(t, pmetric.MetricTypeSum, ms.At(i).Type()) - assert.Equal(t, 1, ms.At(i).Sum().DataPoints().Len()) - assert.Equal(t, "The amount of available and used disk space in the datacenter.", ms.At(i).Description()) - assert.Equal(t, "By", ms.At(i).Unit()) - assert.False(t, ms.At(i).Sum().IsMonotonic()) - assert.Equal(t, pmetric.AggregationTemporalityCumulative, ms.At(i).Sum().AggregationTemporality()) - dp := ms.At(i).Sum().DataPoints().At(0) - assert.Equal(t, start, dp.StartTimestamp()) - assert.Equal(t, ts, dp.Timestamp()) - assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) - assert.Equal(t, int64(1), dp.IntValue()) - attrVal, ok := dp.Attributes().Get("disk_state") - assert.True(t, ok) - assert.Equal(t, "available", attrVal.Str()) + if tt.name != "reaggregate_set" { + assert.False(t, validatedMetrics["vcenter.datacenter.disk.space"], "Found a duplicate in the metrics slice: vcenter.datacenter.disk.space") + validatedMetrics["vcenter.datacenter.disk.space"] = true + assert.Equal(t, pmetric.MetricTypeSum, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Sum().DataPoints().Len()) + assert.Equal(t, "The amount of available and used disk space in the datacenter.", ms.At(i).Description()) + assert.Equal(t, "By", ms.At(i).Unit()) + assert.False(t, ms.At(i).Sum().IsMonotonic()) + assert.Equal(t, pmetric.AggregationTemporalityCumulative, ms.At(i).Sum().AggregationTemporality()) + dp := ms.At(i).Sum().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) + assert.Equal(t, int64(1), dp.IntValue()) + attrVal, ok := dp.Attributes().Get("disk_state") + assert.True(t, ok) + assert.Equal(t, "available", attrVal.Str()) + } else { + assert.False(t, validatedMetrics["vcenter.datacenter.disk.space"], "Found a duplicate in the metrics slice: vcenter.datacenter.disk.space") + validatedMetrics["vcenter.datacenter.disk.space"] = true + assert.Equal(t, pmetric.MetricTypeSum, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Sum().DataPoints().Len()) + assert.Equal(t, "The amount of available and used disk space in the datacenter.", ms.At(i).Description()) + assert.Equal(t, "By", ms.At(i).Unit()) + assert.False(t, ms.At(i).Sum().IsMonotonic()) + assert.Equal(t, pmetric.AggregationTemporalityCumulative, ms.At(i).Sum().AggregationTemporality()) + dp := ms.At(i).Sum().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) + switch aggMap["vcenter.datacenter.disk.space"] { + case "sum": + assert.Equal(t, int64(4), dp.IntValue()) + case "avg": + assert.Equal(t, int64(2), dp.IntValue()) + case "min": + assert.Equal(t, int64(1), dp.IntValue()) + case "max": + assert.Equal(t, int64(3), dp.IntValue()) + } + _, ok := dp.Attributes().Get("disk_state") + assert.False(t, ok) + } case "vcenter.datacenter.host.count": - assert.False(t, validatedMetrics["vcenter.datacenter.host.count"], "Found a duplicate in the metrics slice: vcenter.datacenter.host.count") - validatedMetrics["vcenter.datacenter.host.count"] = true - assert.Equal(t, pmetric.MetricTypeSum, ms.At(i).Type()) - assert.Equal(t, 1, ms.At(i).Sum().DataPoints().Len()) - assert.Equal(t, "The number of hosts in the datacenter.", ms.At(i).Description()) - assert.Equal(t, "{hosts}", ms.At(i).Unit()) - assert.False(t, ms.At(i).Sum().IsMonotonic()) - assert.Equal(t, pmetric.AggregationTemporalityCumulative, ms.At(i).Sum().AggregationTemporality()) - dp := ms.At(i).Sum().DataPoints().At(0) - assert.Equal(t, start, dp.StartTimestamp()) - assert.Equal(t, ts, dp.Timestamp()) - assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) - assert.Equal(t, int64(1), dp.IntValue()) - attrVal, ok := dp.Attributes().Get("status") - assert.True(t, ok) - assert.Equal(t, "red", attrVal.Str()) - attrVal, ok = dp.Attributes().Get("power_state") - assert.True(t, ok) - assert.Equal(t, "on", attrVal.Str()) + if tt.name != "reaggregate_set" { + assert.False(t, validatedMetrics["vcenter.datacenter.host.count"], "Found a duplicate in the metrics slice: vcenter.datacenter.host.count") + validatedMetrics["vcenter.datacenter.host.count"] = true + assert.Equal(t, pmetric.MetricTypeSum, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Sum().DataPoints().Len()) + assert.Equal(t, "The number of hosts in the datacenter.", ms.At(i).Description()) + assert.Equal(t, "{hosts}", ms.At(i).Unit()) + assert.False(t, ms.At(i).Sum().IsMonotonic()) + assert.Equal(t, pmetric.AggregationTemporalityCumulative, ms.At(i).Sum().AggregationTemporality()) + dp := ms.At(i).Sum().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) + assert.Equal(t, int64(1), dp.IntValue()) + attrVal, ok := dp.Attributes().Get("status") + assert.True(t, ok) + assert.Equal(t, "red", attrVal.Str()) + attrVal, ok = dp.Attributes().Get("power_state") + assert.True(t, ok) + assert.Equal(t, "on", attrVal.Str()) + } else { + assert.False(t, validatedMetrics["vcenter.datacenter.host.count"], "Found a duplicate in the metrics slice: vcenter.datacenter.host.count") + validatedMetrics["vcenter.datacenter.host.count"] = true + assert.Equal(t, pmetric.MetricTypeSum, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Sum().DataPoints().Len()) + assert.Equal(t, "The number of hosts in the datacenter.", ms.At(i).Description()) + assert.Equal(t, "{hosts}", ms.At(i).Unit()) + assert.False(t, ms.At(i).Sum().IsMonotonic()) + assert.Equal(t, pmetric.AggregationTemporalityCumulative, ms.At(i).Sum().AggregationTemporality()) + dp := ms.At(i).Sum().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) + switch aggMap["vcenter.datacenter.host.count"] { + case "sum": + assert.Equal(t, int64(4), dp.IntValue()) + case "avg": + assert.Equal(t, int64(2), dp.IntValue()) + case "min": + assert.Equal(t, int64(1), dp.IntValue()) + case "max": + assert.Equal(t, int64(3), dp.IntValue()) + } + _, ok := dp.Attributes().Get("status") + assert.False(t, ok) + _, ok = dp.Attributes().Get("power_state") + assert.False(t, ok) + } case "vcenter.datacenter.memory.limit": - assert.False(t, validatedMetrics["vcenter.datacenter.memory.limit"], "Found a duplicate in the metrics slice: vcenter.datacenter.memory.limit") - validatedMetrics["vcenter.datacenter.memory.limit"] = true - assert.Equal(t, pmetric.MetricTypeSum, ms.At(i).Type()) - assert.Equal(t, 1, ms.At(i).Sum().DataPoints().Len()) - assert.Equal(t, "The total amount of memory available to the datacenter.", ms.At(i).Description()) - assert.Equal(t, "By", ms.At(i).Unit()) - assert.False(t, ms.At(i).Sum().IsMonotonic()) - assert.Equal(t, pmetric.AggregationTemporalityCumulative, ms.At(i).Sum().AggregationTemporality()) - dp := ms.At(i).Sum().DataPoints().At(0) - assert.Equal(t, start, dp.StartTimestamp()) - assert.Equal(t, ts, dp.Timestamp()) - assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) - assert.Equal(t, int64(1), dp.IntValue()) + if tt.name != "reaggregate_set" { + assert.False(t, validatedMetrics["vcenter.datacenter.memory.limit"], "Found a duplicate in the metrics slice: vcenter.datacenter.memory.limit") + validatedMetrics["vcenter.datacenter.memory.limit"] = true + assert.Equal(t, pmetric.MetricTypeSum, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Sum().DataPoints().Len()) + assert.Equal(t, "The total amount of memory available to the datacenter.", ms.At(i).Description()) + assert.Equal(t, "By", ms.At(i).Unit()) + assert.False(t, ms.At(i).Sum().IsMonotonic()) + assert.Equal(t, pmetric.AggregationTemporalityCumulative, ms.At(i).Sum().AggregationTemporality()) + dp := ms.At(i).Sum().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) + assert.Equal(t, int64(1), dp.IntValue()) + } else { + assert.False(t, validatedMetrics["vcenter.datacenter.memory.limit"], "Found a duplicate in the metrics slice: vcenter.datacenter.memory.limit") + validatedMetrics["vcenter.datacenter.memory.limit"] = true + assert.Equal(t, pmetric.MetricTypeSum, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Sum().DataPoints().Len()) + assert.Equal(t, "The total amount of memory available to the datacenter.", ms.At(i).Description()) + assert.Equal(t, "By", ms.At(i).Unit()) + assert.False(t, ms.At(i).Sum().IsMonotonic()) + assert.Equal(t, pmetric.AggregationTemporalityCumulative, ms.At(i).Sum().AggregationTemporality()) + dp := ms.At(i).Sum().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) + switch aggMap["vcenter.datacenter.memory.limit"] { + case "sum": + assert.Equal(t, int64(4), dp.IntValue()) + case "avg": + assert.Equal(t, int64(2), dp.IntValue()) + case "min": + assert.Equal(t, int64(1), dp.IntValue()) + case "max": + assert.Equal(t, int64(3), dp.IntValue()) + } + } case "vcenter.datacenter.vm.count": - assert.False(t, validatedMetrics["vcenter.datacenter.vm.count"], "Found a duplicate in the metrics slice: vcenter.datacenter.vm.count") - validatedMetrics["vcenter.datacenter.vm.count"] = true - assert.Equal(t, pmetric.MetricTypeSum, ms.At(i).Type()) - assert.Equal(t, 1, ms.At(i).Sum().DataPoints().Len()) - assert.Equal(t, "The number of VM's in the datacenter.", ms.At(i).Description()) - assert.Equal(t, "{virtual_machines}", ms.At(i).Unit()) - assert.False(t, ms.At(i).Sum().IsMonotonic()) - assert.Equal(t, pmetric.AggregationTemporalityCumulative, ms.At(i).Sum().AggregationTemporality()) - dp := ms.At(i).Sum().DataPoints().At(0) - assert.Equal(t, start, dp.StartTimestamp()) - assert.Equal(t, ts, dp.Timestamp()) - assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) - assert.Equal(t, int64(1), dp.IntValue()) - attrVal, ok := dp.Attributes().Get("status") - assert.True(t, ok) - assert.Equal(t, "red", attrVal.Str()) - attrVal, ok = dp.Attributes().Get("power_state") - assert.True(t, ok) - assert.Equal(t, "on", attrVal.Str()) + if tt.name != "reaggregate_set" { + assert.False(t, validatedMetrics["vcenter.datacenter.vm.count"], "Found a duplicate in the metrics slice: vcenter.datacenter.vm.count") + validatedMetrics["vcenter.datacenter.vm.count"] = true + assert.Equal(t, pmetric.MetricTypeSum, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Sum().DataPoints().Len()) + assert.Equal(t, "The number of VM's in the datacenter.", ms.At(i).Description()) + assert.Equal(t, "{virtual_machines}", ms.At(i).Unit()) + assert.False(t, ms.At(i).Sum().IsMonotonic()) + assert.Equal(t, pmetric.AggregationTemporalityCumulative, ms.At(i).Sum().AggregationTemporality()) + dp := ms.At(i).Sum().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) + assert.Equal(t, int64(1), dp.IntValue()) + attrVal, ok := dp.Attributes().Get("status") + assert.True(t, ok) + assert.Equal(t, "red", attrVal.Str()) + attrVal, ok = dp.Attributes().Get("power_state") + assert.True(t, ok) + assert.Equal(t, "on", attrVal.Str()) + } else { + assert.False(t, validatedMetrics["vcenter.datacenter.vm.count"], "Found a duplicate in the metrics slice: vcenter.datacenter.vm.count") + validatedMetrics["vcenter.datacenter.vm.count"] = true + assert.Equal(t, pmetric.MetricTypeSum, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Sum().DataPoints().Len()) + assert.Equal(t, "The number of VM's in the datacenter.", ms.At(i).Description()) + assert.Equal(t, "{virtual_machines}", ms.At(i).Unit()) + assert.False(t, ms.At(i).Sum().IsMonotonic()) + assert.Equal(t, pmetric.AggregationTemporalityCumulative, ms.At(i).Sum().AggregationTemporality()) + dp := ms.At(i).Sum().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) + switch aggMap["vcenter.datacenter.vm.count"] { + case "sum": + assert.Equal(t, int64(4), dp.IntValue()) + case "avg": + assert.Equal(t, int64(2), dp.IntValue()) + case "min": + assert.Equal(t, int64(1), dp.IntValue()) + case "max": + assert.Equal(t, int64(3), dp.IntValue()) + } + _, ok := dp.Attributes().Get("status") + assert.False(t, ok) + _, ok = dp.Attributes().Get("power_state") + assert.False(t, ok) + } case "vcenter.datastore.disk.usage": - assert.False(t, validatedMetrics["vcenter.datastore.disk.usage"], "Found a duplicate in the metrics slice: vcenter.datastore.disk.usage") - validatedMetrics["vcenter.datastore.disk.usage"] = true - assert.Equal(t, pmetric.MetricTypeSum, ms.At(i).Type()) - assert.Equal(t, 1, ms.At(i).Sum().DataPoints().Len()) - assert.Equal(t, "The amount of space in the datastore.", ms.At(i).Description()) - assert.Equal(t, "By", ms.At(i).Unit()) - assert.False(t, ms.At(i).Sum().IsMonotonic()) - assert.Equal(t, pmetric.AggregationTemporalityCumulative, ms.At(i).Sum().AggregationTemporality()) - dp := ms.At(i).Sum().DataPoints().At(0) - assert.Equal(t, start, dp.StartTimestamp()) - assert.Equal(t, ts, dp.Timestamp()) - assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) - assert.Equal(t, int64(1), dp.IntValue()) - attrVal, ok := dp.Attributes().Get("disk_state") - assert.True(t, ok) - assert.Equal(t, "available", attrVal.Str()) + if tt.name != "reaggregate_set" { + assert.False(t, validatedMetrics["vcenter.datastore.disk.usage"], "Found a duplicate in the metrics slice: vcenter.datastore.disk.usage") + validatedMetrics["vcenter.datastore.disk.usage"] = true + assert.Equal(t, pmetric.MetricTypeSum, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Sum().DataPoints().Len()) + assert.Equal(t, "The amount of space in the datastore.", ms.At(i).Description()) + assert.Equal(t, "By", ms.At(i).Unit()) + assert.False(t, ms.At(i).Sum().IsMonotonic()) + assert.Equal(t, pmetric.AggregationTemporalityCumulative, ms.At(i).Sum().AggregationTemporality()) + dp := ms.At(i).Sum().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) + assert.Equal(t, int64(1), dp.IntValue()) + attrVal, ok := dp.Attributes().Get("disk_state") + assert.True(t, ok) + assert.Equal(t, "available", attrVal.Str()) + } else { + assert.False(t, validatedMetrics["vcenter.datastore.disk.usage"], "Found a duplicate in the metrics slice: vcenter.datastore.disk.usage") + validatedMetrics["vcenter.datastore.disk.usage"] = true + assert.Equal(t, pmetric.MetricTypeSum, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Sum().DataPoints().Len()) + assert.Equal(t, "The amount of space in the datastore.", ms.At(i).Description()) + assert.Equal(t, "By", ms.At(i).Unit()) + assert.False(t, ms.At(i).Sum().IsMonotonic()) + assert.Equal(t, pmetric.AggregationTemporalityCumulative, ms.At(i).Sum().AggregationTemporality()) + dp := ms.At(i).Sum().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) + switch aggMap["vcenter.datastore.disk.usage"] { + case "sum": + assert.Equal(t, int64(4), dp.IntValue()) + case "avg": + assert.Equal(t, int64(2), dp.IntValue()) + case "min": + assert.Equal(t, int64(1), dp.IntValue()) + case "max": + assert.Equal(t, int64(3), dp.IntValue()) + } + _, ok := dp.Attributes().Get("disk_state") + assert.False(t, ok) + } case "vcenter.datastore.disk.utilization": - assert.False(t, validatedMetrics["vcenter.datastore.disk.utilization"], "Found a duplicate in the metrics slice: vcenter.datastore.disk.utilization") - validatedMetrics["vcenter.datastore.disk.utilization"] = true - assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) - assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) - assert.Equal(t, "The utilization of the datastore.", ms.At(i).Description()) - assert.Equal(t, "%", ms.At(i).Unit()) - dp := ms.At(i).Gauge().DataPoints().At(0) - assert.Equal(t, start, dp.StartTimestamp()) - assert.Equal(t, ts, dp.Timestamp()) - assert.Equal(t, pmetric.NumberDataPointValueTypeDouble, dp.ValueType()) - assert.InDelta(t, float64(1), dp.DoubleValue(), 0.01) + if tt.name != "reaggregate_set" { + assert.False(t, validatedMetrics["vcenter.datastore.disk.utilization"], "Found a duplicate in the metrics slice: vcenter.datastore.disk.utilization") + validatedMetrics["vcenter.datastore.disk.utilization"] = true + assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) + assert.Equal(t, "The utilization of the datastore.", ms.At(i).Description()) + assert.Equal(t, "%", ms.At(i).Unit()) + dp := ms.At(i).Gauge().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeDouble, dp.ValueType()) + assert.InDelta(t, float64(1), dp.DoubleValue(), 0.01) + } else { + assert.False(t, validatedMetrics["vcenter.datastore.disk.utilization"], "Found a duplicate in the metrics slice: vcenter.datastore.disk.utilization") + validatedMetrics["vcenter.datastore.disk.utilization"] = true + assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) + assert.Equal(t, "The utilization of the datastore.", ms.At(i).Description()) + assert.Equal(t, "%", ms.At(i).Unit()) + dp := ms.At(i).Gauge().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeDouble, dp.ValueType()) + switch aggMap["vcenter.datastore.disk.utilization"] { + case "sum": + assert.InDelta(t, float64(4), dp.DoubleValue(), 0.01) + case "avg": + assert.InDelta(t, float64(2), dp.DoubleValue(), 0.01) + case "min": + assert.InDelta(t, float64(1), dp.DoubleValue(), 0.01) + case "max": + assert.InDelta(t, float64(3), dp.DoubleValue(), 0.01) + } + } case "vcenter.host.cpu.capacity": - assert.False(t, validatedMetrics["vcenter.host.cpu.capacity"], "Found a duplicate in the metrics slice: vcenter.host.cpu.capacity") - validatedMetrics["vcenter.host.cpu.capacity"] = true - assert.Equal(t, pmetric.MetricTypeSum, ms.At(i).Type()) - assert.Equal(t, 1, ms.At(i).Sum().DataPoints().Len()) - assert.Equal(t, "Total CPU capacity of the host system.", ms.At(i).Description()) - assert.Equal(t, "MHz", ms.At(i).Unit()) - assert.False(t, ms.At(i).Sum().IsMonotonic()) - assert.Equal(t, pmetric.AggregationTemporalityCumulative, ms.At(i).Sum().AggregationTemporality()) - dp := ms.At(i).Sum().DataPoints().At(0) - assert.Equal(t, start, dp.StartTimestamp()) - assert.Equal(t, ts, dp.Timestamp()) - assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) - assert.Equal(t, int64(1), dp.IntValue()) + if tt.name != "reaggregate_set" { + assert.False(t, validatedMetrics["vcenter.host.cpu.capacity"], "Found a duplicate in the metrics slice: vcenter.host.cpu.capacity") + validatedMetrics["vcenter.host.cpu.capacity"] = true + assert.Equal(t, pmetric.MetricTypeSum, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Sum().DataPoints().Len()) + assert.Equal(t, "Total CPU capacity of the host system.", ms.At(i).Description()) + assert.Equal(t, "MHz", ms.At(i).Unit()) + assert.False(t, ms.At(i).Sum().IsMonotonic()) + assert.Equal(t, pmetric.AggregationTemporalityCumulative, ms.At(i).Sum().AggregationTemporality()) + dp := ms.At(i).Sum().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) + assert.Equal(t, int64(1), dp.IntValue()) + } else { + assert.False(t, validatedMetrics["vcenter.host.cpu.capacity"], "Found a duplicate in the metrics slice: vcenter.host.cpu.capacity") + validatedMetrics["vcenter.host.cpu.capacity"] = true + assert.Equal(t, pmetric.MetricTypeSum, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Sum().DataPoints().Len()) + assert.Equal(t, "Total CPU capacity of the host system.", ms.At(i).Description()) + assert.Equal(t, "MHz", ms.At(i).Unit()) + assert.False(t, ms.At(i).Sum().IsMonotonic()) + assert.Equal(t, pmetric.AggregationTemporalityCumulative, ms.At(i).Sum().AggregationTemporality()) + dp := ms.At(i).Sum().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) + switch aggMap["vcenter.host.cpu.capacity"] { + case "sum": + assert.Equal(t, int64(4), dp.IntValue()) + case "avg": + assert.Equal(t, int64(2), dp.IntValue()) + case "min": + assert.Equal(t, int64(1), dp.IntValue()) + case "max": + assert.Equal(t, int64(3), dp.IntValue()) + } + } case "vcenter.host.cpu.reserved": - assert.False(t, validatedMetrics["vcenter.host.cpu.reserved"], "Found a duplicate in the metrics slice: vcenter.host.cpu.reserved") - validatedMetrics["vcenter.host.cpu.reserved"] = true - assert.Equal(t, pmetric.MetricTypeSum, ms.At(i).Type()) - assert.Equal(t, 1, ms.At(i).Sum().DataPoints().Len()) - assert.Equal(t, "The CPU of the host reserved for use by virtual machines.", ms.At(i).Description()) - assert.Equal(t, "MHz", ms.At(i).Unit()) - assert.False(t, ms.At(i).Sum().IsMonotonic()) - assert.Equal(t, pmetric.AggregationTemporalityCumulative, ms.At(i).Sum().AggregationTemporality()) - dp := ms.At(i).Sum().DataPoints().At(0) - assert.Equal(t, start, dp.StartTimestamp()) - assert.Equal(t, ts, dp.Timestamp()) - assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) - assert.Equal(t, int64(1), dp.IntValue()) - attrVal, ok := dp.Attributes().Get("cpu_reservation_type") - assert.True(t, ok) - assert.Equal(t, "total", attrVal.Str()) + if tt.name != "reaggregate_set" { + assert.False(t, validatedMetrics["vcenter.host.cpu.reserved"], "Found a duplicate in the metrics slice: vcenter.host.cpu.reserved") + validatedMetrics["vcenter.host.cpu.reserved"] = true + assert.Equal(t, pmetric.MetricTypeSum, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Sum().DataPoints().Len()) + assert.Equal(t, "The CPU of the host reserved for use by virtual machines.", ms.At(i).Description()) + assert.Equal(t, "MHz", ms.At(i).Unit()) + assert.False(t, ms.At(i).Sum().IsMonotonic()) + assert.Equal(t, pmetric.AggregationTemporalityCumulative, ms.At(i).Sum().AggregationTemporality()) + dp := ms.At(i).Sum().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) + assert.Equal(t, int64(1), dp.IntValue()) + attrVal, ok := dp.Attributes().Get("cpu_reservation_type") + assert.True(t, ok) + assert.Equal(t, "total", attrVal.Str()) + } else { + assert.False(t, validatedMetrics["vcenter.host.cpu.reserved"], "Found a duplicate in the metrics slice: vcenter.host.cpu.reserved") + validatedMetrics["vcenter.host.cpu.reserved"] = true + assert.Equal(t, pmetric.MetricTypeSum, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Sum().DataPoints().Len()) + assert.Equal(t, "The CPU of the host reserved for use by virtual machines.", ms.At(i).Description()) + assert.Equal(t, "MHz", ms.At(i).Unit()) + assert.False(t, ms.At(i).Sum().IsMonotonic()) + assert.Equal(t, pmetric.AggregationTemporalityCumulative, ms.At(i).Sum().AggregationTemporality()) + dp := ms.At(i).Sum().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) + switch aggMap["vcenter.host.cpu.reserved"] { + case "sum": + assert.Equal(t, int64(4), dp.IntValue()) + case "avg": + assert.Equal(t, int64(2), dp.IntValue()) + case "min": + assert.Equal(t, int64(1), dp.IntValue()) + case "max": + assert.Equal(t, int64(3), dp.IntValue()) + } + _, ok := dp.Attributes().Get("cpu_reservation_type") + assert.False(t, ok) + } case "vcenter.host.cpu.usage": - assert.False(t, validatedMetrics["vcenter.host.cpu.usage"], "Found a duplicate in the metrics slice: vcenter.host.cpu.usage") - validatedMetrics["vcenter.host.cpu.usage"] = true - assert.Equal(t, pmetric.MetricTypeSum, ms.At(i).Type()) - assert.Equal(t, 1, ms.At(i).Sum().DataPoints().Len()) - assert.Equal(t, "The amount of CPU used by the host.", ms.At(i).Description()) - assert.Equal(t, "MHz", ms.At(i).Unit()) - assert.False(t, ms.At(i).Sum().IsMonotonic()) - assert.Equal(t, pmetric.AggregationTemporalityCumulative, ms.At(i).Sum().AggregationTemporality()) - dp := ms.At(i).Sum().DataPoints().At(0) - assert.Equal(t, start, dp.StartTimestamp()) - assert.Equal(t, ts, dp.Timestamp()) - assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) - assert.Equal(t, int64(1), dp.IntValue()) + if tt.name != "reaggregate_set" { + assert.False(t, validatedMetrics["vcenter.host.cpu.usage"], "Found a duplicate in the metrics slice: vcenter.host.cpu.usage") + validatedMetrics["vcenter.host.cpu.usage"] = true + assert.Equal(t, pmetric.MetricTypeSum, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Sum().DataPoints().Len()) + assert.Equal(t, "The amount of CPU used by the host.", ms.At(i).Description()) + assert.Equal(t, "MHz", ms.At(i).Unit()) + assert.False(t, ms.At(i).Sum().IsMonotonic()) + assert.Equal(t, pmetric.AggregationTemporalityCumulative, ms.At(i).Sum().AggregationTemporality()) + dp := ms.At(i).Sum().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) + assert.Equal(t, int64(1), dp.IntValue()) + } else { + assert.False(t, validatedMetrics["vcenter.host.cpu.usage"], "Found a duplicate in the metrics slice: vcenter.host.cpu.usage") + validatedMetrics["vcenter.host.cpu.usage"] = true + assert.Equal(t, pmetric.MetricTypeSum, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Sum().DataPoints().Len()) + assert.Equal(t, "The amount of CPU used by the host.", ms.At(i).Description()) + assert.Equal(t, "MHz", ms.At(i).Unit()) + assert.False(t, ms.At(i).Sum().IsMonotonic()) + assert.Equal(t, pmetric.AggregationTemporalityCumulative, ms.At(i).Sum().AggregationTemporality()) + dp := ms.At(i).Sum().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) + switch aggMap["vcenter.host.cpu.usage"] { + case "sum": + assert.Equal(t, int64(4), dp.IntValue()) + case "avg": + assert.Equal(t, int64(2), dp.IntValue()) + case "min": + assert.Equal(t, int64(1), dp.IntValue()) + case "max": + assert.Equal(t, int64(3), dp.IntValue()) + } + } case "vcenter.host.cpu.utilization": - assert.False(t, validatedMetrics["vcenter.host.cpu.utilization"], "Found a duplicate in the metrics slice: vcenter.host.cpu.utilization") - validatedMetrics["vcenter.host.cpu.utilization"] = true - assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) - assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) - assert.Equal(t, "The CPU utilization of the host system.", ms.At(i).Description()) - assert.Equal(t, "%", ms.At(i).Unit()) - dp := ms.At(i).Gauge().DataPoints().At(0) - assert.Equal(t, start, dp.StartTimestamp()) - assert.Equal(t, ts, dp.Timestamp()) - assert.Equal(t, pmetric.NumberDataPointValueTypeDouble, dp.ValueType()) - assert.InDelta(t, float64(1), dp.DoubleValue(), 0.01) + if tt.name != "reaggregate_set" { + assert.False(t, validatedMetrics["vcenter.host.cpu.utilization"], "Found a duplicate in the metrics slice: vcenter.host.cpu.utilization") + validatedMetrics["vcenter.host.cpu.utilization"] = true + assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) + assert.Equal(t, "The CPU utilization of the host system.", ms.At(i).Description()) + assert.Equal(t, "%", ms.At(i).Unit()) + dp := ms.At(i).Gauge().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeDouble, dp.ValueType()) + assert.InDelta(t, float64(1), dp.DoubleValue(), 0.01) + } else { + assert.False(t, validatedMetrics["vcenter.host.cpu.utilization"], "Found a duplicate in the metrics slice: vcenter.host.cpu.utilization") + validatedMetrics["vcenter.host.cpu.utilization"] = true + assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) + assert.Equal(t, "The CPU utilization of the host system.", ms.At(i).Description()) + assert.Equal(t, "%", ms.At(i).Unit()) + dp := ms.At(i).Gauge().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeDouble, dp.ValueType()) + switch aggMap["vcenter.host.cpu.utilization"] { + case "sum": + assert.InDelta(t, float64(4), dp.DoubleValue(), 0.01) + case "avg": + assert.InDelta(t, float64(2), dp.DoubleValue(), 0.01) + case "min": + assert.InDelta(t, float64(1), dp.DoubleValue(), 0.01) + case "max": + assert.InDelta(t, float64(3), dp.DoubleValue(), 0.01) + } + } case "vcenter.host.disk.latency.avg": - assert.False(t, validatedMetrics["vcenter.host.disk.latency.avg"], "Found a duplicate in the metrics slice: vcenter.host.disk.latency.avg") - validatedMetrics["vcenter.host.disk.latency.avg"] = true - assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) - assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) - assert.Equal(t, "The latency of operations to the host system's disk.", ms.At(i).Description()) - assert.Equal(t, "ms", ms.At(i).Unit()) - dp := ms.At(i).Gauge().DataPoints().At(0) - assert.Equal(t, start, dp.StartTimestamp()) - assert.Equal(t, ts, dp.Timestamp()) - assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) - assert.Equal(t, int64(1), dp.IntValue()) - attrVal, ok := dp.Attributes().Get("direction") - assert.True(t, ok) - assert.Equal(t, "read", attrVal.Str()) - attrVal, ok = dp.Attributes().Get("object") - assert.True(t, ok) - assert.Equal(t, "object_name-val", attrVal.Str()) + if tt.name != "reaggregate_set" { + assert.False(t, validatedMetrics["vcenter.host.disk.latency.avg"], "Found a duplicate in the metrics slice: vcenter.host.disk.latency.avg") + validatedMetrics["vcenter.host.disk.latency.avg"] = true + assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) + assert.Equal(t, "The latency of operations to the host system's disk.", ms.At(i).Description()) + assert.Equal(t, "ms", ms.At(i).Unit()) + dp := ms.At(i).Gauge().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) + assert.Equal(t, int64(1), dp.IntValue()) + attrVal, ok := dp.Attributes().Get("direction") + assert.True(t, ok) + assert.Equal(t, "read", attrVal.Str()) + attrVal, ok = dp.Attributes().Get("object") + assert.True(t, ok) + assert.Equal(t, "object_name-val", attrVal.Str()) + } else { + assert.False(t, validatedMetrics["vcenter.host.disk.latency.avg"], "Found a duplicate in the metrics slice: vcenter.host.disk.latency.avg") + validatedMetrics["vcenter.host.disk.latency.avg"] = true + assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) + assert.Equal(t, "The latency of operations to the host system's disk.", ms.At(i).Description()) + assert.Equal(t, "ms", ms.At(i).Unit()) + dp := ms.At(i).Gauge().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) + switch aggMap["vcenter.host.disk.latency.avg"] { + case "sum": + assert.Equal(t, int64(4), dp.IntValue()) + case "avg": + assert.Equal(t, int64(2), dp.IntValue()) + case "min": + assert.Equal(t, int64(1), dp.IntValue()) + case "max": + assert.Equal(t, int64(3), dp.IntValue()) + } + _, ok := dp.Attributes().Get("direction") + assert.False(t, ok) + _, ok = dp.Attributes().Get("object") + assert.False(t, ok) + } case "vcenter.host.disk.latency.max": - assert.False(t, validatedMetrics["vcenter.host.disk.latency.max"], "Found a duplicate in the metrics slice: vcenter.host.disk.latency.max") - validatedMetrics["vcenter.host.disk.latency.max"] = true - assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) - assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) - assert.Equal(t, "Highest latency value across all disks used by the host.", ms.At(i).Description()) - assert.Equal(t, "ms", ms.At(i).Unit()) - dp := ms.At(i).Gauge().DataPoints().At(0) - assert.Equal(t, start, dp.StartTimestamp()) - assert.Equal(t, ts, dp.Timestamp()) - assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) - assert.Equal(t, int64(1), dp.IntValue()) - attrVal, ok := dp.Attributes().Get("object") - assert.True(t, ok) - assert.Equal(t, "object_name-val", attrVal.Str()) + if tt.name != "reaggregate_set" { + assert.False(t, validatedMetrics["vcenter.host.disk.latency.max"], "Found a duplicate in the metrics slice: vcenter.host.disk.latency.max") + validatedMetrics["vcenter.host.disk.latency.max"] = true + assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) + assert.Equal(t, "Highest latency value across all disks used by the host.", ms.At(i).Description()) + assert.Equal(t, "ms", ms.At(i).Unit()) + dp := ms.At(i).Gauge().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) + assert.Equal(t, int64(1), dp.IntValue()) + attrVal, ok := dp.Attributes().Get("object") + assert.True(t, ok) + assert.Equal(t, "object_name-val", attrVal.Str()) + } else { + assert.False(t, validatedMetrics["vcenter.host.disk.latency.max"], "Found a duplicate in the metrics slice: vcenter.host.disk.latency.max") + validatedMetrics["vcenter.host.disk.latency.max"] = true + assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) + assert.Equal(t, "Highest latency value across all disks used by the host.", ms.At(i).Description()) + assert.Equal(t, "ms", ms.At(i).Unit()) + dp := ms.At(i).Gauge().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) + switch aggMap["vcenter.host.disk.latency.max"] { + case "sum": + assert.Equal(t, int64(4), dp.IntValue()) + case "avg": + assert.Equal(t, int64(2), dp.IntValue()) + case "min": + assert.Equal(t, int64(1), dp.IntValue()) + case "max": + assert.Equal(t, int64(3), dp.IntValue()) + } + _, ok := dp.Attributes().Get("object") + assert.False(t, ok) + } case "vcenter.host.disk.throughput": - assert.False(t, validatedMetrics["vcenter.host.disk.throughput"], "Found a duplicate in the metrics slice: vcenter.host.disk.throughput") - validatedMetrics["vcenter.host.disk.throughput"] = true - assert.Equal(t, pmetric.MetricTypeSum, ms.At(i).Type()) - assert.Equal(t, 1, ms.At(i).Sum().DataPoints().Len()) - assert.Equal(t, "Average number of kilobytes read from or written to the disk each second.", ms.At(i).Description()) - assert.Equal(t, "{KiBy/s}", ms.At(i).Unit()) - assert.False(t, ms.At(i).Sum().IsMonotonic()) - assert.Equal(t, pmetric.AggregationTemporalityCumulative, ms.At(i).Sum().AggregationTemporality()) - dp := ms.At(i).Sum().DataPoints().At(0) - assert.Equal(t, start, dp.StartTimestamp()) - assert.Equal(t, ts, dp.Timestamp()) - assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) - assert.Equal(t, int64(1), dp.IntValue()) - attrVal, ok := dp.Attributes().Get("direction") - assert.True(t, ok) - assert.Equal(t, "read", attrVal.Str()) - attrVal, ok = dp.Attributes().Get("object") - assert.True(t, ok) - assert.Equal(t, "object_name-val", attrVal.Str()) + if tt.name != "reaggregate_set" { + assert.False(t, validatedMetrics["vcenter.host.disk.throughput"], "Found a duplicate in the metrics slice: vcenter.host.disk.throughput") + validatedMetrics["vcenter.host.disk.throughput"] = true + assert.Equal(t, pmetric.MetricTypeSum, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Sum().DataPoints().Len()) + assert.Equal(t, "Average number of kilobytes read from or written to the disk each second.", ms.At(i).Description()) + assert.Equal(t, "{KiBy/s}", ms.At(i).Unit()) + assert.False(t, ms.At(i).Sum().IsMonotonic()) + assert.Equal(t, pmetric.AggregationTemporalityCumulative, ms.At(i).Sum().AggregationTemporality()) + dp := ms.At(i).Sum().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) + assert.Equal(t, int64(1), dp.IntValue()) + attrVal, ok := dp.Attributes().Get("direction") + assert.True(t, ok) + assert.Equal(t, "read", attrVal.Str()) + attrVal, ok = dp.Attributes().Get("object") + assert.True(t, ok) + assert.Equal(t, "object_name-val", attrVal.Str()) + } else { + assert.False(t, validatedMetrics["vcenter.host.disk.throughput"], "Found a duplicate in the metrics slice: vcenter.host.disk.throughput") + validatedMetrics["vcenter.host.disk.throughput"] = true + assert.Equal(t, pmetric.MetricTypeSum, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Sum().DataPoints().Len()) + assert.Equal(t, "Average number of kilobytes read from or written to the disk each second.", ms.At(i).Description()) + assert.Equal(t, "{KiBy/s}", ms.At(i).Unit()) + assert.False(t, ms.At(i).Sum().IsMonotonic()) + assert.Equal(t, pmetric.AggregationTemporalityCumulative, ms.At(i).Sum().AggregationTemporality()) + dp := ms.At(i).Sum().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) + switch aggMap["vcenter.host.disk.throughput"] { + case "sum": + assert.Equal(t, int64(4), dp.IntValue()) + case "avg": + assert.Equal(t, int64(2), dp.IntValue()) + case "min": + assert.Equal(t, int64(1), dp.IntValue()) + case "max": + assert.Equal(t, int64(3), dp.IntValue()) + } + _, ok := dp.Attributes().Get("direction") + assert.False(t, ok) + _, ok = dp.Attributes().Get("object") + assert.False(t, ok) + } case "vcenter.host.memory.capacity": - assert.False(t, validatedMetrics["vcenter.host.memory.capacity"], "Found a duplicate in the metrics slice: vcenter.host.memory.capacity") - validatedMetrics["vcenter.host.memory.capacity"] = true - assert.Equal(t, pmetric.MetricTypeSum, ms.At(i).Type()) - assert.Equal(t, 1, ms.At(i).Sum().DataPoints().Len()) - assert.Equal(t, "Total memory capacity of the host system.", ms.At(i).Description()) - assert.Equal(t, "MiBy", ms.At(i).Unit()) - assert.False(t, ms.At(i).Sum().IsMonotonic()) - assert.Equal(t, pmetric.AggregationTemporalityCumulative, ms.At(i).Sum().AggregationTemporality()) - dp := ms.At(i).Sum().DataPoints().At(0) - assert.Equal(t, start, dp.StartTimestamp()) - assert.Equal(t, ts, dp.Timestamp()) - assert.Equal(t, pmetric.NumberDataPointValueTypeDouble, dp.ValueType()) - assert.InDelta(t, float64(1), dp.DoubleValue(), 0.01) + if tt.name != "reaggregate_set" { + assert.False(t, validatedMetrics["vcenter.host.memory.capacity"], "Found a duplicate in the metrics slice: vcenter.host.memory.capacity") + validatedMetrics["vcenter.host.memory.capacity"] = true + assert.Equal(t, pmetric.MetricTypeSum, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Sum().DataPoints().Len()) + assert.Equal(t, "Total memory capacity of the host system.", ms.At(i).Description()) + assert.Equal(t, "MiBy", ms.At(i).Unit()) + assert.False(t, ms.At(i).Sum().IsMonotonic()) + assert.Equal(t, pmetric.AggregationTemporalityCumulative, ms.At(i).Sum().AggregationTemporality()) + dp := ms.At(i).Sum().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeDouble, dp.ValueType()) + assert.InDelta(t, float64(1), dp.DoubleValue(), 0.01) + } else { + assert.False(t, validatedMetrics["vcenter.host.memory.capacity"], "Found a duplicate in the metrics slice: vcenter.host.memory.capacity") + validatedMetrics["vcenter.host.memory.capacity"] = true + assert.Equal(t, pmetric.MetricTypeSum, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Sum().DataPoints().Len()) + assert.Equal(t, "Total memory capacity of the host system.", ms.At(i).Description()) + assert.Equal(t, "MiBy", ms.At(i).Unit()) + assert.False(t, ms.At(i).Sum().IsMonotonic()) + assert.Equal(t, pmetric.AggregationTemporalityCumulative, ms.At(i).Sum().AggregationTemporality()) + dp := ms.At(i).Sum().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeDouble, dp.ValueType()) + switch aggMap["vcenter.host.memory.capacity"] { + case "sum": + assert.InDelta(t, float64(4), dp.DoubleValue(), 0.01) + case "avg": + assert.InDelta(t, float64(2), dp.DoubleValue(), 0.01) + case "min": + assert.InDelta(t, float64(1), dp.DoubleValue(), 0.01) + case "max": + assert.InDelta(t, float64(3), dp.DoubleValue(), 0.01) + } + } case "vcenter.host.memory.usage": - assert.False(t, validatedMetrics["vcenter.host.memory.usage"], "Found a duplicate in the metrics slice: vcenter.host.memory.usage") - validatedMetrics["vcenter.host.memory.usage"] = true - assert.Equal(t, pmetric.MetricTypeSum, ms.At(i).Type()) - assert.Equal(t, 1, ms.At(i).Sum().DataPoints().Len()) - assert.Equal(t, "The amount of memory the host system is using.", ms.At(i).Description()) - assert.Equal(t, "MiBy", ms.At(i).Unit()) - assert.False(t, ms.At(i).Sum().IsMonotonic()) - assert.Equal(t, pmetric.AggregationTemporalityCumulative, ms.At(i).Sum().AggregationTemporality()) - dp := ms.At(i).Sum().DataPoints().At(0) - assert.Equal(t, start, dp.StartTimestamp()) - assert.Equal(t, ts, dp.Timestamp()) - assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) - assert.Equal(t, int64(1), dp.IntValue()) + if tt.name != "reaggregate_set" { + assert.False(t, validatedMetrics["vcenter.host.memory.usage"], "Found a duplicate in the metrics slice: vcenter.host.memory.usage") + validatedMetrics["vcenter.host.memory.usage"] = true + assert.Equal(t, pmetric.MetricTypeSum, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Sum().DataPoints().Len()) + assert.Equal(t, "The amount of memory the host system is using.", ms.At(i).Description()) + assert.Equal(t, "MiBy", ms.At(i).Unit()) + assert.False(t, ms.At(i).Sum().IsMonotonic()) + assert.Equal(t, pmetric.AggregationTemporalityCumulative, ms.At(i).Sum().AggregationTemporality()) + dp := ms.At(i).Sum().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) + assert.Equal(t, int64(1), dp.IntValue()) + } else { + assert.False(t, validatedMetrics["vcenter.host.memory.usage"], "Found a duplicate in the metrics slice: vcenter.host.memory.usage") + validatedMetrics["vcenter.host.memory.usage"] = true + assert.Equal(t, pmetric.MetricTypeSum, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Sum().DataPoints().Len()) + assert.Equal(t, "The amount of memory the host system is using.", ms.At(i).Description()) + assert.Equal(t, "MiBy", ms.At(i).Unit()) + assert.False(t, ms.At(i).Sum().IsMonotonic()) + assert.Equal(t, pmetric.AggregationTemporalityCumulative, ms.At(i).Sum().AggregationTemporality()) + dp := ms.At(i).Sum().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) + switch aggMap["vcenter.host.memory.usage"] { + case "sum": + assert.Equal(t, int64(4), dp.IntValue()) + case "avg": + assert.Equal(t, int64(2), dp.IntValue()) + case "min": + assert.Equal(t, int64(1), dp.IntValue()) + case "max": + assert.Equal(t, int64(3), dp.IntValue()) + } + } case "vcenter.host.memory.utilization": - assert.False(t, validatedMetrics["vcenter.host.memory.utilization"], "Found a duplicate in the metrics slice: vcenter.host.memory.utilization") - validatedMetrics["vcenter.host.memory.utilization"] = true - assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) - assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) - assert.Equal(t, "The percentage of the host system's memory capacity that is being utilized.", ms.At(i).Description()) - assert.Equal(t, "%", ms.At(i).Unit()) - dp := ms.At(i).Gauge().DataPoints().At(0) - assert.Equal(t, start, dp.StartTimestamp()) - assert.Equal(t, ts, dp.Timestamp()) - assert.Equal(t, pmetric.NumberDataPointValueTypeDouble, dp.ValueType()) - assert.InDelta(t, float64(1), dp.DoubleValue(), 0.01) + if tt.name != "reaggregate_set" { + assert.False(t, validatedMetrics["vcenter.host.memory.utilization"], "Found a duplicate in the metrics slice: vcenter.host.memory.utilization") + validatedMetrics["vcenter.host.memory.utilization"] = true + assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) + assert.Equal(t, "The percentage of the host system's memory capacity that is being utilized.", ms.At(i).Description()) + assert.Equal(t, "%", ms.At(i).Unit()) + dp := ms.At(i).Gauge().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeDouble, dp.ValueType()) + assert.InDelta(t, float64(1), dp.DoubleValue(), 0.01) + } else { + assert.False(t, validatedMetrics["vcenter.host.memory.utilization"], "Found a duplicate in the metrics slice: vcenter.host.memory.utilization") + validatedMetrics["vcenter.host.memory.utilization"] = true + assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) + assert.Equal(t, "The percentage of the host system's memory capacity that is being utilized.", ms.At(i).Description()) + assert.Equal(t, "%", ms.At(i).Unit()) + dp := ms.At(i).Gauge().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeDouble, dp.ValueType()) + switch aggMap["vcenter.host.memory.utilization"] { + case "sum": + assert.InDelta(t, float64(4), dp.DoubleValue(), 0.01) + case "avg": + assert.InDelta(t, float64(2), dp.DoubleValue(), 0.01) + case "min": + assert.InDelta(t, float64(1), dp.DoubleValue(), 0.01) + case "max": + assert.InDelta(t, float64(3), dp.DoubleValue(), 0.01) + } + } case "vcenter.host.network.packet.drop.rate": - assert.False(t, validatedMetrics["vcenter.host.network.packet.drop.rate"], "Found a duplicate in the metrics slice: vcenter.host.network.packet.drop.rate") - validatedMetrics["vcenter.host.network.packet.drop.rate"] = true - assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) - assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) - assert.Equal(t, "The rate of packets dropped across each physical NIC (network interface controller) instance on the host.", ms.At(i).Description()) - assert.Equal(t, "{packets/s}", ms.At(i).Unit()) - dp := ms.At(i).Gauge().DataPoints().At(0) - assert.Equal(t, start, dp.StartTimestamp()) - assert.Equal(t, ts, dp.Timestamp()) - assert.Equal(t, pmetric.NumberDataPointValueTypeDouble, dp.ValueType()) - assert.InDelta(t, float64(1), dp.DoubleValue(), 0.01) - attrVal, ok := dp.Attributes().Get("direction") - assert.True(t, ok) - assert.Equal(t, "transmitted", attrVal.Str()) - attrVal, ok = dp.Attributes().Get("object") - assert.True(t, ok) - assert.Equal(t, "object_name-val", attrVal.Str()) + if tt.name != "reaggregate_set" { + assert.False(t, validatedMetrics["vcenter.host.network.packet.drop.rate"], "Found a duplicate in the metrics slice: vcenter.host.network.packet.drop.rate") + validatedMetrics["vcenter.host.network.packet.drop.rate"] = true + assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) + assert.Equal(t, "The rate of packets dropped across each physical NIC (network interface controller) instance on the host.", ms.At(i).Description()) + assert.Equal(t, "{packets/s}", ms.At(i).Unit()) + dp := ms.At(i).Gauge().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeDouble, dp.ValueType()) + assert.InDelta(t, float64(1), dp.DoubleValue(), 0.01) + attrVal, ok := dp.Attributes().Get("direction") + assert.True(t, ok) + assert.Equal(t, "transmitted", attrVal.Str()) + attrVal, ok = dp.Attributes().Get("object") + assert.True(t, ok) + assert.Equal(t, "object_name-val", attrVal.Str()) + } else { + assert.False(t, validatedMetrics["vcenter.host.network.packet.drop.rate"], "Found a duplicate in the metrics slice: vcenter.host.network.packet.drop.rate") + validatedMetrics["vcenter.host.network.packet.drop.rate"] = true + assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) + assert.Equal(t, "The rate of packets dropped across each physical NIC (network interface controller) instance on the host.", ms.At(i).Description()) + assert.Equal(t, "{packets/s}", ms.At(i).Unit()) + dp := ms.At(i).Gauge().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeDouble, dp.ValueType()) + switch aggMap["vcenter.host.network.packet.drop.rate"] { + case "sum": + assert.InDelta(t, float64(4), dp.DoubleValue(), 0.01) + case "avg": + assert.InDelta(t, float64(2), dp.DoubleValue(), 0.01) + case "min": + assert.InDelta(t, float64(1), dp.DoubleValue(), 0.01) + case "max": + assert.InDelta(t, float64(3), dp.DoubleValue(), 0.01) + } + _, ok := dp.Attributes().Get("direction") + assert.False(t, ok) + _, ok = dp.Attributes().Get("object") + assert.False(t, ok) + } case "vcenter.host.network.packet.error.rate": - assert.False(t, validatedMetrics["vcenter.host.network.packet.error.rate"], "Found a duplicate in the metrics slice: vcenter.host.network.packet.error.rate") - validatedMetrics["vcenter.host.network.packet.error.rate"] = true - assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) - assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) - assert.Equal(t, "The rate of packet errors transmitted or received on the host network.", ms.At(i).Description()) - assert.Equal(t, "{errors/s}", ms.At(i).Unit()) - dp := ms.At(i).Gauge().DataPoints().At(0) - assert.Equal(t, start, dp.StartTimestamp()) - assert.Equal(t, ts, dp.Timestamp()) - assert.Equal(t, pmetric.NumberDataPointValueTypeDouble, dp.ValueType()) - assert.InDelta(t, float64(1), dp.DoubleValue(), 0.01) - attrVal, ok := dp.Attributes().Get("direction") - assert.True(t, ok) - assert.Equal(t, "transmitted", attrVal.Str()) - attrVal, ok = dp.Attributes().Get("object") - assert.True(t, ok) - assert.Equal(t, "object_name-val", attrVal.Str()) + if tt.name != "reaggregate_set" { + assert.False(t, validatedMetrics["vcenter.host.network.packet.error.rate"], "Found a duplicate in the metrics slice: vcenter.host.network.packet.error.rate") + validatedMetrics["vcenter.host.network.packet.error.rate"] = true + assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) + assert.Equal(t, "The rate of packet errors transmitted or received on the host network.", ms.At(i).Description()) + assert.Equal(t, "{errors/s}", ms.At(i).Unit()) + dp := ms.At(i).Gauge().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeDouble, dp.ValueType()) + assert.InDelta(t, float64(1), dp.DoubleValue(), 0.01) + attrVal, ok := dp.Attributes().Get("direction") + assert.True(t, ok) + assert.Equal(t, "transmitted", attrVal.Str()) + attrVal, ok = dp.Attributes().Get("object") + assert.True(t, ok) + assert.Equal(t, "object_name-val", attrVal.Str()) + } else { + assert.False(t, validatedMetrics["vcenter.host.network.packet.error.rate"], "Found a duplicate in the metrics slice: vcenter.host.network.packet.error.rate") + validatedMetrics["vcenter.host.network.packet.error.rate"] = true + assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) + assert.Equal(t, "The rate of packet errors transmitted or received on the host network.", ms.At(i).Description()) + assert.Equal(t, "{errors/s}", ms.At(i).Unit()) + dp := ms.At(i).Gauge().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeDouble, dp.ValueType()) + switch aggMap["vcenter.host.network.packet.error.rate"] { + case "sum": + assert.InDelta(t, float64(4), dp.DoubleValue(), 0.01) + case "avg": + assert.InDelta(t, float64(2), dp.DoubleValue(), 0.01) + case "min": + assert.InDelta(t, float64(1), dp.DoubleValue(), 0.01) + case "max": + assert.InDelta(t, float64(3), dp.DoubleValue(), 0.01) + } + _, ok := dp.Attributes().Get("direction") + assert.False(t, ok) + _, ok = dp.Attributes().Get("object") + assert.False(t, ok) + } case "vcenter.host.network.packet.rate": - assert.False(t, validatedMetrics["vcenter.host.network.packet.rate"], "Found a duplicate in the metrics slice: vcenter.host.network.packet.rate") - validatedMetrics["vcenter.host.network.packet.rate"] = true - assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) - assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) - assert.Equal(t, "The rate of packets transmitted or received across each physical NIC (network interface controller) instance on the host.", ms.At(i).Description()) - assert.Equal(t, "{packets/s}", ms.At(i).Unit()) - dp := ms.At(i).Gauge().DataPoints().At(0) - assert.Equal(t, start, dp.StartTimestamp()) - assert.Equal(t, ts, dp.Timestamp()) - assert.Equal(t, pmetric.NumberDataPointValueTypeDouble, dp.ValueType()) - assert.InDelta(t, float64(1), dp.DoubleValue(), 0.01) - attrVal, ok := dp.Attributes().Get("direction") - assert.True(t, ok) - assert.Equal(t, "transmitted", attrVal.Str()) - attrVal, ok = dp.Attributes().Get("object") - assert.True(t, ok) - assert.Equal(t, "object_name-val", attrVal.Str()) + if tt.name != "reaggregate_set" { + assert.False(t, validatedMetrics["vcenter.host.network.packet.rate"], "Found a duplicate in the metrics slice: vcenter.host.network.packet.rate") + validatedMetrics["vcenter.host.network.packet.rate"] = true + assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) + assert.Equal(t, "The rate of packets transmitted or received across each physical NIC (network interface controller) instance on the host.", ms.At(i).Description()) + assert.Equal(t, "{packets/s}", ms.At(i).Unit()) + dp := ms.At(i).Gauge().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeDouble, dp.ValueType()) + assert.InDelta(t, float64(1), dp.DoubleValue(), 0.01) + attrVal, ok := dp.Attributes().Get("direction") + assert.True(t, ok) + assert.Equal(t, "transmitted", attrVal.Str()) + attrVal, ok = dp.Attributes().Get("object") + assert.True(t, ok) + assert.Equal(t, "object_name-val", attrVal.Str()) + } else { + assert.False(t, validatedMetrics["vcenter.host.network.packet.rate"], "Found a duplicate in the metrics slice: vcenter.host.network.packet.rate") + validatedMetrics["vcenter.host.network.packet.rate"] = true + assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) + assert.Equal(t, "The rate of packets transmitted or received across each physical NIC (network interface controller) instance on the host.", ms.At(i).Description()) + assert.Equal(t, "{packets/s}", ms.At(i).Unit()) + dp := ms.At(i).Gauge().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeDouble, dp.ValueType()) + switch aggMap["vcenter.host.network.packet.rate"] { + case "sum": + assert.InDelta(t, float64(4), dp.DoubleValue(), 0.01) + case "avg": + assert.InDelta(t, float64(2), dp.DoubleValue(), 0.01) + case "min": + assert.InDelta(t, float64(1), dp.DoubleValue(), 0.01) + case "max": + assert.InDelta(t, float64(3), dp.DoubleValue(), 0.01) + } + _, ok := dp.Attributes().Get("direction") + assert.False(t, ok) + _, ok = dp.Attributes().Get("object") + assert.False(t, ok) + } case "vcenter.host.network.throughput": - assert.False(t, validatedMetrics["vcenter.host.network.throughput"], "Found a duplicate in the metrics slice: vcenter.host.network.throughput") - validatedMetrics["vcenter.host.network.throughput"] = true - assert.Equal(t, pmetric.MetricTypeSum, ms.At(i).Type()) - assert.Equal(t, 1, ms.At(i).Sum().DataPoints().Len()) - assert.Equal(t, "The amount of data that was transmitted or received over the network by the host.", ms.At(i).Description()) - assert.Equal(t, "{KiBy/s}", ms.At(i).Unit()) - assert.False(t, ms.At(i).Sum().IsMonotonic()) - assert.Equal(t, pmetric.AggregationTemporalityCumulative, ms.At(i).Sum().AggregationTemporality()) - dp := ms.At(i).Sum().DataPoints().At(0) - assert.Equal(t, start, dp.StartTimestamp()) - assert.Equal(t, ts, dp.Timestamp()) - assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) - assert.Equal(t, int64(1), dp.IntValue()) - attrVal, ok := dp.Attributes().Get("direction") - assert.True(t, ok) - assert.Equal(t, "transmitted", attrVal.Str()) - attrVal, ok = dp.Attributes().Get("object") - assert.True(t, ok) - assert.Equal(t, "object_name-val", attrVal.Str()) + if tt.name != "reaggregate_set" { + assert.False(t, validatedMetrics["vcenter.host.network.throughput"], "Found a duplicate in the metrics slice: vcenter.host.network.throughput") + validatedMetrics["vcenter.host.network.throughput"] = true + assert.Equal(t, pmetric.MetricTypeSum, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Sum().DataPoints().Len()) + assert.Equal(t, "The amount of data that was transmitted or received over the network by the host.", ms.At(i).Description()) + assert.Equal(t, "{KiBy/s}", ms.At(i).Unit()) + assert.False(t, ms.At(i).Sum().IsMonotonic()) + assert.Equal(t, pmetric.AggregationTemporalityCumulative, ms.At(i).Sum().AggregationTemporality()) + dp := ms.At(i).Sum().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) + assert.Equal(t, int64(1), dp.IntValue()) + attrVal, ok := dp.Attributes().Get("direction") + assert.True(t, ok) + assert.Equal(t, "transmitted", attrVal.Str()) + attrVal, ok = dp.Attributes().Get("object") + assert.True(t, ok) + assert.Equal(t, "object_name-val", attrVal.Str()) + } else { + assert.False(t, validatedMetrics["vcenter.host.network.throughput"], "Found a duplicate in the metrics slice: vcenter.host.network.throughput") + validatedMetrics["vcenter.host.network.throughput"] = true + assert.Equal(t, pmetric.MetricTypeSum, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Sum().DataPoints().Len()) + assert.Equal(t, "The amount of data that was transmitted or received over the network by the host.", ms.At(i).Description()) + assert.Equal(t, "{KiBy/s}", ms.At(i).Unit()) + assert.False(t, ms.At(i).Sum().IsMonotonic()) + assert.Equal(t, pmetric.AggregationTemporalityCumulative, ms.At(i).Sum().AggregationTemporality()) + dp := ms.At(i).Sum().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) + switch aggMap["vcenter.host.network.throughput"] { + case "sum": + assert.Equal(t, int64(4), dp.IntValue()) + case "avg": + assert.Equal(t, int64(2), dp.IntValue()) + case "min": + assert.Equal(t, int64(1), dp.IntValue()) + case "max": + assert.Equal(t, int64(3), dp.IntValue()) + } + _, ok := dp.Attributes().Get("direction") + assert.False(t, ok) + _, ok = dp.Attributes().Get("object") + assert.False(t, ok) + } case "vcenter.host.network.usage": - assert.False(t, validatedMetrics["vcenter.host.network.usage"], "Found a duplicate in the metrics slice: vcenter.host.network.usage") - validatedMetrics["vcenter.host.network.usage"] = true - assert.Equal(t, pmetric.MetricTypeSum, ms.At(i).Type()) - assert.Equal(t, 1, ms.At(i).Sum().DataPoints().Len()) - assert.Equal(t, "The sum of the data transmitted and received for all the NIC instances of the host.", ms.At(i).Description()) - assert.Equal(t, "{KiBy/s}", ms.At(i).Unit()) - assert.False(t, ms.At(i).Sum().IsMonotonic()) - assert.Equal(t, pmetric.AggregationTemporalityCumulative, ms.At(i).Sum().AggregationTemporality()) - dp := ms.At(i).Sum().DataPoints().At(0) - assert.Equal(t, start, dp.StartTimestamp()) - assert.Equal(t, ts, dp.Timestamp()) - assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) - assert.Equal(t, int64(1), dp.IntValue()) - attrVal, ok := dp.Attributes().Get("object") - assert.True(t, ok) - assert.Equal(t, "object_name-val", attrVal.Str()) + if tt.name != "reaggregate_set" { + assert.False(t, validatedMetrics["vcenter.host.network.usage"], "Found a duplicate in the metrics slice: vcenter.host.network.usage") + validatedMetrics["vcenter.host.network.usage"] = true + assert.Equal(t, pmetric.MetricTypeSum, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Sum().DataPoints().Len()) + assert.Equal(t, "The sum of the data transmitted and received for all the NIC instances of the host.", ms.At(i).Description()) + assert.Equal(t, "{KiBy/s}", ms.At(i).Unit()) + assert.False(t, ms.At(i).Sum().IsMonotonic()) + assert.Equal(t, pmetric.AggregationTemporalityCumulative, ms.At(i).Sum().AggregationTemporality()) + dp := ms.At(i).Sum().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) + assert.Equal(t, int64(1), dp.IntValue()) + attrVal, ok := dp.Attributes().Get("object") + assert.True(t, ok) + assert.Equal(t, "object_name-val", attrVal.Str()) + } else { + assert.False(t, validatedMetrics["vcenter.host.network.usage"], "Found a duplicate in the metrics slice: vcenter.host.network.usage") + validatedMetrics["vcenter.host.network.usage"] = true + assert.Equal(t, pmetric.MetricTypeSum, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Sum().DataPoints().Len()) + assert.Equal(t, "The sum of the data transmitted and received for all the NIC instances of the host.", ms.At(i).Description()) + assert.Equal(t, "{KiBy/s}", ms.At(i).Unit()) + assert.False(t, ms.At(i).Sum().IsMonotonic()) + assert.Equal(t, pmetric.AggregationTemporalityCumulative, ms.At(i).Sum().AggregationTemporality()) + dp := ms.At(i).Sum().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) + switch aggMap["vcenter.host.network.usage"] { + case "sum": + assert.Equal(t, int64(4), dp.IntValue()) + case "avg": + assert.Equal(t, int64(2), dp.IntValue()) + case "min": + assert.Equal(t, int64(1), dp.IntValue()) + case "max": + assert.Equal(t, int64(3), dp.IntValue()) + } + _, ok := dp.Attributes().Get("object") + assert.False(t, ok) + } case "vcenter.host.vsan.cache.hit_rate": - assert.False(t, validatedMetrics["vcenter.host.vsan.cache.hit_rate"], "Found a duplicate in the metrics slice: vcenter.host.vsan.cache.hit_rate") - validatedMetrics["vcenter.host.vsan.cache.hit_rate"] = true - assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) - assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) - assert.Equal(t, "The host's read IOs which could be satisfied by the local client cache.", ms.At(i).Description()) - assert.Equal(t, "%", ms.At(i).Unit()) - dp := ms.At(i).Gauge().DataPoints().At(0) - assert.Equal(t, start, dp.StartTimestamp()) - assert.Equal(t, ts, dp.Timestamp()) - assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) - assert.Equal(t, int64(1), dp.IntValue()) + if tt.name != "reaggregate_set" { + assert.False(t, validatedMetrics["vcenter.host.vsan.cache.hit_rate"], "Found a duplicate in the metrics slice: vcenter.host.vsan.cache.hit_rate") + validatedMetrics["vcenter.host.vsan.cache.hit_rate"] = true + assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) + assert.Equal(t, "The host's read IOs which could be satisfied by the local client cache.", ms.At(i).Description()) + assert.Equal(t, "%", ms.At(i).Unit()) + dp := ms.At(i).Gauge().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) + assert.Equal(t, int64(1), dp.IntValue()) + } else { + assert.False(t, validatedMetrics["vcenter.host.vsan.cache.hit_rate"], "Found a duplicate in the metrics slice: vcenter.host.vsan.cache.hit_rate") + validatedMetrics["vcenter.host.vsan.cache.hit_rate"] = true + assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) + assert.Equal(t, "The host's read IOs which could be satisfied by the local client cache.", ms.At(i).Description()) + assert.Equal(t, "%", ms.At(i).Unit()) + dp := ms.At(i).Gauge().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) + switch aggMap["vcenter.host.vsan.cache.hit_rate"] { + case "sum": + assert.Equal(t, int64(4), dp.IntValue()) + case "avg": + assert.Equal(t, int64(2), dp.IntValue()) + case "min": + assert.Equal(t, int64(1), dp.IntValue()) + case "max": + assert.Equal(t, int64(3), dp.IntValue()) + } + } case "vcenter.host.vsan.congestions": - assert.False(t, validatedMetrics["vcenter.host.vsan.congestions"], "Found a duplicate in the metrics slice: vcenter.host.vsan.congestions") - validatedMetrics["vcenter.host.vsan.congestions"] = true - assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) - assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) - assert.Equal(t, "The congestions of IOs generated by all vSAN clients in the host.", ms.At(i).Description()) - assert.Equal(t, "{congestions/s}", ms.At(i).Unit()) - dp := ms.At(i).Gauge().DataPoints().At(0) - assert.Equal(t, start, dp.StartTimestamp()) - assert.Equal(t, ts, dp.Timestamp()) - assert.Equal(t, pmetric.NumberDataPointValueTypeDouble, dp.ValueType()) - assert.InDelta(t, float64(1), dp.DoubleValue(), 0.01) + if tt.name != "reaggregate_set" { + assert.False(t, validatedMetrics["vcenter.host.vsan.congestions"], "Found a duplicate in the metrics slice: vcenter.host.vsan.congestions") + validatedMetrics["vcenter.host.vsan.congestions"] = true + assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) + assert.Equal(t, "The congestions of IOs generated by all vSAN clients in the host.", ms.At(i).Description()) + assert.Equal(t, "{congestions/s}", ms.At(i).Unit()) + dp := ms.At(i).Gauge().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeDouble, dp.ValueType()) + assert.InDelta(t, float64(1), dp.DoubleValue(), 0.01) + } else { + assert.False(t, validatedMetrics["vcenter.host.vsan.congestions"], "Found a duplicate in the metrics slice: vcenter.host.vsan.congestions") + validatedMetrics["vcenter.host.vsan.congestions"] = true + assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) + assert.Equal(t, "The congestions of IOs generated by all vSAN clients in the host.", ms.At(i).Description()) + assert.Equal(t, "{congestions/s}", ms.At(i).Unit()) + dp := ms.At(i).Gauge().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeDouble, dp.ValueType()) + switch aggMap["vcenter.host.vsan.congestions"] { + case "sum": + assert.InDelta(t, float64(4), dp.DoubleValue(), 0.01) + case "avg": + assert.InDelta(t, float64(2), dp.DoubleValue(), 0.01) + case "min": + assert.InDelta(t, float64(1), dp.DoubleValue(), 0.01) + case "max": + assert.InDelta(t, float64(3), dp.DoubleValue(), 0.01) + } + } case "vcenter.host.vsan.latency.avg": - assert.False(t, validatedMetrics["vcenter.host.vsan.latency.avg"], "Found a duplicate in the metrics slice: vcenter.host.vsan.latency.avg") - validatedMetrics["vcenter.host.vsan.latency.avg"] = true - assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) - assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) - assert.Equal(t, "The host latency while accessing vSAN storage.", ms.At(i).Description()) - assert.Equal(t, "us", ms.At(i).Unit()) - dp := ms.At(i).Gauge().DataPoints().At(0) - assert.Equal(t, start, dp.StartTimestamp()) - assert.Equal(t, ts, dp.Timestamp()) - assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) - assert.Equal(t, int64(1), dp.IntValue()) - attrVal, ok := dp.Attributes().Get("type") - assert.True(t, ok) - assert.Equal(t, "read", attrVal.Str()) + if tt.name != "reaggregate_set" { + assert.False(t, validatedMetrics["vcenter.host.vsan.latency.avg"], "Found a duplicate in the metrics slice: vcenter.host.vsan.latency.avg") + validatedMetrics["vcenter.host.vsan.latency.avg"] = true + assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) + assert.Equal(t, "The host latency while accessing vSAN storage.", ms.At(i).Description()) + assert.Equal(t, "us", ms.At(i).Unit()) + dp := ms.At(i).Gauge().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) + assert.Equal(t, int64(1), dp.IntValue()) + attrVal, ok := dp.Attributes().Get("type") + assert.True(t, ok) + assert.Equal(t, "read", attrVal.Str()) + } else { + assert.False(t, validatedMetrics["vcenter.host.vsan.latency.avg"], "Found a duplicate in the metrics slice: vcenter.host.vsan.latency.avg") + validatedMetrics["vcenter.host.vsan.latency.avg"] = true + assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) + assert.Equal(t, "The host latency while accessing vSAN storage.", ms.At(i).Description()) + assert.Equal(t, "us", ms.At(i).Unit()) + dp := ms.At(i).Gauge().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) + switch aggMap["vcenter.host.vsan.latency.avg"] { + case "sum": + assert.Equal(t, int64(4), dp.IntValue()) + case "avg": + assert.Equal(t, int64(2), dp.IntValue()) + case "min": + assert.Equal(t, int64(1), dp.IntValue()) + case "max": + assert.Equal(t, int64(3), dp.IntValue()) + } + _, ok := dp.Attributes().Get("type") + assert.False(t, ok) + } case "vcenter.host.vsan.operations": - assert.False(t, validatedMetrics["vcenter.host.vsan.operations"], "Found a duplicate in the metrics slice: vcenter.host.vsan.operations") - validatedMetrics["vcenter.host.vsan.operations"] = true - assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) - assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) - assert.Equal(t, "The vSAN IOPs of a host.", ms.At(i).Description()) - assert.Equal(t, "{operations/s}", ms.At(i).Unit()) - dp := ms.At(i).Gauge().DataPoints().At(0) - assert.Equal(t, start, dp.StartTimestamp()) - assert.Equal(t, ts, dp.Timestamp()) - assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) - assert.Equal(t, int64(1), dp.IntValue()) - attrVal, ok := dp.Attributes().Get("type") - assert.True(t, ok) - assert.Equal(t, "read", attrVal.Str()) + if tt.name != "reaggregate_set" { + assert.False(t, validatedMetrics["vcenter.host.vsan.operations"], "Found a duplicate in the metrics slice: vcenter.host.vsan.operations") + validatedMetrics["vcenter.host.vsan.operations"] = true + assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) + assert.Equal(t, "The vSAN IOPs of a host.", ms.At(i).Description()) + assert.Equal(t, "{operations/s}", ms.At(i).Unit()) + dp := ms.At(i).Gauge().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) + assert.Equal(t, int64(1), dp.IntValue()) + attrVal, ok := dp.Attributes().Get("type") + assert.True(t, ok) + assert.Equal(t, "read", attrVal.Str()) + } else { + assert.False(t, validatedMetrics["vcenter.host.vsan.operations"], "Found a duplicate in the metrics slice: vcenter.host.vsan.operations") + validatedMetrics["vcenter.host.vsan.operations"] = true + assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) + assert.Equal(t, "The vSAN IOPs of a host.", ms.At(i).Description()) + assert.Equal(t, "{operations/s}", ms.At(i).Unit()) + dp := ms.At(i).Gauge().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) + switch aggMap["vcenter.host.vsan.operations"] { + case "sum": + assert.Equal(t, int64(4), dp.IntValue()) + case "avg": + assert.Equal(t, int64(2), dp.IntValue()) + case "min": + assert.Equal(t, int64(1), dp.IntValue()) + case "max": + assert.Equal(t, int64(3), dp.IntValue()) + } + _, ok := dp.Attributes().Get("type") + assert.False(t, ok) + } case "vcenter.host.vsan.throughput": - assert.False(t, validatedMetrics["vcenter.host.vsan.throughput"], "Found a duplicate in the metrics slice: vcenter.host.vsan.throughput") - validatedMetrics["vcenter.host.vsan.throughput"] = true - assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) - assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) - assert.Equal(t, "The vSAN throughput of a host.", ms.At(i).Description()) - assert.Equal(t, "By/s", ms.At(i).Unit()) - dp := ms.At(i).Gauge().DataPoints().At(0) - assert.Equal(t, start, dp.StartTimestamp()) - assert.Equal(t, ts, dp.Timestamp()) - assert.Equal(t, pmetric.NumberDataPointValueTypeDouble, dp.ValueType()) - assert.InDelta(t, float64(1), dp.DoubleValue(), 0.01) - attrVal, ok := dp.Attributes().Get("direction") - assert.True(t, ok) - assert.Equal(t, "read", attrVal.Str()) + if tt.name != "reaggregate_set" { + assert.False(t, validatedMetrics["vcenter.host.vsan.throughput"], "Found a duplicate in the metrics slice: vcenter.host.vsan.throughput") + validatedMetrics["vcenter.host.vsan.throughput"] = true + assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) + assert.Equal(t, "The vSAN throughput of a host.", ms.At(i).Description()) + assert.Equal(t, "By/s", ms.At(i).Unit()) + dp := ms.At(i).Gauge().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeDouble, dp.ValueType()) + assert.InDelta(t, float64(1), dp.DoubleValue(), 0.01) + attrVal, ok := dp.Attributes().Get("direction") + assert.True(t, ok) + assert.Equal(t, "read", attrVal.Str()) + } else { + assert.False(t, validatedMetrics["vcenter.host.vsan.throughput"], "Found a duplicate in the metrics slice: vcenter.host.vsan.throughput") + validatedMetrics["vcenter.host.vsan.throughput"] = true + assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) + assert.Equal(t, "The vSAN throughput of a host.", ms.At(i).Description()) + assert.Equal(t, "By/s", ms.At(i).Unit()) + dp := ms.At(i).Gauge().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeDouble, dp.ValueType()) + switch aggMap["vcenter.host.vsan.throughput"] { + case "sum": + assert.InDelta(t, float64(4), dp.DoubleValue(), 0.01) + case "avg": + assert.InDelta(t, float64(2), dp.DoubleValue(), 0.01) + case "min": + assert.InDelta(t, float64(1), dp.DoubleValue(), 0.01) + case "max": + assert.InDelta(t, float64(3), dp.DoubleValue(), 0.01) + } + _, ok := dp.Attributes().Get("direction") + assert.False(t, ok) + } case "vcenter.resource_pool.cpu.shares": - assert.False(t, validatedMetrics["vcenter.resource_pool.cpu.shares"], "Found a duplicate in the metrics slice: vcenter.resource_pool.cpu.shares") - validatedMetrics["vcenter.resource_pool.cpu.shares"] = true - assert.Equal(t, pmetric.MetricTypeSum, ms.At(i).Type()) - assert.Equal(t, 1, ms.At(i).Sum().DataPoints().Len()) - assert.Equal(t, "The amount of shares of CPU in the resource pool.", ms.At(i).Description()) - assert.Equal(t, "{shares}", ms.At(i).Unit()) - assert.False(t, ms.At(i).Sum().IsMonotonic()) - assert.Equal(t, pmetric.AggregationTemporalityCumulative, ms.At(i).Sum().AggregationTemporality()) - dp := ms.At(i).Sum().DataPoints().At(0) - assert.Equal(t, start, dp.StartTimestamp()) - assert.Equal(t, ts, dp.Timestamp()) - assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) - assert.Equal(t, int64(1), dp.IntValue()) + if tt.name != "reaggregate_set" { + assert.False(t, validatedMetrics["vcenter.resource_pool.cpu.shares"], "Found a duplicate in the metrics slice: vcenter.resource_pool.cpu.shares") + validatedMetrics["vcenter.resource_pool.cpu.shares"] = true + assert.Equal(t, pmetric.MetricTypeSum, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Sum().DataPoints().Len()) + assert.Equal(t, "The amount of shares of CPU in the resource pool.", ms.At(i).Description()) + assert.Equal(t, "{shares}", ms.At(i).Unit()) + assert.False(t, ms.At(i).Sum().IsMonotonic()) + assert.Equal(t, pmetric.AggregationTemporalityCumulative, ms.At(i).Sum().AggregationTemporality()) + dp := ms.At(i).Sum().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) + assert.Equal(t, int64(1), dp.IntValue()) + } else { + assert.False(t, validatedMetrics["vcenter.resource_pool.cpu.shares"], "Found a duplicate in the metrics slice: vcenter.resource_pool.cpu.shares") + validatedMetrics["vcenter.resource_pool.cpu.shares"] = true + assert.Equal(t, pmetric.MetricTypeSum, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Sum().DataPoints().Len()) + assert.Equal(t, "The amount of shares of CPU in the resource pool.", ms.At(i).Description()) + assert.Equal(t, "{shares}", ms.At(i).Unit()) + assert.False(t, ms.At(i).Sum().IsMonotonic()) + assert.Equal(t, pmetric.AggregationTemporalityCumulative, ms.At(i).Sum().AggregationTemporality()) + dp := ms.At(i).Sum().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) + switch aggMap["vcenter.resource_pool.cpu.shares"] { + case "sum": + assert.Equal(t, int64(4), dp.IntValue()) + case "avg": + assert.Equal(t, int64(2), dp.IntValue()) + case "min": + assert.Equal(t, int64(1), dp.IntValue()) + case "max": + assert.Equal(t, int64(3), dp.IntValue()) + } + } case "vcenter.resource_pool.cpu.usage": - assert.False(t, validatedMetrics["vcenter.resource_pool.cpu.usage"], "Found a duplicate in the metrics slice: vcenter.resource_pool.cpu.usage") - validatedMetrics["vcenter.resource_pool.cpu.usage"] = true - assert.Equal(t, pmetric.MetricTypeSum, ms.At(i).Type()) - assert.Equal(t, 1, ms.At(i).Sum().DataPoints().Len()) - assert.Equal(t, "The usage of the CPU used by the resource pool.", ms.At(i).Description()) - assert.Equal(t, "MHz", ms.At(i).Unit()) - assert.False(t, ms.At(i).Sum().IsMonotonic()) - assert.Equal(t, pmetric.AggregationTemporalityCumulative, ms.At(i).Sum().AggregationTemporality()) - dp := ms.At(i).Sum().DataPoints().At(0) - assert.Equal(t, start, dp.StartTimestamp()) - assert.Equal(t, ts, dp.Timestamp()) - assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) - assert.Equal(t, int64(1), dp.IntValue()) + if tt.name != "reaggregate_set" { + assert.False(t, validatedMetrics["vcenter.resource_pool.cpu.usage"], "Found a duplicate in the metrics slice: vcenter.resource_pool.cpu.usage") + validatedMetrics["vcenter.resource_pool.cpu.usage"] = true + assert.Equal(t, pmetric.MetricTypeSum, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Sum().DataPoints().Len()) + assert.Equal(t, "The usage of the CPU used by the resource pool.", ms.At(i).Description()) + assert.Equal(t, "MHz", ms.At(i).Unit()) + assert.False(t, ms.At(i).Sum().IsMonotonic()) + assert.Equal(t, pmetric.AggregationTemporalityCumulative, ms.At(i).Sum().AggregationTemporality()) + dp := ms.At(i).Sum().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) + assert.Equal(t, int64(1), dp.IntValue()) + } else { + assert.False(t, validatedMetrics["vcenter.resource_pool.cpu.usage"], "Found a duplicate in the metrics slice: vcenter.resource_pool.cpu.usage") + validatedMetrics["vcenter.resource_pool.cpu.usage"] = true + assert.Equal(t, pmetric.MetricTypeSum, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Sum().DataPoints().Len()) + assert.Equal(t, "The usage of the CPU used by the resource pool.", ms.At(i).Description()) + assert.Equal(t, "MHz", ms.At(i).Unit()) + assert.False(t, ms.At(i).Sum().IsMonotonic()) + assert.Equal(t, pmetric.AggregationTemporalityCumulative, ms.At(i).Sum().AggregationTemporality()) + dp := ms.At(i).Sum().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) + switch aggMap["vcenter.resource_pool.cpu.usage"] { + case "sum": + assert.Equal(t, int64(4), dp.IntValue()) + case "avg": + assert.Equal(t, int64(2), dp.IntValue()) + case "min": + assert.Equal(t, int64(1), dp.IntValue()) + case "max": + assert.Equal(t, int64(3), dp.IntValue()) + } + } case "vcenter.resource_pool.memory.ballooned": - assert.False(t, validatedMetrics["vcenter.resource_pool.memory.ballooned"], "Found a duplicate in the metrics slice: vcenter.resource_pool.memory.ballooned") - validatedMetrics["vcenter.resource_pool.memory.ballooned"] = true - assert.Equal(t, pmetric.MetricTypeSum, ms.At(i).Type()) - assert.Equal(t, 1, ms.At(i).Sum().DataPoints().Len()) - assert.Equal(t, "The amount of memory in a resource pool that is ballooned due to virtualization.", ms.At(i).Description()) - assert.Equal(t, "MiBy", ms.At(i).Unit()) - assert.False(t, ms.At(i).Sum().IsMonotonic()) - assert.Equal(t, pmetric.AggregationTemporalityCumulative, ms.At(i).Sum().AggregationTemporality()) - dp := ms.At(i).Sum().DataPoints().At(0) - assert.Equal(t, start, dp.StartTimestamp()) - assert.Equal(t, ts, dp.Timestamp()) - assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) - assert.Equal(t, int64(1), dp.IntValue()) + if tt.name != "reaggregate_set" { + assert.False(t, validatedMetrics["vcenter.resource_pool.memory.ballooned"], "Found a duplicate in the metrics slice: vcenter.resource_pool.memory.ballooned") + validatedMetrics["vcenter.resource_pool.memory.ballooned"] = true + assert.Equal(t, pmetric.MetricTypeSum, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Sum().DataPoints().Len()) + assert.Equal(t, "The amount of memory in a resource pool that is ballooned due to virtualization.", ms.At(i).Description()) + assert.Equal(t, "MiBy", ms.At(i).Unit()) + assert.False(t, ms.At(i).Sum().IsMonotonic()) + assert.Equal(t, pmetric.AggregationTemporalityCumulative, ms.At(i).Sum().AggregationTemporality()) + dp := ms.At(i).Sum().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) + assert.Equal(t, int64(1), dp.IntValue()) + } else { + assert.False(t, validatedMetrics["vcenter.resource_pool.memory.ballooned"], "Found a duplicate in the metrics slice: vcenter.resource_pool.memory.ballooned") + validatedMetrics["vcenter.resource_pool.memory.ballooned"] = true + assert.Equal(t, pmetric.MetricTypeSum, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Sum().DataPoints().Len()) + assert.Equal(t, "The amount of memory in a resource pool that is ballooned due to virtualization.", ms.At(i).Description()) + assert.Equal(t, "MiBy", ms.At(i).Unit()) + assert.False(t, ms.At(i).Sum().IsMonotonic()) + assert.Equal(t, pmetric.AggregationTemporalityCumulative, ms.At(i).Sum().AggregationTemporality()) + dp := ms.At(i).Sum().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) + switch aggMap["vcenter.resource_pool.memory.ballooned"] { + case "sum": + assert.Equal(t, int64(4), dp.IntValue()) + case "avg": + assert.Equal(t, int64(2), dp.IntValue()) + case "min": + assert.Equal(t, int64(1), dp.IntValue()) + case "max": + assert.Equal(t, int64(3), dp.IntValue()) + } + } case "vcenter.resource_pool.memory.granted": - assert.False(t, validatedMetrics["vcenter.resource_pool.memory.granted"], "Found a duplicate in the metrics slice: vcenter.resource_pool.memory.granted") - validatedMetrics["vcenter.resource_pool.memory.granted"] = true - assert.Equal(t, pmetric.MetricTypeSum, ms.At(i).Type()) - assert.Equal(t, 1, ms.At(i).Sum().DataPoints().Len()) - assert.Equal(t, "The amount of memory that is granted to VMs in the resource pool from shared and non-shared host memory.", ms.At(i).Description()) - assert.Equal(t, "MiBy", ms.At(i).Unit()) - assert.False(t, ms.At(i).Sum().IsMonotonic()) - assert.Equal(t, pmetric.AggregationTemporalityCumulative, ms.At(i).Sum().AggregationTemporality()) - dp := ms.At(i).Sum().DataPoints().At(0) - assert.Equal(t, start, dp.StartTimestamp()) - assert.Equal(t, ts, dp.Timestamp()) - assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) - assert.Equal(t, int64(1), dp.IntValue()) - attrVal, ok := dp.Attributes().Get("type") - assert.True(t, ok) - assert.Equal(t, "private", attrVal.Str()) + if tt.name != "reaggregate_set" { + assert.False(t, validatedMetrics["vcenter.resource_pool.memory.granted"], "Found a duplicate in the metrics slice: vcenter.resource_pool.memory.granted") + validatedMetrics["vcenter.resource_pool.memory.granted"] = true + assert.Equal(t, pmetric.MetricTypeSum, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Sum().DataPoints().Len()) + assert.Equal(t, "The amount of memory that is granted to VMs in the resource pool from shared and non-shared host memory.", ms.At(i).Description()) + assert.Equal(t, "MiBy", ms.At(i).Unit()) + assert.False(t, ms.At(i).Sum().IsMonotonic()) + assert.Equal(t, pmetric.AggregationTemporalityCumulative, ms.At(i).Sum().AggregationTemporality()) + dp := ms.At(i).Sum().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) + assert.Equal(t, int64(1), dp.IntValue()) + attrVal, ok := dp.Attributes().Get("type") + assert.True(t, ok) + assert.Equal(t, "private", attrVal.Str()) + } else { + assert.False(t, validatedMetrics["vcenter.resource_pool.memory.granted"], "Found a duplicate in the metrics slice: vcenter.resource_pool.memory.granted") + validatedMetrics["vcenter.resource_pool.memory.granted"] = true + assert.Equal(t, pmetric.MetricTypeSum, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Sum().DataPoints().Len()) + assert.Equal(t, "The amount of memory that is granted to VMs in the resource pool from shared and non-shared host memory.", ms.At(i).Description()) + assert.Equal(t, "MiBy", ms.At(i).Unit()) + assert.False(t, ms.At(i).Sum().IsMonotonic()) + assert.Equal(t, pmetric.AggregationTemporalityCumulative, ms.At(i).Sum().AggregationTemporality()) + dp := ms.At(i).Sum().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) + switch aggMap["vcenter.resource_pool.memory.granted"] { + case "sum": + assert.Equal(t, int64(4), dp.IntValue()) + case "avg": + assert.Equal(t, int64(2), dp.IntValue()) + case "min": + assert.Equal(t, int64(1), dp.IntValue()) + case "max": + assert.Equal(t, int64(3), dp.IntValue()) + } + _, ok := dp.Attributes().Get("type") + assert.False(t, ok) + } case "vcenter.resource_pool.memory.shares": - assert.False(t, validatedMetrics["vcenter.resource_pool.memory.shares"], "Found a duplicate in the metrics slice: vcenter.resource_pool.memory.shares") - validatedMetrics["vcenter.resource_pool.memory.shares"] = true - assert.Equal(t, pmetric.MetricTypeSum, ms.At(i).Type()) - assert.Equal(t, 1, ms.At(i).Sum().DataPoints().Len()) - assert.Equal(t, "The amount of shares of memory in the resource pool.", ms.At(i).Description()) - assert.Equal(t, "{shares}", ms.At(i).Unit()) - assert.False(t, ms.At(i).Sum().IsMonotonic()) - assert.Equal(t, pmetric.AggregationTemporalityCumulative, ms.At(i).Sum().AggregationTemporality()) - dp := ms.At(i).Sum().DataPoints().At(0) - assert.Equal(t, start, dp.StartTimestamp()) - assert.Equal(t, ts, dp.Timestamp()) - assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) - assert.Equal(t, int64(1), dp.IntValue()) + if tt.name != "reaggregate_set" { + assert.False(t, validatedMetrics["vcenter.resource_pool.memory.shares"], "Found a duplicate in the metrics slice: vcenter.resource_pool.memory.shares") + validatedMetrics["vcenter.resource_pool.memory.shares"] = true + assert.Equal(t, pmetric.MetricTypeSum, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Sum().DataPoints().Len()) + assert.Equal(t, "The amount of shares of memory in the resource pool.", ms.At(i).Description()) + assert.Equal(t, "{shares}", ms.At(i).Unit()) + assert.False(t, ms.At(i).Sum().IsMonotonic()) + assert.Equal(t, pmetric.AggregationTemporalityCumulative, ms.At(i).Sum().AggregationTemporality()) + dp := ms.At(i).Sum().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) + assert.Equal(t, int64(1), dp.IntValue()) + } else { + assert.False(t, validatedMetrics["vcenter.resource_pool.memory.shares"], "Found a duplicate in the metrics slice: vcenter.resource_pool.memory.shares") + validatedMetrics["vcenter.resource_pool.memory.shares"] = true + assert.Equal(t, pmetric.MetricTypeSum, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Sum().DataPoints().Len()) + assert.Equal(t, "The amount of shares of memory in the resource pool.", ms.At(i).Description()) + assert.Equal(t, "{shares}", ms.At(i).Unit()) + assert.False(t, ms.At(i).Sum().IsMonotonic()) + assert.Equal(t, pmetric.AggregationTemporalityCumulative, ms.At(i).Sum().AggregationTemporality()) + dp := ms.At(i).Sum().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) + switch aggMap["vcenter.resource_pool.memory.shares"] { + case "sum": + assert.Equal(t, int64(4), dp.IntValue()) + case "avg": + assert.Equal(t, int64(2), dp.IntValue()) + case "min": + assert.Equal(t, int64(1), dp.IntValue()) + case "max": + assert.Equal(t, int64(3), dp.IntValue()) + } + } case "vcenter.resource_pool.memory.swapped": - assert.False(t, validatedMetrics["vcenter.resource_pool.memory.swapped"], "Found a duplicate in the metrics slice: vcenter.resource_pool.memory.swapped") - validatedMetrics["vcenter.resource_pool.memory.swapped"] = true - assert.Equal(t, pmetric.MetricTypeSum, ms.At(i).Type()) - assert.Equal(t, 1, ms.At(i).Sum().DataPoints().Len()) - assert.Equal(t, "The amount of memory that is granted to VMs in the resource pool from the host's swap space.", ms.At(i).Description()) - assert.Equal(t, "MiBy", ms.At(i).Unit()) - assert.False(t, ms.At(i).Sum().IsMonotonic()) - assert.Equal(t, pmetric.AggregationTemporalityCumulative, ms.At(i).Sum().AggregationTemporality()) - dp := ms.At(i).Sum().DataPoints().At(0) - assert.Equal(t, start, dp.StartTimestamp()) - assert.Equal(t, ts, dp.Timestamp()) - assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) - assert.Equal(t, int64(1), dp.IntValue()) + if tt.name != "reaggregate_set" { + assert.False(t, validatedMetrics["vcenter.resource_pool.memory.swapped"], "Found a duplicate in the metrics slice: vcenter.resource_pool.memory.swapped") + validatedMetrics["vcenter.resource_pool.memory.swapped"] = true + assert.Equal(t, pmetric.MetricTypeSum, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Sum().DataPoints().Len()) + assert.Equal(t, "The amount of memory that is granted to VMs in the resource pool from the host's swap space.", ms.At(i).Description()) + assert.Equal(t, "MiBy", ms.At(i).Unit()) + assert.False(t, ms.At(i).Sum().IsMonotonic()) + assert.Equal(t, pmetric.AggregationTemporalityCumulative, ms.At(i).Sum().AggregationTemporality()) + dp := ms.At(i).Sum().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) + assert.Equal(t, int64(1), dp.IntValue()) + } else { + assert.False(t, validatedMetrics["vcenter.resource_pool.memory.swapped"], "Found a duplicate in the metrics slice: vcenter.resource_pool.memory.swapped") + validatedMetrics["vcenter.resource_pool.memory.swapped"] = true + assert.Equal(t, pmetric.MetricTypeSum, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Sum().DataPoints().Len()) + assert.Equal(t, "The amount of memory that is granted to VMs in the resource pool from the host's swap space.", ms.At(i).Description()) + assert.Equal(t, "MiBy", ms.At(i).Unit()) + assert.False(t, ms.At(i).Sum().IsMonotonic()) + assert.Equal(t, pmetric.AggregationTemporalityCumulative, ms.At(i).Sum().AggregationTemporality()) + dp := ms.At(i).Sum().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) + switch aggMap["vcenter.resource_pool.memory.swapped"] { + case "sum": + assert.Equal(t, int64(4), dp.IntValue()) + case "avg": + assert.Equal(t, int64(2), dp.IntValue()) + case "min": + assert.Equal(t, int64(1), dp.IntValue()) + case "max": + assert.Equal(t, int64(3), dp.IntValue()) + } + } case "vcenter.resource_pool.memory.usage": - assert.False(t, validatedMetrics["vcenter.resource_pool.memory.usage"], "Found a duplicate in the metrics slice: vcenter.resource_pool.memory.usage") - validatedMetrics["vcenter.resource_pool.memory.usage"] = true - assert.Equal(t, pmetric.MetricTypeSum, ms.At(i).Type()) - assert.Equal(t, 1, ms.At(i).Sum().DataPoints().Len()) - assert.Equal(t, "The usage of the memory by the resource pool.", ms.At(i).Description()) - assert.Equal(t, "MiBy", ms.At(i).Unit()) - assert.False(t, ms.At(i).Sum().IsMonotonic()) - assert.Equal(t, pmetric.AggregationTemporalityCumulative, ms.At(i).Sum().AggregationTemporality()) - dp := ms.At(i).Sum().DataPoints().At(0) - assert.Equal(t, start, dp.StartTimestamp()) - assert.Equal(t, ts, dp.Timestamp()) - assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) - assert.Equal(t, int64(1), dp.IntValue()) - attrVal, ok := dp.Attributes().Get("type") - assert.True(t, ok) - assert.Equal(t, "guest", attrVal.Str()) + if tt.name != "reaggregate_set" { + assert.False(t, validatedMetrics["vcenter.resource_pool.memory.usage"], "Found a duplicate in the metrics slice: vcenter.resource_pool.memory.usage") + validatedMetrics["vcenter.resource_pool.memory.usage"] = true + assert.Equal(t, pmetric.MetricTypeSum, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Sum().DataPoints().Len()) + assert.Equal(t, "The usage of the memory by the resource pool.", ms.At(i).Description()) + assert.Equal(t, "MiBy", ms.At(i).Unit()) + assert.False(t, ms.At(i).Sum().IsMonotonic()) + assert.Equal(t, pmetric.AggregationTemporalityCumulative, ms.At(i).Sum().AggregationTemporality()) + dp := ms.At(i).Sum().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) + assert.Equal(t, int64(1), dp.IntValue()) + attrVal, ok := dp.Attributes().Get("type") + assert.True(t, ok) + assert.Equal(t, "guest", attrVal.Str()) + } else { + assert.False(t, validatedMetrics["vcenter.resource_pool.memory.usage"], "Found a duplicate in the metrics slice: vcenter.resource_pool.memory.usage") + validatedMetrics["vcenter.resource_pool.memory.usage"] = true + assert.Equal(t, pmetric.MetricTypeSum, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Sum().DataPoints().Len()) + assert.Equal(t, "The usage of the memory by the resource pool.", ms.At(i).Description()) + assert.Equal(t, "MiBy", ms.At(i).Unit()) + assert.False(t, ms.At(i).Sum().IsMonotonic()) + assert.Equal(t, pmetric.AggregationTemporalityCumulative, ms.At(i).Sum().AggregationTemporality()) + dp := ms.At(i).Sum().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) + switch aggMap["vcenter.resource_pool.memory.usage"] { + case "sum": + assert.Equal(t, int64(4), dp.IntValue()) + case "avg": + assert.Equal(t, int64(2), dp.IntValue()) + case "min": + assert.Equal(t, int64(1), dp.IntValue()) + case "max": + assert.Equal(t, int64(3), dp.IntValue()) + } + _, ok := dp.Attributes().Get("type") + assert.False(t, ok) + } case "vcenter.vm.cpu.readiness": - assert.False(t, validatedMetrics["vcenter.vm.cpu.readiness"], "Found a duplicate in the metrics slice: vcenter.vm.cpu.readiness") - validatedMetrics["vcenter.vm.cpu.readiness"] = true - assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) - assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) - assert.Equal(t, "Percentage of time that the virtual machine was ready, but could not get scheduled to run on the physical CPU.", ms.At(i).Description()) - assert.Equal(t, "%", ms.At(i).Unit()) - dp := ms.At(i).Gauge().DataPoints().At(0) - assert.Equal(t, start, dp.StartTimestamp()) - assert.Equal(t, ts, dp.Timestamp()) - assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) - assert.Equal(t, int64(1), dp.IntValue()) + if tt.name != "reaggregate_set" { + assert.False(t, validatedMetrics["vcenter.vm.cpu.readiness"], "Found a duplicate in the metrics slice: vcenter.vm.cpu.readiness") + validatedMetrics["vcenter.vm.cpu.readiness"] = true + assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) + assert.Equal(t, "Percentage of time that the virtual machine was ready, but could not get scheduled to run on the physical CPU.", ms.At(i).Description()) + assert.Equal(t, "%", ms.At(i).Unit()) + dp := ms.At(i).Gauge().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) + assert.Equal(t, int64(1), dp.IntValue()) + } else { + assert.False(t, validatedMetrics["vcenter.vm.cpu.readiness"], "Found a duplicate in the metrics slice: vcenter.vm.cpu.readiness") + validatedMetrics["vcenter.vm.cpu.readiness"] = true + assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) + assert.Equal(t, "Percentage of time that the virtual machine was ready, but could not get scheduled to run on the physical CPU.", ms.At(i).Description()) + assert.Equal(t, "%", ms.At(i).Unit()) + dp := ms.At(i).Gauge().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) + switch aggMap["vcenter.vm.cpu.readiness"] { + case "sum": + assert.Equal(t, int64(4), dp.IntValue()) + case "avg": + assert.Equal(t, int64(2), dp.IntValue()) + case "min": + assert.Equal(t, int64(1), dp.IntValue()) + case "max": + assert.Equal(t, int64(3), dp.IntValue()) + } + } case "vcenter.vm.cpu.time": - assert.False(t, validatedMetrics["vcenter.vm.cpu.time"], "Found a duplicate in the metrics slice: vcenter.vm.cpu.time") - validatedMetrics["vcenter.vm.cpu.time"] = true - assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) - assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) - assert.Equal(t, "CPU time spent in idle, ready or wait state.", ms.At(i).Description()) - assert.Equal(t, "%", ms.At(i).Unit()) - dp := ms.At(i).Gauge().DataPoints().At(0) - assert.Equal(t, start, dp.StartTimestamp()) - assert.Equal(t, ts, dp.Timestamp()) - assert.Equal(t, pmetric.NumberDataPointValueTypeDouble, dp.ValueType()) - assert.InDelta(t, float64(1), dp.DoubleValue(), 0.01) - attrVal, ok := dp.Attributes().Get("cpu_state") - assert.True(t, ok) - assert.Equal(t, "idle", attrVal.Str()) - attrVal, ok = dp.Attributes().Get("object") - assert.True(t, ok) - assert.Equal(t, "object_name-val", attrVal.Str()) + if tt.name != "reaggregate_set" { + assert.False(t, validatedMetrics["vcenter.vm.cpu.time"], "Found a duplicate in the metrics slice: vcenter.vm.cpu.time") + validatedMetrics["vcenter.vm.cpu.time"] = true + assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) + assert.Equal(t, "CPU time spent in idle, ready or wait state.", ms.At(i).Description()) + assert.Equal(t, "%", ms.At(i).Unit()) + dp := ms.At(i).Gauge().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeDouble, dp.ValueType()) + assert.InDelta(t, float64(1), dp.DoubleValue(), 0.01) + attrVal, ok := dp.Attributes().Get("cpu_state") + assert.True(t, ok) + assert.Equal(t, "idle", attrVal.Str()) + attrVal, ok = dp.Attributes().Get("object") + assert.True(t, ok) + assert.Equal(t, "object_name-val", attrVal.Str()) + } else { + assert.False(t, validatedMetrics["vcenter.vm.cpu.time"], "Found a duplicate in the metrics slice: vcenter.vm.cpu.time") + validatedMetrics["vcenter.vm.cpu.time"] = true + assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) + assert.Equal(t, "CPU time spent in idle, ready or wait state.", ms.At(i).Description()) + assert.Equal(t, "%", ms.At(i).Unit()) + dp := ms.At(i).Gauge().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeDouble, dp.ValueType()) + switch aggMap["vcenter.vm.cpu.time"] { + case "sum": + assert.InDelta(t, float64(4), dp.DoubleValue(), 0.01) + case "avg": + assert.InDelta(t, float64(2), dp.DoubleValue(), 0.01) + case "min": + assert.InDelta(t, float64(1), dp.DoubleValue(), 0.01) + case "max": + assert.InDelta(t, float64(3), dp.DoubleValue(), 0.01) + } + _, ok := dp.Attributes().Get("cpu_state") + assert.False(t, ok) + _, ok = dp.Attributes().Get("object") + assert.False(t, ok) + } case "vcenter.vm.cpu.usage": - assert.False(t, validatedMetrics["vcenter.vm.cpu.usage"], "Found a duplicate in the metrics slice: vcenter.vm.cpu.usage") - validatedMetrics["vcenter.vm.cpu.usage"] = true - assert.Equal(t, pmetric.MetricTypeSum, ms.At(i).Type()) - assert.Equal(t, 1, ms.At(i).Sum().DataPoints().Len()) - assert.Equal(t, "The amount of CPU used by the VM.", ms.At(i).Description()) - assert.Equal(t, "MHz", ms.At(i).Unit()) - assert.False(t, ms.At(i).Sum().IsMonotonic()) - assert.Equal(t, pmetric.AggregationTemporalityCumulative, ms.At(i).Sum().AggregationTemporality()) - dp := ms.At(i).Sum().DataPoints().At(0) - assert.Equal(t, start, dp.StartTimestamp()) - assert.Equal(t, ts, dp.Timestamp()) - assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) - assert.Equal(t, int64(1), dp.IntValue()) + if tt.name != "reaggregate_set" { + assert.False(t, validatedMetrics["vcenter.vm.cpu.usage"], "Found a duplicate in the metrics slice: vcenter.vm.cpu.usage") + validatedMetrics["vcenter.vm.cpu.usage"] = true + assert.Equal(t, pmetric.MetricTypeSum, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Sum().DataPoints().Len()) + assert.Equal(t, "The amount of CPU used by the VM.", ms.At(i).Description()) + assert.Equal(t, "MHz", ms.At(i).Unit()) + assert.False(t, ms.At(i).Sum().IsMonotonic()) + assert.Equal(t, pmetric.AggregationTemporalityCumulative, ms.At(i).Sum().AggregationTemporality()) + dp := ms.At(i).Sum().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) + assert.Equal(t, int64(1), dp.IntValue()) + } else { + assert.False(t, validatedMetrics["vcenter.vm.cpu.usage"], "Found a duplicate in the metrics slice: vcenter.vm.cpu.usage") + validatedMetrics["vcenter.vm.cpu.usage"] = true + assert.Equal(t, pmetric.MetricTypeSum, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Sum().DataPoints().Len()) + assert.Equal(t, "The amount of CPU used by the VM.", ms.At(i).Description()) + assert.Equal(t, "MHz", ms.At(i).Unit()) + assert.False(t, ms.At(i).Sum().IsMonotonic()) + assert.Equal(t, pmetric.AggregationTemporalityCumulative, ms.At(i).Sum().AggregationTemporality()) + dp := ms.At(i).Sum().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) + switch aggMap["vcenter.vm.cpu.usage"] { + case "sum": + assert.Equal(t, int64(4), dp.IntValue()) + case "avg": + assert.Equal(t, int64(2), dp.IntValue()) + case "min": + assert.Equal(t, int64(1), dp.IntValue()) + case "max": + assert.Equal(t, int64(3), dp.IntValue()) + } + } case "vcenter.vm.cpu.utilization": - assert.False(t, validatedMetrics["vcenter.vm.cpu.utilization"], "Found a duplicate in the metrics slice: vcenter.vm.cpu.utilization") - validatedMetrics["vcenter.vm.cpu.utilization"] = true - assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) - assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) - assert.Equal(t, "The CPU utilization of the VM.", ms.At(i).Description()) - assert.Equal(t, "%", ms.At(i).Unit()) - dp := ms.At(i).Gauge().DataPoints().At(0) - assert.Equal(t, start, dp.StartTimestamp()) - assert.Equal(t, ts, dp.Timestamp()) - assert.Equal(t, pmetric.NumberDataPointValueTypeDouble, dp.ValueType()) - assert.InDelta(t, float64(1), dp.DoubleValue(), 0.01) + if tt.name != "reaggregate_set" { + assert.False(t, validatedMetrics["vcenter.vm.cpu.utilization"], "Found a duplicate in the metrics slice: vcenter.vm.cpu.utilization") + validatedMetrics["vcenter.vm.cpu.utilization"] = true + assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) + assert.Equal(t, "The CPU utilization of the VM.", ms.At(i).Description()) + assert.Equal(t, "%", ms.At(i).Unit()) + dp := ms.At(i).Gauge().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeDouble, dp.ValueType()) + assert.InDelta(t, float64(1), dp.DoubleValue(), 0.01) + } else { + assert.False(t, validatedMetrics["vcenter.vm.cpu.utilization"], "Found a duplicate in the metrics slice: vcenter.vm.cpu.utilization") + validatedMetrics["vcenter.vm.cpu.utilization"] = true + assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) + assert.Equal(t, "The CPU utilization of the VM.", ms.At(i).Description()) + assert.Equal(t, "%", ms.At(i).Unit()) + dp := ms.At(i).Gauge().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeDouble, dp.ValueType()) + switch aggMap["vcenter.vm.cpu.utilization"] { + case "sum": + assert.InDelta(t, float64(4), dp.DoubleValue(), 0.01) + case "avg": + assert.InDelta(t, float64(2), dp.DoubleValue(), 0.01) + case "min": + assert.InDelta(t, float64(1), dp.DoubleValue(), 0.01) + case "max": + assert.InDelta(t, float64(3), dp.DoubleValue(), 0.01) + } + } case "vcenter.vm.disk.latency.avg": - assert.False(t, validatedMetrics["vcenter.vm.disk.latency.avg"], "Found a duplicate in the metrics slice: vcenter.vm.disk.latency.avg") - validatedMetrics["vcenter.vm.disk.latency.avg"] = true - assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) - assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) - assert.Equal(t, "The latency of operations to the virtual machine's disk.", ms.At(i).Description()) - assert.Equal(t, "ms", ms.At(i).Unit()) - dp := ms.At(i).Gauge().DataPoints().At(0) - assert.Equal(t, start, dp.StartTimestamp()) - assert.Equal(t, ts, dp.Timestamp()) - assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) - assert.Equal(t, int64(1), dp.IntValue()) - attrVal, ok := dp.Attributes().Get("direction") - assert.True(t, ok) - assert.Equal(t, "read", attrVal.Str()) - attrVal, ok = dp.Attributes().Get("disk_type") - assert.True(t, ok) - assert.Equal(t, "virtual", attrVal.Str()) - attrVal, ok = dp.Attributes().Get("object") - assert.True(t, ok) - assert.Equal(t, "object_name-val", attrVal.Str()) + if tt.name != "reaggregate_set" { + assert.False(t, validatedMetrics["vcenter.vm.disk.latency.avg"], "Found a duplicate in the metrics slice: vcenter.vm.disk.latency.avg") + validatedMetrics["vcenter.vm.disk.latency.avg"] = true + assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) + assert.Equal(t, "The latency of operations to the virtual machine's disk.", ms.At(i).Description()) + assert.Equal(t, "ms", ms.At(i).Unit()) + dp := ms.At(i).Gauge().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) + assert.Equal(t, int64(1), dp.IntValue()) + attrVal, ok := dp.Attributes().Get("direction") + assert.True(t, ok) + assert.Equal(t, "read", attrVal.Str()) + attrVal, ok = dp.Attributes().Get("disk_type") + assert.True(t, ok) + assert.Equal(t, "virtual", attrVal.Str()) + attrVal, ok = dp.Attributes().Get("object") + assert.True(t, ok) + assert.Equal(t, "object_name-val", attrVal.Str()) + } else { + assert.False(t, validatedMetrics["vcenter.vm.disk.latency.avg"], "Found a duplicate in the metrics slice: vcenter.vm.disk.latency.avg") + validatedMetrics["vcenter.vm.disk.latency.avg"] = true + assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) + assert.Equal(t, "The latency of operations to the virtual machine's disk.", ms.At(i).Description()) + assert.Equal(t, "ms", ms.At(i).Unit()) + dp := ms.At(i).Gauge().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) + switch aggMap["vcenter.vm.disk.latency.avg"] { + case "sum": + assert.Equal(t, int64(4), dp.IntValue()) + case "avg": + assert.Equal(t, int64(2), dp.IntValue()) + case "min": + assert.Equal(t, int64(1), dp.IntValue()) + case "max": + assert.Equal(t, int64(3), dp.IntValue()) + } + _, ok := dp.Attributes().Get("direction") + assert.False(t, ok) + _, ok = dp.Attributes().Get("disk_type") + assert.False(t, ok) + _, ok = dp.Attributes().Get("object") + assert.False(t, ok) + } case "vcenter.vm.disk.latency.max": - assert.False(t, validatedMetrics["vcenter.vm.disk.latency.max"], "Found a duplicate in the metrics slice: vcenter.vm.disk.latency.max") - validatedMetrics["vcenter.vm.disk.latency.max"] = true - assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) - assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) - assert.Equal(t, "The highest reported total latency (device and kernel times) over an interval of 20 seconds.", ms.At(i).Description()) - assert.Equal(t, "ms", ms.At(i).Unit()) - dp := ms.At(i).Gauge().DataPoints().At(0) - assert.Equal(t, start, dp.StartTimestamp()) - assert.Equal(t, ts, dp.Timestamp()) - assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) - assert.Equal(t, int64(1), dp.IntValue()) - attrVal, ok := dp.Attributes().Get("object") - assert.True(t, ok) - assert.Equal(t, "object_name-val", attrVal.Str()) + if tt.name != "reaggregate_set" { + assert.False(t, validatedMetrics["vcenter.vm.disk.latency.max"], "Found a duplicate in the metrics slice: vcenter.vm.disk.latency.max") + validatedMetrics["vcenter.vm.disk.latency.max"] = true + assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) + assert.Equal(t, "The highest reported total latency (device and kernel times) over an interval of 20 seconds.", ms.At(i).Description()) + assert.Equal(t, "ms", ms.At(i).Unit()) + dp := ms.At(i).Gauge().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) + assert.Equal(t, int64(1), dp.IntValue()) + attrVal, ok := dp.Attributes().Get("object") + assert.True(t, ok) + assert.Equal(t, "object_name-val", attrVal.Str()) + } else { + assert.False(t, validatedMetrics["vcenter.vm.disk.latency.max"], "Found a duplicate in the metrics slice: vcenter.vm.disk.latency.max") + validatedMetrics["vcenter.vm.disk.latency.max"] = true + assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) + assert.Equal(t, "The highest reported total latency (device and kernel times) over an interval of 20 seconds.", ms.At(i).Description()) + assert.Equal(t, "ms", ms.At(i).Unit()) + dp := ms.At(i).Gauge().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) + switch aggMap["vcenter.vm.disk.latency.max"] { + case "sum": + assert.Equal(t, int64(4), dp.IntValue()) + case "avg": + assert.Equal(t, int64(2), dp.IntValue()) + case "min": + assert.Equal(t, int64(1), dp.IntValue()) + case "max": + assert.Equal(t, int64(3), dp.IntValue()) + } + _, ok := dp.Attributes().Get("object") + assert.False(t, ok) + } case "vcenter.vm.disk.throughput": - assert.False(t, validatedMetrics["vcenter.vm.disk.throughput"], "Found a duplicate in the metrics slice: vcenter.vm.disk.throughput") - validatedMetrics["vcenter.vm.disk.throughput"] = true - assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) - assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) - assert.Equal(t, "Average number of kilobytes read from or written to the virtual disk each second.", ms.At(i).Description()) - assert.Equal(t, "{KiBy/s}", ms.At(i).Unit()) - dp := ms.At(i).Gauge().DataPoints().At(0) - assert.Equal(t, start, dp.StartTimestamp()) - assert.Equal(t, ts, dp.Timestamp()) - assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) - assert.Equal(t, int64(1), dp.IntValue()) - attrVal, ok := dp.Attributes().Get("direction") - assert.True(t, ok) - assert.Equal(t, "read", attrVal.Str()) - attrVal, ok = dp.Attributes().Get("object") - assert.True(t, ok) - assert.Equal(t, "object_name-val", attrVal.Str()) + if tt.name != "reaggregate_set" { + assert.False(t, validatedMetrics["vcenter.vm.disk.throughput"], "Found a duplicate in the metrics slice: vcenter.vm.disk.throughput") + validatedMetrics["vcenter.vm.disk.throughput"] = true + assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) + assert.Equal(t, "Average number of kilobytes read from or written to the virtual disk each second.", ms.At(i).Description()) + assert.Equal(t, "{KiBy/s}", ms.At(i).Unit()) + dp := ms.At(i).Gauge().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) + assert.Equal(t, int64(1), dp.IntValue()) + attrVal, ok := dp.Attributes().Get("direction") + assert.True(t, ok) + assert.Equal(t, "read", attrVal.Str()) + attrVal, ok = dp.Attributes().Get("object") + assert.True(t, ok) + assert.Equal(t, "object_name-val", attrVal.Str()) + } else { + assert.False(t, validatedMetrics["vcenter.vm.disk.throughput"], "Found a duplicate in the metrics slice: vcenter.vm.disk.throughput") + validatedMetrics["vcenter.vm.disk.throughput"] = true + assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) + assert.Equal(t, "Average number of kilobytes read from or written to the virtual disk each second.", ms.At(i).Description()) + assert.Equal(t, "{KiBy/s}", ms.At(i).Unit()) + dp := ms.At(i).Gauge().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) + switch aggMap["vcenter.vm.disk.throughput"] { + case "sum": + assert.Equal(t, int64(4), dp.IntValue()) + case "avg": + assert.Equal(t, int64(2), dp.IntValue()) + case "min": + assert.Equal(t, int64(1), dp.IntValue()) + case "max": + assert.Equal(t, int64(3), dp.IntValue()) + } + _, ok := dp.Attributes().Get("direction") + assert.False(t, ok) + _, ok = dp.Attributes().Get("object") + assert.False(t, ok) + } case "vcenter.vm.disk.usage": - assert.False(t, validatedMetrics["vcenter.vm.disk.usage"], "Found a duplicate in the metrics slice: vcenter.vm.disk.usage") - validatedMetrics["vcenter.vm.disk.usage"] = true - assert.Equal(t, pmetric.MetricTypeSum, ms.At(i).Type()) - assert.Equal(t, 1, ms.At(i).Sum().DataPoints().Len()) - assert.Equal(t, "The amount of storage space used by the virtual machine.", ms.At(i).Description()) - assert.Equal(t, "By", ms.At(i).Unit()) - assert.False(t, ms.At(i).Sum().IsMonotonic()) - assert.Equal(t, pmetric.AggregationTemporalityCumulative, ms.At(i).Sum().AggregationTemporality()) - dp := ms.At(i).Sum().DataPoints().At(0) - assert.Equal(t, start, dp.StartTimestamp()) - assert.Equal(t, ts, dp.Timestamp()) - assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) - assert.Equal(t, int64(1), dp.IntValue()) - attrVal, ok := dp.Attributes().Get("disk_state") - assert.True(t, ok) - assert.Equal(t, "available", attrVal.Str()) + if tt.name != "reaggregate_set" { + assert.False(t, validatedMetrics["vcenter.vm.disk.usage"], "Found a duplicate in the metrics slice: vcenter.vm.disk.usage") + validatedMetrics["vcenter.vm.disk.usage"] = true + assert.Equal(t, pmetric.MetricTypeSum, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Sum().DataPoints().Len()) + assert.Equal(t, "The amount of storage space used by the virtual machine.", ms.At(i).Description()) + assert.Equal(t, "By", ms.At(i).Unit()) + assert.False(t, ms.At(i).Sum().IsMonotonic()) + assert.Equal(t, pmetric.AggregationTemporalityCumulative, ms.At(i).Sum().AggregationTemporality()) + dp := ms.At(i).Sum().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) + assert.Equal(t, int64(1), dp.IntValue()) + attrVal, ok := dp.Attributes().Get("disk_state") + assert.True(t, ok) + assert.Equal(t, "available", attrVal.Str()) + } else { + assert.False(t, validatedMetrics["vcenter.vm.disk.usage"], "Found a duplicate in the metrics slice: vcenter.vm.disk.usage") + validatedMetrics["vcenter.vm.disk.usage"] = true + assert.Equal(t, pmetric.MetricTypeSum, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Sum().DataPoints().Len()) + assert.Equal(t, "The amount of storage space used by the virtual machine.", ms.At(i).Description()) + assert.Equal(t, "By", ms.At(i).Unit()) + assert.False(t, ms.At(i).Sum().IsMonotonic()) + assert.Equal(t, pmetric.AggregationTemporalityCumulative, ms.At(i).Sum().AggregationTemporality()) + dp := ms.At(i).Sum().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) + switch aggMap["vcenter.vm.disk.usage"] { + case "sum": + assert.Equal(t, int64(4), dp.IntValue()) + case "avg": + assert.Equal(t, int64(2), dp.IntValue()) + case "min": + assert.Equal(t, int64(1), dp.IntValue()) + case "max": + assert.Equal(t, int64(3), dp.IntValue()) + } + _, ok := dp.Attributes().Get("disk_state") + assert.False(t, ok) + } case "vcenter.vm.disk.utilization": - assert.False(t, validatedMetrics["vcenter.vm.disk.utilization"], "Found a duplicate in the metrics slice: vcenter.vm.disk.utilization") - validatedMetrics["vcenter.vm.disk.utilization"] = true - assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) - assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) - assert.Equal(t, "The utilization of storage on the virtual machine.", ms.At(i).Description()) - assert.Equal(t, "%", ms.At(i).Unit()) - dp := ms.At(i).Gauge().DataPoints().At(0) - assert.Equal(t, start, dp.StartTimestamp()) - assert.Equal(t, ts, dp.Timestamp()) - assert.Equal(t, pmetric.NumberDataPointValueTypeDouble, dp.ValueType()) - assert.InDelta(t, float64(1), dp.DoubleValue(), 0.01) + if tt.name != "reaggregate_set" { + assert.False(t, validatedMetrics["vcenter.vm.disk.utilization"], "Found a duplicate in the metrics slice: vcenter.vm.disk.utilization") + validatedMetrics["vcenter.vm.disk.utilization"] = true + assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) + assert.Equal(t, "The utilization of storage on the virtual machine.", ms.At(i).Description()) + assert.Equal(t, "%", ms.At(i).Unit()) + dp := ms.At(i).Gauge().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeDouble, dp.ValueType()) + assert.InDelta(t, float64(1), dp.DoubleValue(), 0.01) + } else { + assert.False(t, validatedMetrics["vcenter.vm.disk.utilization"], "Found a duplicate in the metrics slice: vcenter.vm.disk.utilization") + validatedMetrics["vcenter.vm.disk.utilization"] = true + assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) + assert.Equal(t, "The utilization of storage on the virtual machine.", ms.At(i).Description()) + assert.Equal(t, "%", ms.At(i).Unit()) + dp := ms.At(i).Gauge().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeDouble, dp.ValueType()) + switch aggMap["vcenter.vm.disk.utilization"] { + case "sum": + assert.InDelta(t, float64(4), dp.DoubleValue(), 0.01) + case "avg": + assert.InDelta(t, float64(2), dp.DoubleValue(), 0.01) + case "min": + assert.InDelta(t, float64(1), dp.DoubleValue(), 0.01) + case "max": + assert.InDelta(t, float64(3), dp.DoubleValue(), 0.01) + } + } case "vcenter.vm.memory.ballooned": - assert.False(t, validatedMetrics["vcenter.vm.memory.ballooned"], "Found a duplicate in the metrics slice: vcenter.vm.memory.ballooned") - validatedMetrics["vcenter.vm.memory.ballooned"] = true - assert.Equal(t, pmetric.MetricTypeSum, ms.At(i).Type()) - assert.Equal(t, 1, ms.At(i).Sum().DataPoints().Len()) - assert.Equal(t, "The amount of memory that is ballooned due to virtualization.", ms.At(i).Description()) - assert.Equal(t, "MiBy", ms.At(i).Unit()) - assert.False(t, ms.At(i).Sum().IsMonotonic()) - assert.Equal(t, pmetric.AggregationTemporalityCumulative, ms.At(i).Sum().AggregationTemporality()) - dp := ms.At(i).Sum().DataPoints().At(0) - assert.Equal(t, start, dp.StartTimestamp()) - assert.Equal(t, ts, dp.Timestamp()) - assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) - assert.Equal(t, int64(1), dp.IntValue()) + if tt.name != "reaggregate_set" { + assert.False(t, validatedMetrics["vcenter.vm.memory.ballooned"], "Found a duplicate in the metrics slice: vcenter.vm.memory.ballooned") + validatedMetrics["vcenter.vm.memory.ballooned"] = true + assert.Equal(t, pmetric.MetricTypeSum, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Sum().DataPoints().Len()) + assert.Equal(t, "The amount of memory that is ballooned due to virtualization.", ms.At(i).Description()) + assert.Equal(t, "MiBy", ms.At(i).Unit()) + assert.False(t, ms.At(i).Sum().IsMonotonic()) + assert.Equal(t, pmetric.AggregationTemporalityCumulative, ms.At(i).Sum().AggregationTemporality()) + dp := ms.At(i).Sum().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) + assert.Equal(t, int64(1), dp.IntValue()) + } else { + assert.False(t, validatedMetrics["vcenter.vm.memory.ballooned"], "Found a duplicate in the metrics slice: vcenter.vm.memory.ballooned") + validatedMetrics["vcenter.vm.memory.ballooned"] = true + assert.Equal(t, pmetric.MetricTypeSum, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Sum().DataPoints().Len()) + assert.Equal(t, "The amount of memory that is ballooned due to virtualization.", ms.At(i).Description()) + assert.Equal(t, "MiBy", ms.At(i).Unit()) + assert.False(t, ms.At(i).Sum().IsMonotonic()) + assert.Equal(t, pmetric.AggregationTemporalityCumulative, ms.At(i).Sum().AggregationTemporality()) + dp := ms.At(i).Sum().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) + switch aggMap["vcenter.vm.memory.ballooned"] { + case "sum": + assert.Equal(t, int64(4), dp.IntValue()) + case "avg": + assert.Equal(t, int64(2), dp.IntValue()) + case "min": + assert.Equal(t, int64(1), dp.IntValue()) + case "max": + assert.Equal(t, int64(3), dp.IntValue()) + } + } case "vcenter.vm.memory.granted": - assert.False(t, validatedMetrics["vcenter.vm.memory.granted"], "Found a duplicate in the metrics slice: vcenter.vm.memory.granted") - validatedMetrics["vcenter.vm.memory.granted"] = true - assert.Equal(t, pmetric.MetricTypeSum, ms.At(i).Type()) - assert.Equal(t, 1, ms.At(i).Sum().DataPoints().Len()) - assert.Equal(t, "The amount of memory that is granted to a VM.", ms.At(i).Description()) - assert.Equal(t, "MiBy", ms.At(i).Unit()) - assert.False(t, ms.At(i).Sum().IsMonotonic()) - assert.Equal(t, pmetric.AggregationTemporalityCumulative, ms.At(i).Sum().AggregationTemporality()) - dp := ms.At(i).Sum().DataPoints().At(0) - assert.Equal(t, start, dp.StartTimestamp()) - assert.Equal(t, ts, dp.Timestamp()) - assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) - assert.Equal(t, int64(1), dp.IntValue()) + if tt.name != "reaggregate_set" { + assert.False(t, validatedMetrics["vcenter.vm.memory.granted"], "Found a duplicate in the metrics slice: vcenter.vm.memory.granted") + validatedMetrics["vcenter.vm.memory.granted"] = true + assert.Equal(t, pmetric.MetricTypeSum, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Sum().DataPoints().Len()) + assert.Equal(t, "The amount of memory that is granted to a VM.", ms.At(i).Description()) + assert.Equal(t, "MiBy", ms.At(i).Unit()) + assert.False(t, ms.At(i).Sum().IsMonotonic()) + assert.Equal(t, pmetric.AggregationTemporalityCumulative, ms.At(i).Sum().AggregationTemporality()) + dp := ms.At(i).Sum().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) + assert.Equal(t, int64(1), dp.IntValue()) + } else { + assert.False(t, validatedMetrics["vcenter.vm.memory.granted"], "Found a duplicate in the metrics slice: vcenter.vm.memory.granted") + validatedMetrics["vcenter.vm.memory.granted"] = true + assert.Equal(t, pmetric.MetricTypeSum, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Sum().DataPoints().Len()) + assert.Equal(t, "The amount of memory that is granted to a VM.", ms.At(i).Description()) + assert.Equal(t, "MiBy", ms.At(i).Unit()) + assert.False(t, ms.At(i).Sum().IsMonotonic()) + assert.Equal(t, pmetric.AggregationTemporalityCumulative, ms.At(i).Sum().AggregationTemporality()) + dp := ms.At(i).Sum().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) + switch aggMap["vcenter.vm.memory.granted"] { + case "sum": + assert.Equal(t, int64(4), dp.IntValue()) + case "avg": + assert.Equal(t, int64(2), dp.IntValue()) + case "min": + assert.Equal(t, int64(1), dp.IntValue()) + case "max": + assert.Equal(t, int64(3), dp.IntValue()) + } + } case "vcenter.vm.memory.swapped": - assert.False(t, validatedMetrics["vcenter.vm.memory.swapped"], "Found a duplicate in the metrics slice: vcenter.vm.memory.swapped") - validatedMetrics["vcenter.vm.memory.swapped"] = true - assert.Equal(t, pmetric.MetricTypeSum, ms.At(i).Type()) - assert.Equal(t, 1, ms.At(i).Sum().DataPoints().Len()) - assert.Equal(t, "The portion of memory that is granted to this VM from the host's swap space.", ms.At(i).Description()) - assert.Equal(t, "MiBy", ms.At(i).Unit()) - assert.False(t, ms.At(i).Sum().IsMonotonic()) - assert.Equal(t, pmetric.AggregationTemporalityCumulative, ms.At(i).Sum().AggregationTemporality()) - dp := ms.At(i).Sum().DataPoints().At(0) - assert.Equal(t, start, dp.StartTimestamp()) - assert.Equal(t, ts, dp.Timestamp()) - assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) - assert.Equal(t, int64(1), dp.IntValue()) + if tt.name != "reaggregate_set" { + assert.False(t, validatedMetrics["vcenter.vm.memory.swapped"], "Found a duplicate in the metrics slice: vcenter.vm.memory.swapped") + validatedMetrics["vcenter.vm.memory.swapped"] = true + assert.Equal(t, pmetric.MetricTypeSum, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Sum().DataPoints().Len()) + assert.Equal(t, "The portion of memory that is granted to this VM from the host's swap space.", ms.At(i).Description()) + assert.Equal(t, "MiBy", ms.At(i).Unit()) + assert.False(t, ms.At(i).Sum().IsMonotonic()) + assert.Equal(t, pmetric.AggregationTemporalityCumulative, ms.At(i).Sum().AggregationTemporality()) + dp := ms.At(i).Sum().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) + assert.Equal(t, int64(1), dp.IntValue()) + } else { + assert.False(t, validatedMetrics["vcenter.vm.memory.swapped"], "Found a duplicate in the metrics slice: vcenter.vm.memory.swapped") + validatedMetrics["vcenter.vm.memory.swapped"] = true + assert.Equal(t, pmetric.MetricTypeSum, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Sum().DataPoints().Len()) + assert.Equal(t, "The portion of memory that is granted to this VM from the host's swap space.", ms.At(i).Description()) + assert.Equal(t, "MiBy", ms.At(i).Unit()) + assert.False(t, ms.At(i).Sum().IsMonotonic()) + assert.Equal(t, pmetric.AggregationTemporalityCumulative, ms.At(i).Sum().AggregationTemporality()) + dp := ms.At(i).Sum().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) + switch aggMap["vcenter.vm.memory.swapped"] { + case "sum": + assert.Equal(t, int64(4), dp.IntValue()) + case "avg": + assert.Equal(t, int64(2), dp.IntValue()) + case "min": + assert.Equal(t, int64(1), dp.IntValue()) + case "max": + assert.Equal(t, int64(3), dp.IntValue()) + } + } case "vcenter.vm.memory.swapped_ssd": - assert.False(t, validatedMetrics["vcenter.vm.memory.swapped_ssd"], "Found a duplicate in the metrics slice: vcenter.vm.memory.swapped_ssd") - validatedMetrics["vcenter.vm.memory.swapped_ssd"] = true - assert.Equal(t, pmetric.MetricTypeSum, ms.At(i).Type()) - assert.Equal(t, 1, ms.At(i).Sum().DataPoints().Len()) - assert.Equal(t, "The amount of memory swapped to fast disk device such as SSD.", ms.At(i).Description()) - assert.Equal(t, "KiBy", ms.At(i).Unit()) - assert.False(t, ms.At(i).Sum().IsMonotonic()) - assert.Equal(t, pmetric.AggregationTemporalityCumulative, ms.At(i).Sum().AggregationTemporality()) - dp := ms.At(i).Sum().DataPoints().At(0) - assert.Equal(t, start, dp.StartTimestamp()) - assert.Equal(t, ts, dp.Timestamp()) - assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) - assert.Equal(t, int64(1), dp.IntValue()) + if tt.name != "reaggregate_set" { + assert.False(t, validatedMetrics["vcenter.vm.memory.swapped_ssd"], "Found a duplicate in the metrics slice: vcenter.vm.memory.swapped_ssd") + validatedMetrics["vcenter.vm.memory.swapped_ssd"] = true + assert.Equal(t, pmetric.MetricTypeSum, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Sum().DataPoints().Len()) + assert.Equal(t, "The amount of memory swapped to fast disk device such as SSD.", ms.At(i).Description()) + assert.Equal(t, "KiBy", ms.At(i).Unit()) + assert.False(t, ms.At(i).Sum().IsMonotonic()) + assert.Equal(t, pmetric.AggregationTemporalityCumulative, ms.At(i).Sum().AggregationTemporality()) + dp := ms.At(i).Sum().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) + assert.Equal(t, int64(1), dp.IntValue()) + } else { + assert.False(t, validatedMetrics["vcenter.vm.memory.swapped_ssd"], "Found a duplicate in the metrics slice: vcenter.vm.memory.swapped_ssd") + validatedMetrics["vcenter.vm.memory.swapped_ssd"] = true + assert.Equal(t, pmetric.MetricTypeSum, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Sum().DataPoints().Len()) + assert.Equal(t, "The amount of memory swapped to fast disk device such as SSD.", ms.At(i).Description()) + assert.Equal(t, "KiBy", ms.At(i).Unit()) + assert.False(t, ms.At(i).Sum().IsMonotonic()) + assert.Equal(t, pmetric.AggregationTemporalityCumulative, ms.At(i).Sum().AggregationTemporality()) + dp := ms.At(i).Sum().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) + switch aggMap["vcenter.vm.memory.swapped_ssd"] { + case "sum": + assert.Equal(t, int64(4), dp.IntValue()) + case "avg": + assert.Equal(t, int64(2), dp.IntValue()) + case "min": + assert.Equal(t, int64(1), dp.IntValue()) + case "max": + assert.Equal(t, int64(3), dp.IntValue()) + } + } case "vcenter.vm.memory.usage": - assert.False(t, validatedMetrics["vcenter.vm.memory.usage"], "Found a duplicate in the metrics slice: vcenter.vm.memory.usage") - validatedMetrics["vcenter.vm.memory.usage"] = true - assert.Equal(t, pmetric.MetricTypeSum, ms.At(i).Type()) - assert.Equal(t, 1, ms.At(i).Sum().DataPoints().Len()) - assert.Equal(t, "The amount of memory that is used by the virtual machine.", ms.At(i).Description()) - assert.Equal(t, "MiBy", ms.At(i).Unit()) - assert.False(t, ms.At(i).Sum().IsMonotonic()) - assert.Equal(t, pmetric.AggregationTemporalityCumulative, ms.At(i).Sum().AggregationTemporality()) - dp := ms.At(i).Sum().DataPoints().At(0) - assert.Equal(t, start, dp.StartTimestamp()) - assert.Equal(t, ts, dp.Timestamp()) - assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) - assert.Equal(t, int64(1), dp.IntValue()) + if tt.name != "reaggregate_set" { + assert.False(t, validatedMetrics["vcenter.vm.memory.usage"], "Found a duplicate in the metrics slice: vcenter.vm.memory.usage") + validatedMetrics["vcenter.vm.memory.usage"] = true + assert.Equal(t, pmetric.MetricTypeSum, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Sum().DataPoints().Len()) + assert.Equal(t, "The amount of memory that is used by the virtual machine.", ms.At(i).Description()) + assert.Equal(t, "MiBy", ms.At(i).Unit()) + assert.False(t, ms.At(i).Sum().IsMonotonic()) + assert.Equal(t, pmetric.AggregationTemporalityCumulative, ms.At(i).Sum().AggregationTemporality()) + dp := ms.At(i).Sum().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) + assert.Equal(t, int64(1), dp.IntValue()) + } else { + assert.False(t, validatedMetrics["vcenter.vm.memory.usage"], "Found a duplicate in the metrics slice: vcenter.vm.memory.usage") + validatedMetrics["vcenter.vm.memory.usage"] = true + assert.Equal(t, pmetric.MetricTypeSum, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Sum().DataPoints().Len()) + assert.Equal(t, "The amount of memory that is used by the virtual machine.", ms.At(i).Description()) + assert.Equal(t, "MiBy", ms.At(i).Unit()) + assert.False(t, ms.At(i).Sum().IsMonotonic()) + assert.Equal(t, pmetric.AggregationTemporalityCumulative, ms.At(i).Sum().AggregationTemporality()) + dp := ms.At(i).Sum().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) + switch aggMap["vcenter.vm.memory.usage"] { + case "sum": + assert.Equal(t, int64(4), dp.IntValue()) + case "avg": + assert.Equal(t, int64(2), dp.IntValue()) + case "min": + assert.Equal(t, int64(1), dp.IntValue()) + case "max": + assert.Equal(t, int64(3), dp.IntValue()) + } + } case "vcenter.vm.memory.utilization": - assert.False(t, validatedMetrics["vcenter.vm.memory.utilization"], "Found a duplicate in the metrics slice: vcenter.vm.memory.utilization") - validatedMetrics["vcenter.vm.memory.utilization"] = true - assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) - assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) - assert.Equal(t, "The memory utilization of the VM.", ms.At(i).Description()) - assert.Equal(t, "%", ms.At(i).Unit()) - dp := ms.At(i).Gauge().DataPoints().At(0) - assert.Equal(t, start, dp.StartTimestamp()) - assert.Equal(t, ts, dp.Timestamp()) - assert.Equal(t, pmetric.NumberDataPointValueTypeDouble, dp.ValueType()) - assert.InDelta(t, float64(1), dp.DoubleValue(), 0.01) + if tt.name != "reaggregate_set" { + assert.False(t, validatedMetrics["vcenter.vm.memory.utilization"], "Found a duplicate in the metrics slice: vcenter.vm.memory.utilization") + validatedMetrics["vcenter.vm.memory.utilization"] = true + assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) + assert.Equal(t, "The memory utilization of the VM.", ms.At(i).Description()) + assert.Equal(t, "%", ms.At(i).Unit()) + dp := ms.At(i).Gauge().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeDouble, dp.ValueType()) + assert.InDelta(t, float64(1), dp.DoubleValue(), 0.01) + } else { + assert.False(t, validatedMetrics["vcenter.vm.memory.utilization"], "Found a duplicate in the metrics slice: vcenter.vm.memory.utilization") + validatedMetrics["vcenter.vm.memory.utilization"] = true + assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) + assert.Equal(t, "The memory utilization of the VM.", ms.At(i).Description()) + assert.Equal(t, "%", ms.At(i).Unit()) + dp := ms.At(i).Gauge().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeDouble, dp.ValueType()) + switch aggMap["vcenter.vm.memory.utilization"] { + case "sum": + assert.InDelta(t, float64(4), dp.DoubleValue(), 0.01) + case "avg": + assert.InDelta(t, float64(2), dp.DoubleValue(), 0.01) + case "min": + assert.InDelta(t, float64(1), dp.DoubleValue(), 0.01) + case "max": + assert.InDelta(t, float64(3), dp.DoubleValue(), 0.01) + } + } case "vcenter.vm.network.broadcast.packet.rate": - assert.False(t, validatedMetrics["vcenter.vm.network.broadcast.packet.rate"], "Found a duplicate in the metrics slice: vcenter.vm.network.broadcast.packet.rate") - validatedMetrics["vcenter.vm.network.broadcast.packet.rate"] = true - assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) - assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) - assert.Equal(t, "The rate of broadcast packets transmitted or received by each vNIC (virtual network interface controller) on the virtual machine.", ms.At(i).Description()) - assert.Equal(t, "{packets/s}", ms.At(i).Unit()) - dp := ms.At(i).Gauge().DataPoints().At(0) - assert.Equal(t, start, dp.StartTimestamp()) - assert.Equal(t, ts, dp.Timestamp()) - assert.Equal(t, pmetric.NumberDataPointValueTypeDouble, dp.ValueType()) - assert.InDelta(t, float64(1), dp.DoubleValue(), 0.01) - attrVal, ok := dp.Attributes().Get("direction") - assert.True(t, ok) - assert.Equal(t, "transmitted", attrVal.Str()) - attrVal, ok = dp.Attributes().Get("object") - assert.True(t, ok) - assert.Equal(t, "object_name-val", attrVal.Str()) + if tt.name != "reaggregate_set" { + assert.False(t, validatedMetrics["vcenter.vm.network.broadcast.packet.rate"], "Found a duplicate in the metrics slice: vcenter.vm.network.broadcast.packet.rate") + validatedMetrics["vcenter.vm.network.broadcast.packet.rate"] = true + assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) + assert.Equal(t, "The rate of broadcast packets transmitted or received by each vNIC (virtual network interface controller) on the virtual machine.", ms.At(i).Description()) + assert.Equal(t, "{packets/s}", ms.At(i).Unit()) + dp := ms.At(i).Gauge().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeDouble, dp.ValueType()) + assert.InDelta(t, float64(1), dp.DoubleValue(), 0.01) + attrVal, ok := dp.Attributes().Get("direction") + assert.True(t, ok) + assert.Equal(t, "transmitted", attrVal.Str()) + attrVal, ok = dp.Attributes().Get("object") + assert.True(t, ok) + assert.Equal(t, "object_name-val", attrVal.Str()) + } else { + assert.False(t, validatedMetrics["vcenter.vm.network.broadcast.packet.rate"], "Found a duplicate in the metrics slice: vcenter.vm.network.broadcast.packet.rate") + validatedMetrics["vcenter.vm.network.broadcast.packet.rate"] = true + assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) + assert.Equal(t, "The rate of broadcast packets transmitted or received by each vNIC (virtual network interface controller) on the virtual machine.", ms.At(i).Description()) + assert.Equal(t, "{packets/s}", ms.At(i).Unit()) + dp := ms.At(i).Gauge().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeDouble, dp.ValueType()) + switch aggMap["vcenter.vm.network.broadcast.packet.rate"] { + case "sum": + assert.InDelta(t, float64(4), dp.DoubleValue(), 0.01) + case "avg": + assert.InDelta(t, float64(2), dp.DoubleValue(), 0.01) + case "min": + assert.InDelta(t, float64(1), dp.DoubleValue(), 0.01) + case "max": + assert.InDelta(t, float64(3), dp.DoubleValue(), 0.01) + } + _, ok := dp.Attributes().Get("direction") + assert.False(t, ok) + _, ok = dp.Attributes().Get("object") + assert.False(t, ok) + } case "vcenter.vm.network.multicast.packet.rate": - assert.False(t, validatedMetrics["vcenter.vm.network.multicast.packet.rate"], "Found a duplicate in the metrics slice: vcenter.vm.network.multicast.packet.rate") - validatedMetrics["vcenter.vm.network.multicast.packet.rate"] = true - assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) - assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) - assert.Equal(t, "The rate of multicast packets transmitted or received by each vNIC (virtual network interface controller) on the virtual machine.", ms.At(i).Description()) - assert.Equal(t, "{packets/s}", ms.At(i).Unit()) - dp := ms.At(i).Gauge().DataPoints().At(0) - assert.Equal(t, start, dp.StartTimestamp()) - assert.Equal(t, ts, dp.Timestamp()) - assert.Equal(t, pmetric.NumberDataPointValueTypeDouble, dp.ValueType()) - assert.InDelta(t, float64(1), dp.DoubleValue(), 0.01) - attrVal, ok := dp.Attributes().Get("direction") - assert.True(t, ok) - assert.Equal(t, "transmitted", attrVal.Str()) - attrVal, ok = dp.Attributes().Get("object") - assert.True(t, ok) - assert.Equal(t, "object_name-val", attrVal.Str()) + if tt.name != "reaggregate_set" { + assert.False(t, validatedMetrics["vcenter.vm.network.multicast.packet.rate"], "Found a duplicate in the metrics slice: vcenter.vm.network.multicast.packet.rate") + validatedMetrics["vcenter.vm.network.multicast.packet.rate"] = true + assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) + assert.Equal(t, "The rate of multicast packets transmitted or received by each vNIC (virtual network interface controller) on the virtual machine.", ms.At(i).Description()) + assert.Equal(t, "{packets/s}", ms.At(i).Unit()) + dp := ms.At(i).Gauge().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeDouble, dp.ValueType()) + assert.InDelta(t, float64(1), dp.DoubleValue(), 0.01) + attrVal, ok := dp.Attributes().Get("direction") + assert.True(t, ok) + assert.Equal(t, "transmitted", attrVal.Str()) + attrVal, ok = dp.Attributes().Get("object") + assert.True(t, ok) + assert.Equal(t, "object_name-val", attrVal.Str()) + } else { + assert.False(t, validatedMetrics["vcenter.vm.network.multicast.packet.rate"], "Found a duplicate in the metrics slice: vcenter.vm.network.multicast.packet.rate") + validatedMetrics["vcenter.vm.network.multicast.packet.rate"] = true + assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) + assert.Equal(t, "The rate of multicast packets transmitted or received by each vNIC (virtual network interface controller) on the virtual machine.", ms.At(i).Description()) + assert.Equal(t, "{packets/s}", ms.At(i).Unit()) + dp := ms.At(i).Gauge().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeDouble, dp.ValueType()) + switch aggMap["vcenter.vm.network.multicast.packet.rate"] { + case "sum": + assert.InDelta(t, float64(4), dp.DoubleValue(), 0.01) + case "avg": + assert.InDelta(t, float64(2), dp.DoubleValue(), 0.01) + case "min": + assert.InDelta(t, float64(1), dp.DoubleValue(), 0.01) + case "max": + assert.InDelta(t, float64(3), dp.DoubleValue(), 0.01) + } + _, ok := dp.Attributes().Get("direction") + assert.False(t, ok) + _, ok = dp.Attributes().Get("object") + assert.False(t, ok) + } case "vcenter.vm.network.packet.drop.rate": - assert.False(t, validatedMetrics["vcenter.vm.network.packet.drop.rate"], "Found a duplicate in the metrics slice: vcenter.vm.network.packet.drop.rate") - validatedMetrics["vcenter.vm.network.packet.drop.rate"] = true - assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) - assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) - assert.Equal(t, "The rate of transmitted or received packets dropped by each vNIC (virtual network interface controller) on the virtual machine.", ms.At(i).Description()) - assert.Equal(t, "{packets/s}", ms.At(i).Unit()) - dp := ms.At(i).Gauge().DataPoints().At(0) - assert.Equal(t, start, dp.StartTimestamp()) - assert.Equal(t, ts, dp.Timestamp()) - assert.Equal(t, pmetric.NumberDataPointValueTypeDouble, dp.ValueType()) - assert.InDelta(t, float64(1), dp.DoubleValue(), 0.01) - attrVal, ok := dp.Attributes().Get("direction") - assert.True(t, ok) - assert.Equal(t, "transmitted", attrVal.Str()) - attrVal, ok = dp.Attributes().Get("object") - assert.True(t, ok) - assert.Equal(t, "object_name-val", attrVal.Str()) + if tt.name != "reaggregate_set" { + assert.False(t, validatedMetrics["vcenter.vm.network.packet.drop.rate"], "Found a duplicate in the metrics slice: vcenter.vm.network.packet.drop.rate") + validatedMetrics["vcenter.vm.network.packet.drop.rate"] = true + assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) + assert.Equal(t, "The rate of transmitted or received packets dropped by each vNIC (virtual network interface controller) on the virtual machine.", ms.At(i).Description()) + assert.Equal(t, "{packets/s}", ms.At(i).Unit()) + dp := ms.At(i).Gauge().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeDouble, dp.ValueType()) + assert.InDelta(t, float64(1), dp.DoubleValue(), 0.01) + attrVal, ok := dp.Attributes().Get("direction") + assert.True(t, ok) + assert.Equal(t, "transmitted", attrVal.Str()) + attrVal, ok = dp.Attributes().Get("object") + assert.True(t, ok) + assert.Equal(t, "object_name-val", attrVal.Str()) + } else { + assert.False(t, validatedMetrics["vcenter.vm.network.packet.drop.rate"], "Found a duplicate in the metrics slice: vcenter.vm.network.packet.drop.rate") + validatedMetrics["vcenter.vm.network.packet.drop.rate"] = true + assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) + assert.Equal(t, "The rate of transmitted or received packets dropped by each vNIC (virtual network interface controller) on the virtual machine.", ms.At(i).Description()) + assert.Equal(t, "{packets/s}", ms.At(i).Unit()) + dp := ms.At(i).Gauge().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeDouble, dp.ValueType()) + switch aggMap["vcenter.vm.network.packet.drop.rate"] { + case "sum": + assert.InDelta(t, float64(4), dp.DoubleValue(), 0.01) + case "avg": + assert.InDelta(t, float64(2), dp.DoubleValue(), 0.01) + case "min": + assert.InDelta(t, float64(1), dp.DoubleValue(), 0.01) + case "max": + assert.InDelta(t, float64(3), dp.DoubleValue(), 0.01) + } + _, ok := dp.Attributes().Get("direction") + assert.False(t, ok) + _, ok = dp.Attributes().Get("object") + assert.False(t, ok) + } case "vcenter.vm.network.packet.rate": - assert.False(t, validatedMetrics["vcenter.vm.network.packet.rate"], "Found a duplicate in the metrics slice: vcenter.vm.network.packet.rate") - validatedMetrics["vcenter.vm.network.packet.rate"] = true - assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) - assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) - assert.Equal(t, "The rate of packets transmitted or received by each vNIC (virtual network interface controller) on the virtual machine.", ms.At(i).Description()) - assert.Equal(t, "{packets/s}", ms.At(i).Unit()) - dp := ms.At(i).Gauge().DataPoints().At(0) - assert.Equal(t, start, dp.StartTimestamp()) - assert.Equal(t, ts, dp.Timestamp()) - assert.Equal(t, pmetric.NumberDataPointValueTypeDouble, dp.ValueType()) - assert.InDelta(t, float64(1), dp.DoubleValue(), 0.01) - attrVal, ok := dp.Attributes().Get("direction") - assert.True(t, ok) - assert.Equal(t, "transmitted", attrVal.Str()) - attrVal, ok = dp.Attributes().Get("object") - assert.True(t, ok) - assert.Equal(t, "object_name-val", attrVal.Str()) + if tt.name != "reaggregate_set" { + assert.False(t, validatedMetrics["vcenter.vm.network.packet.rate"], "Found a duplicate in the metrics slice: vcenter.vm.network.packet.rate") + validatedMetrics["vcenter.vm.network.packet.rate"] = true + assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) + assert.Equal(t, "The rate of packets transmitted or received by each vNIC (virtual network interface controller) on the virtual machine.", ms.At(i).Description()) + assert.Equal(t, "{packets/s}", ms.At(i).Unit()) + dp := ms.At(i).Gauge().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeDouble, dp.ValueType()) + assert.InDelta(t, float64(1), dp.DoubleValue(), 0.01) + attrVal, ok := dp.Attributes().Get("direction") + assert.True(t, ok) + assert.Equal(t, "transmitted", attrVal.Str()) + attrVal, ok = dp.Attributes().Get("object") + assert.True(t, ok) + assert.Equal(t, "object_name-val", attrVal.Str()) + } else { + assert.False(t, validatedMetrics["vcenter.vm.network.packet.rate"], "Found a duplicate in the metrics slice: vcenter.vm.network.packet.rate") + validatedMetrics["vcenter.vm.network.packet.rate"] = true + assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) + assert.Equal(t, "The rate of packets transmitted or received by each vNIC (virtual network interface controller) on the virtual machine.", ms.At(i).Description()) + assert.Equal(t, "{packets/s}", ms.At(i).Unit()) + dp := ms.At(i).Gauge().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeDouble, dp.ValueType()) + switch aggMap["vcenter.vm.network.packet.rate"] { + case "sum": + assert.InDelta(t, float64(4), dp.DoubleValue(), 0.01) + case "avg": + assert.InDelta(t, float64(2), dp.DoubleValue(), 0.01) + case "min": + assert.InDelta(t, float64(1), dp.DoubleValue(), 0.01) + case "max": + assert.InDelta(t, float64(3), dp.DoubleValue(), 0.01) + } + _, ok := dp.Attributes().Get("direction") + assert.False(t, ok) + _, ok = dp.Attributes().Get("object") + assert.False(t, ok) + } case "vcenter.vm.network.throughput": - assert.False(t, validatedMetrics["vcenter.vm.network.throughput"], "Found a duplicate in the metrics slice: vcenter.vm.network.throughput") - validatedMetrics["vcenter.vm.network.throughput"] = true - assert.Equal(t, pmetric.MetricTypeSum, ms.At(i).Type()) - assert.Equal(t, 1, ms.At(i).Sum().DataPoints().Len()) - assert.Equal(t, "The amount of data that was transmitted or received over the network of the virtual machine.", ms.At(i).Description()) - assert.Equal(t, "By/s", ms.At(i).Unit()) - assert.False(t, ms.At(i).Sum().IsMonotonic()) - assert.Equal(t, pmetric.AggregationTemporalityCumulative, ms.At(i).Sum().AggregationTemporality()) - dp := ms.At(i).Sum().DataPoints().At(0) - assert.Equal(t, start, dp.StartTimestamp()) - assert.Equal(t, ts, dp.Timestamp()) - assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) - assert.Equal(t, int64(1), dp.IntValue()) - attrVal, ok := dp.Attributes().Get("direction") - assert.True(t, ok) - assert.Equal(t, "transmitted", attrVal.Str()) - attrVal, ok = dp.Attributes().Get("object") - assert.True(t, ok) - assert.Equal(t, "object_name-val", attrVal.Str()) + if tt.name != "reaggregate_set" { + assert.False(t, validatedMetrics["vcenter.vm.network.throughput"], "Found a duplicate in the metrics slice: vcenter.vm.network.throughput") + validatedMetrics["vcenter.vm.network.throughput"] = true + assert.Equal(t, pmetric.MetricTypeSum, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Sum().DataPoints().Len()) + assert.Equal(t, "The amount of data that was transmitted or received over the network of the virtual machine.", ms.At(i).Description()) + assert.Equal(t, "By/s", ms.At(i).Unit()) + assert.False(t, ms.At(i).Sum().IsMonotonic()) + assert.Equal(t, pmetric.AggregationTemporalityCumulative, ms.At(i).Sum().AggregationTemporality()) + dp := ms.At(i).Sum().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) + assert.Equal(t, int64(1), dp.IntValue()) + attrVal, ok := dp.Attributes().Get("direction") + assert.True(t, ok) + assert.Equal(t, "transmitted", attrVal.Str()) + attrVal, ok = dp.Attributes().Get("object") + assert.True(t, ok) + assert.Equal(t, "object_name-val", attrVal.Str()) + } else { + assert.False(t, validatedMetrics["vcenter.vm.network.throughput"], "Found a duplicate in the metrics slice: vcenter.vm.network.throughput") + validatedMetrics["vcenter.vm.network.throughput"] = true + assert.Equal(t, pmetric.MetricTypeSum, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Sum().DataPoints().Len()) + assert.Equal(t, "The amount of data that was transmitted or received over the network of the virtual machine.", ms.At(i).Description()) + assert.Equal(t, "By/s", ms.At(i).Unit()) + assert.False(t, ms.At(i).Sum().IsMonotonic()) + assert.Equal(t, pmetric.AggregationTemporalityCumulative, ms.At(i).Sum().AggregationTemporality()) + dp := ms.At(i).Sum().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) + switch aggMap["vcenter.vm.network.throughput"] { + case "sum": + assert.Equal(t, int64(4), dp.IntValue()) + case "avg": + assert.Equal(t, int64(2), dp.IntValue()) + case "min": + assert.Equal(t, int64(1), dp.IntValue()) + case "max": + assert.Equal(t, int64(3), dp.IntValue()) + } + _, ok := dp.Attributes().Get("direction") + assert.False(t, ok) + _, ok = dp.Attributes().Get("object") + assert.False(t, ok) + } case "vcenter.vm.network.usage": - assert.False(t, validatedMetrics["vcenter.vm.network.usage"], "Found a duplicate in the metrics slice: vcenter.vm.network.usage") - validatedMetrics["vcenter.vm.network.usage"] = true - assert.Equal(t, pmetric.MetricTypeSum, ms.At(i).Type()) - assert.Equal(t, 1, ms.At(i).Sum().DataPoints().Len()) - assert.Equal(t, "The network utilization combined transmit and receive rates during an interval.", ms.At(i).Description()) - assert.Equal(t, "{KiBy/s}", ms.At(i).Unit()) - assert.False(t, ms.At(i).Sum().IsMonotonic()) - assert.Equal(t, pmetric.AggregationTemporalityCumulative, ms.At(i).Sum().AggregationTemporality()) - dp := ms.At(i).Sum().DataPoints().At(0) - assert.Equal(t, start, dp.StartTimestamp()) - assert.Equal(t, ts, dp.Timestamp()) - assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) - assert.Equal(t, int64(1), dp.IntValue()) - attrVal, ok := dp.Attributes().Get("object") - assert.True(t, ok) - assert.Equal(t, "object_name-val", attrVal.Str()) + if tt.name != "reaggregate_set" { + assert.False(t, validatedMetrics["vcenter.vm.network.usage"], "Found a duplicate in the metrics slice: vcenter.vm.network.usage") + validatedMetrics["vcenter.vm.network.usage"] = true + assert.Equal(t, pmetric.MetricTypeSum, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Sum().DataPoints().Len()) + assert.Equal(t, "The network utilization combined transmit and receive rates during an interval.", ms.At(i).Description()) + assert.Equal(t, "{KiBy/s}", ms.At(i).Unit()) + assert.False(t, ms.At(i).Sum().IsMonotonic()) + assert.Equal(t, pmetric.AggregationTemporalityCumulative, ms.At(i).Sum().AggregationTemporality()) + dp := ms.At(i).Sum().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) + assert.Equal(t, int64(1), dp.IntValue()) + attrVal, ok := dp.Attributes().Get("object") + assert.True(t, ok) + assert.Equal(t, "object_name-val", attrVal.Str()) + } else { + assert.False(t, validatedMetrics["vcenter.vm.network.usage"], "Found a duplicate in the metrics slice: vcenter.vm.network.usage") + validatedMetrics["vcenter.vm.network.usage"] = true + assert.Equal(t, pmetric.MetricTypeSum, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Sum().DataPoints().Len()) + assert.Equal(t, "The network utilization combined transmit and receive rates during an interval.", ms.At(i).Description()) + assert.Equal(t, "{KiBy/s}", ms.At(i).Unit()) + assert.False(t, ms.At(i).Sum().IsMonotonic()) + assert.Equal(t, pmetric.AggregationTemporalityCumulative, ms.At(i).Sum().AggregationTemporality()) + dp := ms.At(i).Sum().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) + switch aggMap["vcenter.vm.network.usage"] { + case "sum": + assert.Equal(t, int64(4), dp.IntValue()) + case "avg": + assert.Equal(t, int64(2), dp.IntValue()) + case "min": + assert.Equal(t, int64(1), dp.IntValue()) + case "max": + assert.Equal(t, int64(3), dp.IntValue()) + } + _, ok := dp.Attributes().Get("object") + assert.False(t, ok) + } case "vcenter.vm.vsan.latency.avg": - assert.False(t, validatedMetrics["vcenter.vm.vsan.latency.avg"], "Found a duplicate in the metrics slice: vcenter.vm.vsan.latency.avg") - validatedMetrics["vcenter.vm.vsan.latency.avg"] = true - assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) - assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) - assert.Equal(t, "The virtual machine latency while accessing vSAN storage.", ms.At(i).Description()) - assert.Equal(t, "us", ms.At(i).Unit()) - dp := ms.At(i).Gauge().DataPoints().At(0) - assert.Equal(t, start, dp.StartTimestamp()) - assert.Equal(t, ts, dp.Timestamp()) - assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) - assert.Equal(t, int64(1), dp.IntValue()) - attrVal, ok := dp.Attributes().Get("type") - assert.True(t, ok) - assert.Equal(t, "read", attrVal.Str()) + if tt.name != "reaggregate_set" { + assert.False(t, validatedMetrics["vcenter.vm.vsan.latency.avg"], "Found a duplicate in the metrics slice: vcenter.vm.vsan.latency.avg") + validatedMetrics["vcenter.vm.vsan.latency.avg"] = true + assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) + assert.Equal(t, "The virtual machine latency while accessing vSAN storage.", ms.At(i).Description()) + assert.Equal(t, "us", ms.At(i).Unit()) + dp := ms.At(i).Gauge().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) + assert.Equal(t, int64(1), dp.IntValue()) + attrVal, ok := dp.Attributes().Get("type") + assert.True(t, ok) + assert.Equal(t, "read", attrVal.Str()) + } else { + assert.False(t, validatedMetrics["vcenter.vm.vsan.latency.avg"], "Found a duplicate in the metrics slice: vcenter.vm.vsan.latency.avg") + validatedMetrics["vcenter.vm.vsan.latency.avg"] = true + assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) + assert.Equal(t, "The virtual machine latency while accessing vSAN storage.", ms.At(i).Description()) + assert.Equal(t, "us", ms.At(i).Unit()) + dp := ms.At(i).Gauge().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) + switch aggMap["vcenter.vm.vsan.latency.avg"] { + case "sum": + assert.Equal(t, int64(4), dp.IntValue()) + case "avg": + assert.Equal(t, int64(2), dp.IntValue()) + case "min": + assert.Equal(t, int64(1), dp.IntValue()) + case "max": + assert.Equal(t, int64(3), dp.IntValue()) + } + _, ok := dp.Attributes().Get("type") + assert.False(t, ok) + } case "vcenter.vm.vsan.operations": - assert.False(t, validatedMetrics["vcenter.vm.vsan.operations"], "Found a duplicate in the metrics slice: vcenter.vm.vsan.operations") - validatedMetrics["vcenter.vm.vsan.operations"] = true - assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) - assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) - assert.Equal(t, "The vSAN IOPs of a virtual machine.", ms.At(i).Description()) - assert.Equal(t, "{operations/s}", ms.At(i).Unit()) - dp := ms.At(i).Gauge().DataPoints().At(0) - assert.Equal(t, start, dp.StartTimestamp()) - assert.Equal(t, ts, dp.Timestamp()) - assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) - assert.Equal(t, int64(1), dp.IntValue()) - attrVal, ok := dp.Attributes().Get("type") - assert.True(t, ok) - assert.Equal(t, "read", attrVal.Str()) + if tt.name != "reaggregate_set" { + assert.False(t, validatedMetrics["vcenter.vm.vsan.operations"], "Found a duplicate in the metrics slice: vcenter.vm.vsan.operations") + validatedMetrics["vcenter.vm.vsan.operations"] = true + assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) + assert.Equal(t, "The vSAN IOPs of a virtual machine.", ms.At(i).Description()) + assert.Equal(t, "{operations/s}", ms.At(i).Unit()) + dp := ms.At(i).Gauge().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) + assert.Equal(t, int64(1), dp.IntValue()) + attrVal, ok := dp.Attributes().Get("type") + assert.True(t, ok) + assert.Equal(t, "read", attrVal.Str()) + } else { + assert.False(t, validatedMetrics["vcenter.vm.vsan.operations"], "Found a duplicate in the metrics slice: vcenter.vm.vsan.operations") + validatedMetrics["vcenter.vm.vsan.operations"] = true + assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) + assert.Equal(t, "The vSAN IOPs of a virtual machine.", ms.At(i).Description()) + assert.Equal(t, "{operations/s}", ms.At(i).Unit()) + dp := ms.At(i).Gauge().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType()) + switch aggMap["vcenter.vm.vsan.operations"] { + case "sum": + assert.Equal(t, int64(4), dp.IntValue()) + case "avg": + assert.Equal(t, int64(2), dp.IntValue()) + case "min": + assert.Equal(t, int64(1), dp.IntValue()) + case "max": + assert.Equal(t, int64(3), dp.IntValue()) + } + _, ok := dp.Attributes().Get("type") + assert.False(t, ok) + } case "vcenter.vm.vsan.throughput": - assert.False(t, validatedMetrics["vcenter.vm.vsan.throughput"], "Found a duplicate in the metrics slice: vcenter.vm.vsan.throughput") - validatedMetrics["vcenter.vm.vsan.throughput"] = true - assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) - assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) - assert.Equal(t, "The vSAN throughput of a virtual machine.", ms.At(i).Description()) - assert.Equal(t, "By/s", ms.At(i).Unit()) - dp := ms.At(i).Gauge().DataPoints().At(0) - assert.Equal(t, start, dp.StartTimestamp()) - assert.Equal(t, ts, dp.Timestamp()) - assert.Equal(t, pmetric.NumberDataPointValueTypeDouble, dp.ValueType()) - assert.InDelta(t, float64(1), dp.DoubleValue(), 0.01) - attrVal, ok := dp.Attributes().Get("direction") - assert.True(t, ok) - assert.Equal(t, "read", attrVal.Str()) + if tt.name != "reaggregate_set" { + assert.False(t, validatedMetrics["vcenter.vm.vsan.throughput"], "Found a duplicate in the metrics slice: vcenter.vm.vsan.throughput") + validatedMetrics["vcenter.vm.vsan.throughput"] = true + assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) + assert.Equal(t, "The vSAN throughput of a virtual machine.", ms.At(i).Description()) + assert.Equal(t, "By/s", ms.At(i).Unit()) + dp := ms.At(i).Gauge().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeDouble, dp.ValueType()) + assert.InDelta(t, float64(1), dp.DoubleValue(), 0.01) + attrVal, ok := dp.Attributes().Get("direction") + assert.True(t, ok) + assert.Equal(t, "read", attrVal.Str()) + } else { + assert.False(t, validatedMetrics["vcenter.vm.vsan.throughput"], "Found a duplicate in the metrics slice: vcenter.vm.vsan.throughput") + validatedMetrics["vcenter.vm.vsan.throughput"] = true + assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type()) + assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len()) + assert.Equal(t, "The vSAN throughput of a virtual machine.", ms.At(i).Description()) + assert.Equal(t, "By/s", ms.At(i).Unit()) + dp := ms.At(i).Gauge().DataPoints().At(0) + assert.Equal(t, start, dp.StartTimestamp()) + assert.Equal(t, ts, dp.Timestamp()) + assert.Equal(t, pmetric.NumberDataPointValueTypeDouble, dp.ValueType()) + switch aggMap["vcenter.vm.vsan.throughput"] { + case "sum": + assert.InDelta(t, float64(4), dp.DoubleValue(), 0.01) + case "avg": + assert.InDelta(t, float64(2), dp.DoubleValue(), 0.01) + case "min": + assert.InDelta(t, float64(1), dp.DoubleValue(), 0.01) + case "max": + assert.InDelta(t, float64(3), dp.DoubleValue(), 0.01) + } + _, ok := dp.Attributes().Get("direction") + assert.False(t, ok) + } } } }) diff --git a/receiver/vcenterreceiver/internal/metadata/testdata/config.yaml b/receiver/vcenterreceiver/internal/metadata/testdata/config.yaml index 130db2582ef9d..4f32b05b419d4 100644 --- a/receiver/vcenterreceiver/internal/metadata/testdata/config.yaml +++ b/receiver/vcenterreceiver/internal/metadata/testdata/config.yaml @@ -3,146 +3,457 @@ all_set: metrics: vcenter.cluster.cpu.effective: enabled: true + attributes: [] vcenter.cluster.cpu.limit: enabled: true + attributes: [] vcenter.cluster.host.count: enabled: true + attributes: ["effective"] vcenter.cluster.memory.effective: enabled: true + attributes: [] vcenter.cluster.memory.limit: enabled: true + attributes: [] vcenter.cluster.vm.count: enabled: true + attributes: ["power_state"] vcenter.cluster.vm_template.count: enabled: true + attributes: [] vcenter.cluster.vsan.congestions: enabled: true + attributes: [] vcenter.cluster.vsan.latency.avg: enabled: true + attributes: ["type"] vcenter.cluster.vsan.operations: enabled: true + attributes: ["type"] vcenter.cluster.vsan.throughput: enabled: true + attributes: ["direction"] vcenter.datacenter.cluster.count: enabled: true + attributes: ["status"] vcenter.datacenter.cpu.limit: enabled: true + attributes: [] vcenter.datacenter.datastore.count: enabled: true + attributes: [] vcenter.datacenter.disk.space: enabled: true + attributes: ["disk_state"] vcenter.datacenter.host.count: enabled: true + attributes: ["status","power_state"] vcenter.datacenter.memory.limit: enabled: true + attributes: [] vcenter.datacenter.vm.count: enabled: true + attributes: ["status","power_state"] vcenter.datastore.disk.usage: enabled: true + attributes: ["disk_state"] vcenter.datastore.disk.utilization: enabled: true + attributes: [] vcenter.host.cpu.capacity: enabled: true + attributes: [] vcenter.host.cpu.reserved: enabled: true + attributes: ["cpu_reservation_type"] vcenter.host.cpu.usage: enabled: true + attributes: [] vcenter.host.cpu.utilization: enabled: true + attributes: [] vcenter.host.disk.latency.avg: enabled: true + attributes: ["direction","object"] vcenter.host.disk.latency.max: enabled: true + attributes: ["object"] vcenter.host.disk.throughput: enabled: true + attributes: ["direction","object"] vcenter.host.memory.capacity: enabled: true + attributes: [] vcenter.host.memory.usage: enabled: true + attributes: [] vcenter.host.memory.utilization: enabled: true + attributes: [] vcenter.host.network.packet.drop.rate: enabled: true + attributes: ["direction","object"] vcenter.host.network.packet.error.rate: enabled: true + attributes: ["direction","object"] vcenter.host.network.packet.rate: enabled: true + attributes: ["direction","object"] vcenter.host.network.throughput: enabled: true + attributes: ["direction","object"] vcenter.host.network.usage: enabled: true + attributes: ["object"] vcenter.host.vsan.cache.hit_rate: enabled: true + attributes: [] vcenter.host.vsan.congestions: enabled: true + attributes: [] vcenter.host.vsan.latency.avg: enabled: true + attributes: ["type"] vcenter.host.vsan.operations: enabled: true + attributes: ["type"] vcenter.host.vsan.throughput: enabled: true + attributes: ["direction"] vcenter.resource_pool.cpu.shares: enabled: true + attributes: [] vcenter.resource_pool.cpu.usage: enabled: true + attributes: [] vcenter.resource_pool.memory.ballooned: enabled: true + attributes: [] vcenter.resource_pool.memory.granted: enabled: true + attributes: ["type"] vcenter.resource_pool.memory.shares: enabled: true + attributes: [] vcenter.resource_pool.memory.swapped: enabled: true + attributes: [] vcenter.resource_pool.memory.usage: enabled: true + attributes: ["type"] vcenter.vm.cpu.readiness: enabled: true + attributes: [] vcenter.vm.cpu.time: enabled: true + attributes: ["cpu_state","object"] vcenter.vm.cpu.usage: enabled: true + attributes: [] vcenter.vm.cpu.utilization: enabled: true + attributes: [] vcenter.vm.disk.latency.avg: enabled: true + attributes: ["direction","disk_type","object"] vcenter.vm.disk.latency.max: enabled: true + attributes: ["object"] vcenter.vm.disk.throughput: enabled: true + attributes: ["direction","object"] vcenter.vm.disk.usage: enabled: true + attributes: ["disk_state"] vcenter.vm.disk.utilization: enabled: true + attributes: [] vcenter.vm.memory.ballooned: enabled: true + attributes: [] vcenter.vm.memory.granted: enabled: true + attributes: [] vcenter.vm.memory.swapped: enabled: true + attributes: [] vcenter.vm.memory.swapped_ssd: enabled: true + attributes: [] vcenter.vm.memory.usage: enabled: true + attributes: [] vcenter.vm.memory.utilization: enabled: true + attributes: [] vcenter.vm.network.broadcast.packet.rate: enabled: true + attributes: ["direction","object"] vcenter.vm.network.multicast.packet.rate: enabled: true + attributes: ["direction","object"] vcenter.vm.network.packet.drop.rate: enabled: true + attributes: ["direction","object"] vcenter.vm.network.packet.rate: enabled: true + attributes: ["direction","object"] vcenter.vm.network.throughput: enabled: true + attributes: ["direction","object"] vcenter.vm.network.usage: enabled: true + attributes: ["object"] vcenter.vm.vsan.latency.avg: enabled: true + attributes: ["type"] vcenter.vm.vsan.operations: enabled: true + attributes: ["type"] vcenter.vm.vsan.throughput: enabled: true + attributes: ["direction"] + resource_attributes: + vcenter.cluster.name: + enabled: true + vcenter.datacenter.name: + enabled: true + vcenter.datastore.name: + enabled: true + vcenter.host.name: + enabled: true + vcenter.resource_pool.inventory_path: + enabled: true + vcenter.resource_pool.name: + enabled: true + vcenter.virtual_app.inventory_path: + enabled: true + vcenter.virtual_app.name: + enabled: true + vcenter.vm.id: + enabled: true + vcenter.vm.name: + enabled: true + vcenter.vm_template.id: + enabled: true + vcenter.vm_template.name: + enabled: true +reaggregate_set: + metrics: + vcenter.cluster.cpu.effective: + enabled: true + attributes: [] + vcenter.cluster.cpu.limit: + enabled: true + attributes: [] + vcenter.cluster.host.count: + enabled: true + attributes: [] + vcenter.cluster.memory.effective: + enabled: true + attributes: [] + vcenter.cluster.memory.limit: + enabled: true + attributes: [] + vcenter.cluster.vm.count: + enabled: true + attributes: [] + vcenter.cluster.vm_template.count: + enabled: true + attributes: [] + vcenter.cluster.vsan.congestions: + enabled: true + attributes: [] + vcenter.cluster.vsan.latency.avg: + enabled: true + attributes: [] + vcenter.cluster.vsan.operations: + enabled: true + attributes: [] + vcenter.cluster.vsan.throughput: + enabled: true + attributes: [] + vcenter.datacenter.cluster.count: + enabled: true + attributes: [] + vcenter.datacenter.cpu.limit: + enabled: true + attributes: [] + vcenter.datacenter.datastore.count: + enabled: true + attributes: [] + vcenter.datacenter.disk.space: + enabled: true + attributes: [] + vcenter.datacenter.host.count: + enabled: true + attributes: [] + vcenter.datacenter.memory.limit: + enabled: true + attributes: [] + vcenter.datacenter.vm.count: + enabled: true + attributes: [] + vcenter.datastore.disk.usage: + enabled: true + attributes: [] + vcenter.datastore.disk.utilization: + enabled: true + attributes: [] + vcenter.host.cpu.capacity: + enabled: true + attributes: [] + vcenter.host.cpu.reserved: + enabled: true + attributes: [] + vcenter.host.cpu.usage: + enabled: true + attributes: [] + vcenter.host.cpu.utilization: + enabled: true + attributes: [] + vcenter.host.disk.latency.avg: + enabled: true + attributes: [] + vcenter.host.disk.latency.max: + enabled: true + attributes: [] + vcenter.host.disk.throughput: + enabled: true + attributes: [] + vcenter.host.memory.capacity: + enabled: true + attributes: [] + vcenter.host.memory.usage: + enabled: true + attributes: [] + vcenter.host.memory.utilization: + enabled: true + attributes: [] + vcenter.host.network.packet.drop.rate: + enabled: true + attributes: [] + vcenter.host.network.packet.error.rate: + enabled: true + attributes: [] + vcenter.host.network.packet.rate: + enabled: true + attributes: [] + vcenter.host.network.throughput: + enabled: true + attributes: [] + vcenter.host.network.usage: + enabled: true + attributes: [] + vcenter.host.vsan.cache.hit_rate: + enabled: true + attributes: [] + vcenter.host.vsan.congestions: + enabled: true + attributes: [] + vcenter.host.vsan.latency.avg: + enabled: true + attributes: [] + vcenter.host.vsan.operations: + enabled: true + attributes: [] + vcenter.host.vsan.throughput: + enabled: true + attributes: [] + vcenter.resource_pool.cpu.shares: + enabled: true + attributes: [] + vcenter.resource_pool.cpu.usage: + enabled: true + attributes: [] + vcenter.resource_pool.memory.ballooned: + enabled: true + attributes: [] + vcenter.resource_pool.memory.granted: + enabled: true + attributes: [] + vcenter.resource_pool.memory.shares: + enabled: true + attributes: [] + vcenter.resource_pool.memory.swapped: + enabled: true + attributes: [] + vcenter.resource_pool.memory.usage: + enabled: true + attributes: [] + vcenter.vm.cpu.readiness: + enabled: true + attributes: [] + vcenter.vm.cpu.time: + enabled: true + attributes: [] + vcenter.vm.cpu.usage: + enabled: true + attributes: [] + vcenter.vm.cpu.utilization: + enabled: true + attributes: [] + vcenter.vm.disk.latency.avg: + enabled: true + attributes: [] + vcenter.vm.disk.latency.max: + enabled: true + attributes: [] + vcenter.vm.disk.throughput: + enabled: true + attributes: [] + vcenter.vm.disk.usage: + enabled: true + attributes: [] + vcenter.vm.disk.utilization: + enabled: true + attributes: [] + vcenter.vm.memory.ballooned: + enabled: true + attributes: [] + vcenter.vm.memory.granted: + enabled: true + attributes: [] + vcenter.vm.memory.swapped: + enabled: true + attributes: [] + vcenter.vm.memory.swapped_ssd: + enabled: true + attributes: [] + vcenter.vm.memory.usage: + enabled: true + attributes: [] + vcenter.vm.memory.utilization: + enabled: true + attributes: [] + vcenter.vm.network.broadcast.packet.rate: + enabled: true + attributes: [] + vcenter.vm.network.multicast.packet.rate: + enabled: true + attributes: [] + vcenter.vm.network.packet.drop.rate: + enabled: true + attributes: [] + vcenter.vm.network.packet.rate: + enabled: true + attributes: [] + vcenter.vm.network.throughput: + enabled: true + attributes: [] + vcenter.vm.network.usage: + enabled: true + attributes: [] + vcenter.vm.vsan.latency.avg: + enabled: true + attributes: [] + vcenter.vm.vsan.operations: + enabled: true + attributes: [] + vcenter.vm.vsan.throughput: + enabled: true + attributes: [] resource_attributes: vcenter.cluster.name: enabled: true @@ -172,146 +483,217 @@ none_set: metrics: vcenter.cluster.cpu.effective: enabled: false + attributes: [] vcenter.cluster.cpu.limit: enabled: false + attributes: [] vcenter.cluster.host.count: enabled: false + attributes: ["effective"] vcenter.cluster.memory.effective: enabled: false + attributes: [] vcenter.cluster.memory.limit: enabled: false + attributes: [] vcenter.cluster.vm.count: enabled: false + attributes: ["power_state"] vcenter.cluster.vm_template.count: enabled: false + attributes: [] vcenter.cluster.vsan.congestions: enabled: false + attributes: [] vcenter.cluster.vsan.latency.avg: enabled: false + attributes: ["type"] vcenter.cluster.vsan.operations: enabled: false + attributes: ["type"] vcenter.cluster.vsan.throughput: enabled: false + attributes: ["direction"] vcenter.datacenter.cluster.count: enabled: false + attributes: ["status"] vcenter.datacenter.cpu.limit: enabled: false + attributes: [] vcenter.datacenter.datastore.count: enabled: false + attributes: [] vcenter.datacenter.disk.space: enabled: false + attributes: ["disk_state"] vcenter.datacenter.host.count: enabled: false + attributes: ["status","power_state"] vcenter.datacenter.memory.limit: enabled: false + attributes: [] vcenter.datacenter.vm.count: enabled: false + attributes: ["status","power_state"] vcenter.datastore.disk.usage: enabled: false + attributes: ["disk_state"] vcenter.datastore.disk.utilization: enabled: false + attributes: [] vcenter.host.cpu.capacity: enabled: false + attributes: [] vcenter.host.cpu.reserved: enabled: false + attributes: ["cpu_reservation_type"] vcenter.host.cpu.usage: enabled: false + attributes: [] vcenter.host.cpu.utilization: enabled: false + attributes: [] vcenter.host.disk.latency.avg: enabled: false + attributes: ["direction","object"] vcenter.host.disk.latency.max: enabled: false + attributes: ["object"] vcenter.host.disk.throughput: enabled: false + attributes: ["direction","object"] vcenter.host.memory.capacity: enabled: false + attributes: [] vcenter.host.memory.usage: enabled: false + attributes: [] vcenter.host.memory.utilization: enabled: false + attributes: [] vcenter.host.network.packet.drop.rate: enabled: false + attributes: ["direction","object"] vcenter.host.network.packet.error.rate: enabled: false + attributes: ["direction","object"] vcenter.host.network.packet.rate: enabled: false + attributes: ["direction","object"] vcenter.host.network.throughput: enabled: false + attributes: ["direction","object"] vcenter.host.network.usage: enabled: false + attributes: ["object"] vcenter.host.vsan.cache.hit_rate: enabled: false + attributes: [] vcenter.host.vsan.congestions: enabled: false + attributes: [] vcenter.host.vsan.latency.avg: enabled: false + attributes: ["type"] vcenter.host.vsan.operations: enabled: false + attributes: ["type"] vcenter.host.vsan.throughput: enabled: false + attributes: ["direction"] vcenter.resource_pool.cpu.shares: enabled: false + attributes: [] vcenter.resource_pool.cpu.usage: enabled: false + attributes: [] vcenter.resource_pool.memory.ballooned: enabled: false + attributes: [] vcenter.resource_pool.memory.granted: enabled: false + attributes: ["type"] vcenter.resource_pool.memory.shares: enabled: false + attributes: [] vcenter.resource_pool.memory.swapped: enabled: false + attributes: [] vcenter.resource_pool.memory.usage: enabled: false + attributes: ["type"] vcenter.vm.cpu.readiness: enabled: false + attributes: [] vcenter.vm.cpu.time: enabled: false + attributes: ["cpu_state","object"] vcenter.vm.cpu.usage: enabled: false + attributes: [] vcenter.vm.cpu.utilization: enabled: false + attributes: [] vcenter.vm.disk.latency.avg: enabled: false + attributes: ["direction","disk_type","object"] vcenter.vm.disk.latency.max: enabled: false + attributes: ["object"] vcenter.vm.disk.throughput: enabled: false + attributes: ["direction","object"] vcenter.vm.disk.usage: enabled: false + attributes: ["disk_state"] vcenter.vm.disk.utilization: enabled: false + attributes: [] vcenter.vm.memory.ballooned: enabled: false + attributes: [] vcenter.vm.memory.granted: enabled: false + attributes: [] vcenter.vm.memory.swapped: enabled: false + attributes: [] vcenter.vm.memory.swapped_ssd: enabled: false + attributes: [] vcenter.vm.memory.usage: enabled: false + attributes: [] vcenter.vm.memory.utilization: enabled: false + attributes: [] vcenter.vm.network.broadcast.packet.rate: enabled: false + attributes: ["direction","object"] vcenter.vm.network.multicast.packet.rate: enabled: false + attributes: ["direction","object"] vcenter.vm.network.packet.drop.rate: enabled: false + attributes: ["direction","object"] vcenter.vm.network.packet.rate: enabled: false + attributes: ["direction","object"] vcenter.vm.network.throughput: enabled: false + attributes: ["direction","object"] vcenter.vm.network.usage: enabled: false + attributes: ["object"] vcenter.vm.vsan.latency.avg: enabled: false + attributes: ["type"] vcenter.vm.vsan.operations: enabled: false + attributes: ["type"] vcenter.vm.vsan.throughput: enabled: false + attributes: ["direction"] resource_attributes: vcenter.cluster.name: enabled: false diff --git a/receiver/vcenterreceiver/metadata.yaml b/receiver/vcenterreceiver/metadata.yaml index 61022c66545d9..8fde7946fa3e0 100644 --- a/receiver/vcenterreceiver/metadata.yaml +++ b/receiver/vcenterreceiver/metadata.yaml @@ -1,4 +1,5 @@ type: vcenter +reaggregation_enabled: true status: class: receiver @@ -67,6 +68,7 @@ attributes: - total - used description: The type of CPU reservation for the host. + requirement_level: recommended cpu_state: description: CPU time spent in idle, ready or idle state. type: string @@ -74,6 +76,7 @@ attributes: - "idle" - "ready" - "wait" + requirement_level: recommended disk_direction: name_override: direction description: The direction of disk latency. @@ -81,18 +84,21 @@ attributes: enum: - read - write + requirement_level: recommended disk_state: description: The state of storage and whether it is already allocated or free. type: string enum: - available - used + requirement_level: recommended disk_type: description: The type of storage device that is being recorded. type: string enum: - virtual - physical + requirement_level: recommended entity_status: name_override: status description: The current status of the managed entity. @@ -102,10 +108,12 @@ attributes: - "yellow" - "green" - "gray" + requirement_level: recommended host_effective: type: bool name_override: effective description: Whether the host is effective in the vCenter cluster. + requirement_level: recommended host_power_state: name_override: power_state description: The current power state of the host. @@ -115,6 +123,7 @@ attributes: - "off" - "standby" - "unknown" + requirement_level: recommended memory_granted_type: name_override: type description: The type of memory granted. @@ -122,6 +131,7 @@ attributes: enum: - private - shared + requirement_level: recommended memory_usage_type: name_override: type description: The type of memory usage. @@ -130,10 +140,12 @@ attributes: - guest - host - overhead + requirement_level: recommended object_name: name_override: object description: The object on the virtual machine or host that is being reported on. type: string + requirement_level: recommended throughput_direction: name_override: direction description: The direction of network throughput. @@ -141,6 +153,7 @@ attributes: enum: - transmitted - received + requirement_level: recommended vm_count_power_state: name_override: power_state description: The current power state of the virtual machine. @@ -150,6 +163,7 @@ attributes: - "off" - "suspended" - "unknown" + requirement_level: recommended vsan_latency_type: name_override: type description: The type of vSAN latency. @@ -157,6 +171,7 @@ attributes: enum: - read - write + requirement_level: recommended vsan_operation_type: name_override: type description: The type of vSAN operation. @@ -165,7 +180,7 @@ attributes: - read - write - unmap - + requirement_level: recommended vsan_throughput_direction: name_override: direction description: The type of vSAN throughput. @@ -173,6 +188,7 @@ attributes: enum: - read - write + requirement_level: recommended metrics: vcenter.cluster.cpu.effective: From 603179f32421609bb52ea3637a2e3600e60400d8 Mon Sep 17 00:00:00 2001 From: singhvibhanshu Date: Wed, 25 Feb 2026 20:12:39 +0530 Subject: [PATCH 2/3] [chore] format go imports --- receiver/vcenterreceiver/generated_package_test.go | 3 ++- .../vcenterreceiver/internal/metadata/generated_config_test.go | 1 - 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/receiver/vcenterreceiver/generated_package_test.go b/receiver/vcenterreceiver/generated_package_test.go index b9f3211ba0b28..41cb84e7dcaef 100644 --- a/receiver/vcenterreceiver/generated_package_test.go +++ b/receiver/vcenterreceiver/generated_package_test.go @@ -3,8 +3,9 @@ package vcenterreceiver import ( - "go.uber.org/goleak" "testing" + + "go.uber.org/goleak" ) func TestMain(m *testing.M) { diff --git a/receiver/vcenterreceiver/internal/metadata/generated_config_test.go b/receiver/vcenterreceiver/internal/metadata/generated_config_test.go index 9c8691255db7c..74ac95ef670e5 100644 --- a/receiver/vcenterreceiver/internal/metadata/generated_config_test.go +++ b/receiver/vcenterreceiver/internal/metadata/generated_config_test.go @@ -9,7 +9,6 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/stretchr/testify/require" - "go.opentelemetry.io/collector/confmap" "go.opentelemetry.io/collector/confmap/confmaptest" ) From 0cd96960dda2389d47364fe05f4ea6ce362e1fff Mon Sep 17 00:00:00 2001 From: singhvibhanshu Date: Wed, 25 Feb 2026 20:40:39 +0530 Subject: [PATCH 3/3] [chore] update config schemas --- .../internal/metadata/config.schema.yaml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/receiver/vcenterreceiver/internal/metadata/config.schema.yaml b/receiver/vcenterreceiver/internal/metadata/config.schema.yaml index 306984f683ae0..352f7c297569f 100644 --- a/receiver/vcenterreceiver/internal/metadata/config.schema.yaml +++ b/receiver/vcenterreceiver/internal/metadata/config.schema.yaml @@ -1,4 +1,10 @@ $defs: + attribute_config: + description: AttributeConfig holds configuration information for a particular metric. + type: object + properties: + enabled: + type: boolean attribute_cpu_reservation_type: description: AttributeCPUReservationType specifies the value cpu_reservation_type attribute. type: integer @@ -45,6 +51,12 @@ $defs: description: MetricConfig provides common config for a particular metric. type: object properties: + aggregation_strategy: + type: string + attributes: + type: array + items: + type: string enabled: type: boolean metrics_builder_config: