Skip to content

Commit

Permalink
[receiver/vcenter] Bump receiver.vcenter.emitPerfMetricsWithObjects g…
Browse files Browse the repository at this point in the history
…ate to stable (open-telemetry#31215)
  • Loading branch information
djaglowski authored and DougManton committed Mar 13, 2024
1 parent 4d2ddc8 commit 876797c
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 3,617 deletions.
27 changes: 27 additions & 0 deletions .chloggen/featuregate-vcenter-stable.yaml
Original file line number Diff line number Diff line change
@@ -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: breaking

# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver)
component: receiver/vcenter

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Bump receiver.vcenter.emitPerfMetricsWithObjects feature gate to stable

# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
issues: [31215]

# (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: []
29 changes: 1 addition & 28 deletions receiver/vcenterreceiver/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,31 +59,4 @@ Details about the metrics produced by this receiver can be found in [metadata.ya
### Feature gates
#### Performance metrics dimensions
These metrics were incorrectly dimensioned previously but the desired fix is a breaking change. To avoid breaking existing users, this feature gate is used to control whether the dimensions are fixed or not. This feature gate is planned to removed in two months.
- `vcenter.vm.network.throughput`
- `vcenter.vm.network.usage`
- `vcenter.vm.network.packet.count`
- `vcenter.vm.disk.latency.avg`
- `vcenter.vm.disk.latency.max`
- `vcenter.host.network.usage`
- `vcenter.host.network.throughput`
- `vcenter.host.network.packet.count`
- `vcenter.host.network.packet.errors`
- `vcenter.host.disk.latency.avg`
- `vcenter.host.disk.latency.max`
- `vcenter.host.disk.throughput`

These metrics were improperly dimensioned and needed another metric attribute `object` in order to properly dimension the data.

#### v0.93.0, January 2024

- The receiver will emit the `object` metric attribute by default
- `receiver.vcenter.emitPerfMetricsWithObjects` is *enabled* by default.

#### v0.95.0, February 2024

- The feature gates are removed.
- Performance metrics will always include the `object` metric attribute.
The `receiver.vcenter.emitPerfMetricsWithObjects` is now stable and will be removed in v0.97.0.
90 changes: 2 additions & 88 deletions receiver/vcenterreceiver/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,11 +152,7 @@ func (v *vcenterMetricScraper) recordHostPerformanceMetrics(
errs.AddPartial(1, err)
return
}
if v.emitPerfWithObject {
v.processHostPerformance(info.results)
} else {
v.processHostPerformanceWithoutObject(info.results)
}
v.processHostPerformance(info.results)
}

// vmPerfMetricList may be customizable in the future but here is the full list of Virtual Machine Performance Counters
Expand Down Expand Up @@ -196,13 +192,7 @@ func (v *vcenterMetricScraper) recordVMPerformance(
errs.AddPartial(1, err)
return
}

if v.emitPerfWithObject {
v.processVMPerformanceMetrics(info)
} else {
v.processVMPerformanceMetricsWithoutObject(info)
}

v.processVMPerformanceMetrics(info)
}

func (v *vcenterMetricScraper) processVMPerformanceMetrics(info *perfSampleResult) {
Expand Down Expand Up @@ -240,41 +230,6 @@ func (v *vcenterMetricScraper) processVMPerformanceMetrics(info *perfSampleResul
}
}

