Skip to content

Commit

Permalink
[receiver/dockerstatsreceiver] Add metrics that are only available on…
Browse files Browse the repository at this point in the history
… hosts that use cgroups v2 (open-telemetry#22706)

**Description:**
This PR updates the documentation of all the metrics that are available
only on cgroups v1 or cgroups v2.

It PR also adds two metrics that are only available when the host is
using cgroups v2:
 * `container.memory.anon`
 * `container.memory.file`

Both are documented here:
https://docs.kernel.org/admin-guide/cgroup-v2.html#memory-interface-files

I enabled the metric `container.memory.file` by default (causing a
breaking change) because it is a metric that was already scraped for
cgroups v1, contained in the metric `container.memory.total_cache`.

```yaml
  container.memory.total_cache:
    enabled: true
    description: "Total amount of memory used by the processes of this cgroup (and descendants) that can be associated with a block on a block device. Also accounts for memory used by tmpfs (Only available with cgroups v1)."

  container.memory.file:
    enabled: true
    description: "Amount of memory used to cache filesystem data, including tmpfs and shared memory (Only available with cgroups v2)."
```

Let me know your thoughts about this breaking change.

**Link to tracking Issue:** open-telemetry#21097

**Testing:**
The refactor done during PR open-telemetry#21110 had mocks ready to test these new
metrics. There is no need to add more tests.

**Documentation:**
To see which metrics are available in Docker:
* v1:
https://github.com/moby/moby/blob/7103efac9d737e8b202126e8c8e2227805e70771/daemon/stats_unix.go#L86
* v2:
https://github.com/moby/moby/blob/7103efac9d737e8b202126e8c8e2227805e70771/daemon/stats_unix.go#L195

Kernel cgroup documentation:
 * v1: https://docs.kernel.org/admin-guide/cgroup-v1/memory.html
* v2:
https://docs.kernel.org/admin-guide/cgroup-v2.html#memory-interface-files
  • Loading branch information
kang-makes committed Jun 25, 2023
1 parent 8ba48f6 commit da5df85
Show file tree
Hide file tree
Showing 15 changed files with 1,233 additions and 791 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: breaking

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

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Add non populated metrics `container.memory.anon` and `container.memory.file` that are only available when the host uses cgroups v2.

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

# (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: |
Metric `container.memory.file` was added to fulfil the lack of `container.memory.total_cache` metric in case that the
cgroup version mounted in the host is v2 instead of v1.
Now there is documentation of which metrics are available depending cgroups version being used on the host.
88 changes: 54 additions & 34 deletions receiver/dockerstatsreceiver/documentation.md

Large diffs are not rendered by default.

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.

184 changes: 151 additions & 33 deletions receiver/dockerstatsreceiver/internal/metadata/generated_metrics.go

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,14 @@ all_set:
enabled: true
container.memory.active_file:
enabled: true
container.memory.anon:
enabled: true
container.memory.cache:
enabled: true
container.memory.dirty:
enabled: true
container.memory.file:
enabled: true
container.memory.hierarchical_memory_limit:
enabled: true
container.memory.hierarchical_memsw_limit:
Expand Down Expand Up @@ -184,10 +188,14 @@ none_set:
enabled: false
container.memory.active_file:
enabled: false
container.memory.anon:
enabled: false
container.memory.cache:
enabled: false
container.memory.dirty:
enabled: false
container.memory.file:
enabled: false
container.memory.hierarchical_memory_limit:
enabled: false
container.memory.hierarchical_memsw_limit:
Expand Down
Loading

0 comments on commit da5df85

Please sign in to comment.