Skip to content

Commit

Permalink
[receiver/hostmetrics] Disable deprecated process memory metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
andrzej-stencel committed Dec 29, 2022
1 parent 3b25b98 commit 5a32e90
Show file tree
Hide file tree
Showing 9 changed files with 66 additions and 46 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: deprecation

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

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Disable deprecated process memory metrics

# One or more tracking issues related to the change
issues: [14327]

# (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: |
The metrics `process.memory.physical_usage` and `process.memory.virtual_usage` are now disabled by default and will be removed in v0.72.0.
As a replacement, the following metrics are now enabled by default: `process.memory.usage`, `process.memory.virtual`.
For details, see the [docs](https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/v0.68.0/receiver/hostmetricsreceiver#transition-to-process-memory-metric-names-aligned-with-opentelemetry-specification).
2 changes: 1 addition & 1 deletion receiver/hostmetricsreceiver/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ the following process will be followed to phase out the old metrics:
- Until and including `v0.63.0`, only the old metrics `process.memory.physical_usage` and `process.memory.virtual_usage` are emitted.
You can use the [Metrics Transform processor][metricstransformprocessor_docs] to rename them.
- Between `v0.64.0` and `v0.69.0`, the new metrics are introduced as optional (disabled by default) and the old metrics are marked as deprecated.
- Between `v0.64.0` and `v0.68.0`, the new metrics are introduced as optional (disabled by default) and the old metrics are marked as deprecated.
Only the old metrics are emitted by default.
- Between `v0.69.0` and `v0.71.0`, the new metrics are enabled and the old metrics are disabled by default.
- In `v0.72.0` and up, the old metrics are removed.
Expand Down
4 changes: 2 additions & 2 deletions receiver/hostmetricsreceiver/hostmetrics_receiver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ var standardMetrics = []string{

var resourceMetrics = []string{
"process.cpu.time",
"process.memory.physical_usage",
"process.memory.virtual_usage",
"process.memory.usage",
"process.memory.virtual",
"process.disk.io",
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,17 @@ Disk bytes transferred.
| ---- | ----------- | ------ |
| direction | Direction of flow of bytes (read or write). | Str: ``read``, ``write`` |
### process.memory.physical_usage
### process.memory.usage
Deprecated: use `process.memory.usage` metric instead. The amount of physical memory in use.
The amount of physical memory in use.
| Unit | Metric Type | Value Type | Aggregation Temporality | Monotonic |
| ---- | ----------- | ---------- | ----------------------- | --------- |
| By | Sum | Int | Cumulative | false |
### process.memory.virtual_usage
### process.memory.virtual
Deprecated: Use `process.memory.virtual` metric instead. Virtual memory size.
Virtual memory size.
| Unit | Metric Type | Value Type | Aggregation Temporality | Monotonic |
| ---- | ----------- | ---------- | ----------------------- | --------- |
Expand Down Expand Up @@ -108,9 +108,9 @@ Number of disk operations performed by the process.
| ---- | ----------- | ------ |
| direction | Direction of flow of bytes (read or write). | Str: ``read``, ``write`` |
### process.memory.usage
### process.memory.physical_usage
The amount of physical memory in use.
[DEPRECATED] Use `process.memory.usage` metric instead. The amount of physical memory in use.

| Unit | Metric Type | Value Type | Aggregation Temporality | Monotonic |
| ---- | ----------- | ---------- | ----------------------- | --------- |
Expand All @@ -124,9 +124,9 @@ Percentage of total physical memory that is used by the process.
| ---- | ----------- | ---------- |
| 1 | Gauge | Double |

### process.memory.virtual
### process.memory.virtual_usage

Virtual memory size.
[DEPRECATED] Use `process.memory.virtual` metric instead. Virtual memory size.

| Unit | Metric Type | Value Type | Aggregation Temporality | Monotonic |
| ---- | ----------- | ---------- | ----------------------- | --------- |
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,11 @@ metrics:
attributes: [state]

process.memory.physical_usage:
enabled: true
description: "Deprecated: use `process.memory.usage` metric instead. The amount of physical memory in use."
enabled: false
description: "[DEPRECATED] Use `process.memory.usage` metric instead. The amount of physical memory in use."
warnings:
if_enabled: >-
The metric is deprecated and will be removed in v0.70.0. Please use `process.memory.usage` instead. See
if_configured: >-
The metric is deprecated and will be removed in v0.72.0. Please use `process.memory.usage` instead. See
https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/receiver/hostmetricsreceiver#transition-to-process-memory-metric-names-aligned-with-opentelemetry-specification
for more details.
unit: By
Expand All @@ -98,7 +98,7 @@ metrics:
monotonic: false

process.memory.usage:
enabled: false
enabled: true
description: The amount of physical memory in use.
unit: By
sum:
Expand All @@ -107,11 +107,11 @@ metrics:
monotonic: false

process.memory.virtual_usage:
enabled: true
description: "Deprecated: Use `process.memory.virtual` metric instead. Virtual memory size."
enabled: false
description: "[DEPRECATED] Use `process.memory.virtual` metric instead. Virtual memory size."
warnings:
if_enabled: >-
The metric is deprecated and will be removed in v0.70.0. Please use `process.memory.virtual` metric instead. See
if_configured: >-
The metric is deprecated and will be removed in v0.72.0. Please use `process.memory.virtual` metric instead. See
https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/receiver/hostmetricsreceiver#transition-to-process-memory-metric-names-aligned-with-opentelemetry-specification
for more details.
unit: By
Expand All @@ -121,7 +121,7 @@ metrics:
monotonic: false

process.memory.virtual:
enabled: false
enabled: true
description: Virtual memory size.
unit: By
sum:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ func (s *scraper) scrapeAndAppendCPUTimeMetric(now pcommon.Timestamp, handle pro
}

func (s *scraper) scrapeAndAppendMemoryUsageMetrics(now pcommon.Timestamp, handle processHandle) error {
if !(s.config.Metrics.ProcessMemoryPhysicalUsage.Enabled || s.config.Metrics.ProcessMemoryVirtualUsage.Enabled) {
if !(s.config.Metrics.ProcessMemoryUsage.Enabled || s.config.Metrics.ProcessMemoryVirtual.Enabled || s.config.Metrics.ProcessMemoryPhysicalUsage.Enabled || s.config.Metrics.ProcessMemoryVirtualUsage.Enabled) {
return nil
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,10 +207,10 @@ func assertCPUUtilizationMetricValid(t *testing.T, resourceMetrics pmetric.Resou
}

func assertMemoryUsageMetricValid(t *testing.T, resourceMetrics pmetric.ResourceMetricsSlice, startTime pcommon.Timestamp) {
physicalMemUsageMetric := getMetric(t, "process.memory.physical_usage", resourceMetrics)
assert.Equal(t, "process.memory.physical_usage", physicalMemUsageMetric.Name())
virtualMemUsageMetric := getMetric(t, "process.memory.virtual_usage", resourceMetrics)
assert.Equal(t, "process.memory.virtual_usage", virtualMemUsageMetric.Name())
physicalMemUsageMetric := getMetric(t, "process.memory.usage", resourceMetrics)
assert.Equal(t, "process.memory.usage", physicalMemUsageMetric.Name())
virtualMemUsageMetric := getMetric(t, "process.memory.virtual", resourceMetrics)
assert.Equal(t, "process.memory.virtual", virtualMemUsageMetric.Name())

if startTime != 0 {
internal.AssertSumMetricStartTimeEquals(t, physicalMemUsageMetric, startTime)
Expand Down Expand Up @@ -962,8 +962,8 @@ func TestScrapeMetrics_DontCheckDisabledMetrics(t *testing.T) {
metricSettings.ProcessCPUTime.Enabled = false
metricSettings.ProcessDiskIo.Enabled = false
metricSettings.ProcessDiskOperations.Enabled = false
metricSettings.ProcessMemoryPhysicalUsage.Enabled = false
metricSettings.ProcessMemoryVirtualUsage.Enabled = false
metricSettings.ProcessMemoryUsage.Enabled = false
metricSettings.ProcessMemoryVirtual.Enabled = false

t.Run("Metrics don't log errors when disabled", func(t *testing.T) {
config := &Config{Metrics: metricSettings}
Expand Down

0 comments on commit 5a32e90

Please sign in to comment.