Skip to content

Commit

Permalink
[receiver/hostmetrics] Add system.memory.limit metric (open-telemetry…
Browse files Browse the repository at this point in the history
…#30306)

Adds opt-in support for `system.memory.limit`, standardized on
open-telemetry/semantic-conventions/pull/409.
  • Loading branch information
mx-psi authored and cparkins committed Jan 10, 2024
1 parent 01f1696 commit 08fbb91
Show file tree
Hide file tree
Showing 9 changed files with 136 additions and 0 deletions.
28 changes: 28 additions & 0 deletions .chloggen/mx-psi_system.memory.limit.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# 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. filelogreceiver)
component: hostmetricsreceiver

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: "Add `system.memory.limit` metric reporting the total memory available."

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

# (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: |
This metric is opt-in. To enable it, set `scrapers::memory::metrics::system.memory.limit::enabled` to `true` in the hostmetrics config.
# 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: []
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,14 @@ An estimate of how much memory is available for starting new applications, witho
| ---- | ----------- | ---------- | ----------------------- | --------- |
| By | Sum | Int | Cumulative | false |
### system.memory.limit
Total bytes of memory available.
| Unit | Metric Type | Value Type | Aggregation Temporality | Monotonic |
| ---- | ----------- | ---------- | ----------------------- | --------- |
| By | Sum | Int | Cumulative | false |
### system.memory.utilization
Percentage of memory bytes in use.
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.

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 @@ -3,6 +3,8 @@ all_set:
metrics:
system.linux.memory.available:
enabled: true
system.memory.limit:
enabled: true
system.memory.usage:
enabled: true
system.memory.utilization:
Expand All @@ -11,6 +13,8 @@ none_set:
metrics:
system.linux.memory.available:
enabled: false
system.memory.limit:
enabled: false
system.memory.usage:
enabled: false
system.memory.utilization:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ func (s *scraper) start(ctx context.Context, _ component.Host) error {
return nil
}

func (s *scraper) recordMemoryLimitMetric(now pcommon.Timestamp, memInfo *mem.VirtualMemoryStat) {
s.mb.RecordSystemMemoryLimitDataPoint(now, int64(memInfo.Total))
}

func (s *scraper) scrape(ctx context.Context) (pmetric.Metrics, error) {
ctx = context.WithValue(ctx, common.EnvKey, s.envMap)

Expand All @@ -69,6 +73,7 @@ func (s *scraper) scrape(ctx context.Context) (pmetric.Metrics, error) {
memInfo.Total), metricsLen)
}
s.recordMemoryUtilizationMetric(now, memInfo)
s.recordMemoryLimitMetric(now, memInfo)
s.recordSystemSpecificMetrics(now, memInfo)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,15 @@ attributes:
enum: [buffered, cached, inactive, free, slab_reclaimable, slab_unreclaimable, used]

metrics:
system.memory.limit:
enabled: false
description: Total bytes of memory available.
unit: By
sum:
value_type: int
aggregation_temporality: cumulative
monotonic: false

system.memory.usage:
enabled: true
description: Bytes of memory in use.
Expand Down

0 comments on commit 08fbb91

Please sign in to comment.