func (v *vcenterMetricScraper) processVMPerformanceMetricsWithoutObject(info *perfSampleResult) {
for _, m := range info.results {
for _, val := range m.Value {
for j, nestedValue := range val.Value {
si := m.SampleInfo[j]
switch val.Name {
// Performance monitoring level 1 metrics
case "net.bytesTx.average":
v.mb.RecordVcenterVMNetworkThroughputDataPointWithoutObject(pcommon.NewTimestampFromTime(si.Timestamp), nestedValue, metadata.AttributeThroughputDirectionTransmitted)
case "net.bytesRx.average":
v.mb.RecordVcenterVMNetworkThroughputDataPointWithoutObject(pcommon.NewTimestampFromTime(si.Timestamp), nestedValue, metadata.AttributeThroughputDirectionReceived)
case "net.usage.average":
v.mb.RecordVcenterVMNetworkUsageDataPointWithoutObject(pcommon.NewTimestampFromTime(si.Timestamp), nestedValue)
case "net.packetsTx.summation":
v.mb.RecordVcenterVMNetworkPacketCountDataPointWithoutObject(pcommon.NewTimestampFromTime(si.Timestamp), nestedValue, metadata.AttributeThroughputDirectionTransmitted)
case "net.packetsRx.summation":
v.mb.RecordVcenterVMNetworkPacketCountDataPointWithoutObject(pcommon.NewTimestampFromTime(si.Timestamp), nestedValue, metadata.AttributeThroughputDirectionReceived)

// Performance monitoring level 2 metrics required
case "disk.totalReadLatency.average":
v.mb.RecordVcenterVMDiskLatencyAvgDataPointWithoutObject(pcommon.NewTimestampFromTime(si.Timestamp), nestedValue, metadata.AttributeDiskDirectionRead, metadata.AttributeDiskTypePhysical)
case "virtualDisk.totalReadLatency.average":
v.mb.RecordVcenterVMDiskLatencyAvgDataPointWithoutObject(pcommon.NewTimestampFromTime(si.Timestamp), nestedValue, metadata.AttributeDiskDirectionRead, metadata.AttributeDiskTypeVirtual)
case "disk.totalWriteLatency.average":
v.mb.RecordVcenterVMDiskLatencyAvgDataPointWithoutObject(pcommon.NewTimestampFromTime(si.Timestamp), nestedValue, metadata.AttributeDiskDirectionWrite, metadata.AttributeDiskTypePhysical)
case "virtualDisk.totalWriteLatency.average":
v.mb.RecordVcenterVMDiskLatencyAvgDataPointWithoutObject(pcommon.NewTimestampFromTime(si.Timestamp), nestedValue, metadata.AttributeDiskDirectionWrite, metadata.AttributeDiskTypeVirtual)
case "disk.maxTotalLatency.latest":
v.mb.RecordVcenterVMDiskLatencyMaxDataPointWithoutObject(pcommon.NewTimestampFromTime(si.Timestamp), nestedValue)
}
}
}
}
}

func (v *vcenterMetricScraper) processHostPerformance(metrics []performance.EntityMetric) {
for _, m := range metrics {
for _, val := range m.Value {
Expand Down Expand Up @@ -315,44 +270,3 @@ func (v *vcenterMetricScraper) processHostPerformance(metrics []performance.Enti
}
}
}

func (v *vcenterMetricScraper) processHostPerformanceWithoutObject(metrics []performance.EntityMetric) {
for _, m := range metrics {
for _, val := range m.Value {
for j, nestedValue := range val.Value {
si := m.SampleInfo[j]
switch val.Name {
// Performance monitoring level 1 metrics
case "net.usage.average":
v.mb.RecordVcenterHostNetworkUsageDataPointWithoutObject(pcommon.NewTimestampFromTime(si.Timestamp), nestedValue)
case "net.bytesTx.average":
v.mb.RecordVcenterHostNetworkThroughputDataPointWithoutObject(pcommon.NewTimestampFromTime(si.Timestamp), nestedValue, metadata.AttributeThroughputDirectionTransmitted)
case "net.bytesRx.average":
v.mb.RecordVcenterHostNetworkThroughputDataPointWithoutObject(pcommon.NewTimestampFromTime(si.Timestamp), nestedValue, metadata.AttributeThroughputDirectionReceived)
case "net.packetsTx.summation":
v.mb.RecordVcenterHostNetworkPacketCountDataPointWithoutObject(pcommon.NewTimestampFromTime(si.Timestamp), nestedValue, metadata.AttributeThroughputDirectionTransmitted)
case "net.packetsRx.summation":
v.mb.RecordVcenterHostNetworkPacketCountDataPointWithoutObject(pcommon.NewTimestampFromTime(si.Timestamp), nestedValue, metadata.AttributeThroughputDirectionReceived)

// Following requires performance level 2
case "net.errorsRx.summation":
v.mb.RecordVcenterHostNetworkPacketErrorsDataPointWithoutObject(pcommon.NewTimestampFromTime(si.Timestamp), nestedValue, metadata.AttributeThroughputDirectionReceived)
case "net.errorsTx.summation":
v.mb.RecordVcenterHostNetworkPacketErrorsDataPointWithoutObject(pcommon.NewTimestampFromTime(si.Timestamp), nestedValue, metadata.AttributeThroughputDirectionTransmitted)
case "disk.totalWriteLatency.average":
v.mb.RecordVcenterHostDiskLatencyAvgDataPointWithoutObject(pcommon.NewTimestampFromTime(si.Timestamp), nestedValue, metadata.AttributeDiskDirectionWrite)
case "disk.totalReadLatency.average":
v.mb.RecordVcenterHostDiskLatencyAvgDataPointWithoutObject(pcommon.NewTimestampFromTime(si.Timestamp), nestedValue, metadata.AttributeDiskDirectionRead)
case "disk.maxTotalLatency.latest":
v.mb.RecordVcenterHostDiskLatencyMaxDataPointWithoutObject(pcommon.NewTimestampFromTime(si.Timestamp), nestedValue)

// Following requires performance level 4
case "disk.read.average":
v.mb.RecordVcenterHostDiskThroughputDataPointWithoutObject(pcommon.NewTimestampFromTime(si.Timestamp), nestedValue, metadata.AttributeDiskDirectionRead)
case "disk.write.average":
v.mb.RecordVcenterHostDiskThroughputDataPointWithoutObject(pcommon.NewTimestampFromTime(si.Timestamp), nestedValue, metadata.AttributeDiskDirectionWrite)
}
}
}
}
}
25 changes: 12 additions & 13 deletions receiver/vcenterreceiver/scraper.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ const (
emitPerfMetricsWithObjectsFeatureGateID = "receiver.vcenter.emitPerfMetricsWithObjects"
)

var emitPerfMetricsWithObjects = featuregate.GlobalRegistry().MustRegister(
var _ = featuregate.GlobalRegistry().MustRegister(
emitPerfMetricsWithObjectsFeatureGateID,
featuregate.StageBeta,
featuregate.WithRegisterDescription("When enabled, the receiver emits vCenter performance metrics with object metric label dimension."),
featuregate.StageStable,
featuregate.WithRegisterToVersion("v0.97.0"),
)

var _ receiver.Metrics = (*vcenterMetricScraper)(nil)
Expand All @@ -38,10 +38,10 @@ type vcenterMetricScraper struct {
config *Config
mb *metadata.MetricsBuilder
logger *zap.Logger

// map of vm name => compute name
vmToComputeMap map[string]string
vmToResourcePool map[string]*object.ResourcePool
emitPerfWithObject bool
vmToComputeMap map[string]string
vmToResourcePool map[string]*object.ResourcePool
}

func newVmwareVcenterScraper(
Expand All @@ -51,13 +51,12 @@ func newVmwareVcenterScraper(
) *vcenterMetricScraper {
client := newVcenterClient(config)
return &vcenterMetricScraper{
client: client,
config: config,
logger: logger,
mb: metadata.NewMetricsBuilder(config.MetricsBuilderConfig, settings),
vmToComputeMap: make(map[string]string),
vmToResourcePool: make(map[string]*object.ResourcePool),
emitPerfWithObject: emitPerfMetricsWithObjects.IsEnabled(),
client: client,
config: config,
logger: logger,
mb: metadata.NewMetricsBuilder(config.MetricsBuilderConfig, settings),
vmToComputeMap: make(map[string]string),
vmToResourcePool: make(map[string]*object.ResourcePool),
}
}

Expand Down
32 changes: 0 additions & 32 deletions receiver/vcenterreceiver/scraper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,38 +33,6 @@ func TestScrape(t *testing.T) {
testScrape(ctx, t, cfg)
}

func TestScrapeWithoutPerfObjects(t *testing.T) {
ctx := context.Background()
mockServer := mock.MockServer(t, false)
defer mockServer.Close()

cfg := &Config{
MetricsBuilderConfig: metadata.DefaultMetricsBuilderConfig(),
Endpoint: mockServer.URL,
Username: mock.MockUsername,
Password: mock.MockPassword,
}

scraper := newVmwareVcenterScraper(zap.NewNop(), cfg, receivertest.NewNopCreateSettings())
scraper.emitPerfWithObject = false

metrics, err := scraper.scrape(ctx)
require.NoError(t, err)
require.NotEqual(t, metrics.MetricCount(), 0)

goldenPath := filepath.Join("testdata", "metrics", "expected_without_objects.yaml")
expectedMetrics, err := golden.ReadMetrics(goldenPath)
require.NoError(t, err)

err = pmetrictest.CompareMetrics(expectedMetrics, metrics,
pmetrictest.IgnoreStartTimestamp(), pmetrictest.IgnoreTimestamp(),
pmetrictest.IgnoreResourceMetricsOrder(),
pmetrictest.IgnoreMetricDataPointsOrder(),
)
require.NoError(t, err)
require.NoError(t, scraper.Shutdown(ctx))
}

func TestScrape_TLS(t *testing.T) {
ctx := context.Background()
mockServer := mock.MockServer(t, true)
Expand Down
Loading

0 comments on commit 876797c

Please sign in to comment.