Skip to content

Commit d7e1933

Browse files
carlossscastrosigiliosormfitzpatrickmartin-majlis-s1djaglowski
authored
[receiver/dockerstats] Add inspect metrics (open-telemetry#21803)
**Description:** Adds 3 new metrics from the docker inspect api * container.cpu.limit * container.cpu.shares * container.restart.count Since all these metrics are collected from the inspect api, a new method was created (`recordInspectMetrics`) where only the containerJSON structure is passed as an argument. **Link to tracking Issue:** open-telemetry#21087 **Testing:** New metrics were added to the receiver test and expected_metrics.yaml files. The receiver and config tests were also adjusted to reflect the minimum api version of 1.25 ``` ❯ go clean -testcache ❯ make test go test -race -timeout 300s -parallel 4 --tags="" ./... ok github.com/open-telemetry/opentelemetry-collector-contrib/receiver/dockerstatsreceiver 0.508s ok github.com/open-telemetry/opentelemetry-collector-contrib/receiver/dockerstatsreceiver/internal/metadata 0.381s ❯ go test --tags integration ./... ok github.com/open-telemetry/opentelemetry-collector-contrib/receiver/dockerstatsreceiver 14.060s ok github.com/open-telemetry/opentelemetry-collector-contrib/receiver/dockerstatsreceiver/internal/metadata 0.241s ``` **Documentation:** New metrics documentation was generated using `mdatagen` --------- Signed-off-by: Paschalis Tsilias <[email protected]> Signed-off-by: Christian Kruse <[email protected]> Signed-off-by: Dani Louca <[email protected]> Signed-off-by: Jared Tan <[email protected]> Signed-off-by: Dominik Rosiek <[email protected]> Signed-off-by: Raphael Silva <[email protected]> Signed-off-by: Alex Boten <[email protected]> Signed-off-by: Pavol Loffay <[email protected]> Signed-off-by: Juraci Paixão Kröhling <[email protected]> Signed-off-by: Sean Porter <[email protected]> Co-authored-by: Christian Felipe Álvarez <[email protected]> Co-authored-by: Christian <[email protected]> Co-authored-by: Ryan Fitzpatrick <[email protected]> Co-authored-by: Martin Majlis <[email protected]> Co-authored-by: Daniel Jaglowski <[email protected]> Co-authored-by: hovavza <[email protected]> Co-authored-by: Povilas Versockas <[email protected]> Co-authored-by: Dmitrii Anoshin <[email protected]> Co-authored-by: sakulali <[email protected]> Co-authored-by: OpenTelemetry Bot <[email protected]> Co-authored-by: Tyler Helmuth <[email protected]> Co-authored-by: Paschalis Tsilias <[email protected]> Co-authored-by: Juraci Paixão Kröhling <[email protected]> Co-authored-by: Andrzej Stencel <[email protected]> Co-authored-by: Brandon Johnson <[email protected]> Co-authored-by: Miel Donkers <[email protected]> Co-authored-by: bryan-aguilar <[email protected]> Co-authored-by: Christian Kruse <[email protected]> Co-authored-by: gord02 <[email protected]> Co-authored-by: bagmeg <[email protected]> Co-authored-by: Yang Song <[email protected]> Co-authored-by: Pablo Baeyens <[email protected]> Co-authored-by: Curtis Robert <[email protected]> Co-authored-by: VihasMakwana <[email protected]> Co-authored-by: Antoine Toulme <[email protected]> Co-authored-by: Dani Louca <[email protected]> Co-authored-by: xu0o0 <[email protected]> Co-authored-by: David Ashpole <[email protected]> Co-authored-by: Jared Tan <[email protected]> Co-authored-by: Raj Nishtala <[email protected]> Co-authored-by: Dominik Rosiek <[email protected]> Co-authored-by: Priyanshu Raj <[email protected]> Co-authored-by: Raphael Philipe Mendes da Silva <[email protected]> Co-authored-by: Anthony Mirabella <[email protected]> Co-authored-by: Yotam loewenbach <[email protected]> Co-authored-by: Alex Boten <[email protected]> Co-authored-by: Jina Jain <[email protected]> Co-authored-by: Curtis Robert <[email protected]> Co-authored-by: Abhishek Saharn <[email protected]> Co-authored-by: Ramachandran A G <[email protected]> Co-authored-by: Ziqi Zhao <[email protected]> Co-authored-by: Ramachandran A G <[email protected]> Co-authored-by: Faith Chikwekwe <[email protected]> Co-authored-by: Daniel Kuiper <[email protected]> Co-authored-by: ArchangelSDY <[email protected]> Co-authored-by: Pavol Loffay <[email protected]> Co-authored-by: Paulo Janotti <[email protected]> Co-authored-by: Nathan Burke <[email protected]> Co-authored-by: shalper2 <[email protected]> Co-authored-by: 道君 <[email protected]> Co-authored-by: Colin Desmond <[email protected]> Co-authored-by: Mario <[email protected]> Co-authored-by: Paulin Todev <[email protected]> Co-authored-by: Steven Swartz <[email protected]> Co-authored-by: Chris Parkins <[email protected]> Co-authored-by: Frederic Branczyk <[email protected]> Co-authored-by: Jiekun <[email protected]> Co-authored-by: Joel <[email protected]> Co-authored-by: Sean Porter <[email protected]> Co-authored-by: Tigran Najaryan <[email protected]> Co-authored-by: nzbart <[email protected]> Co-authored-by: Pavan Krishna <[email protected]> Co-authored-by: pszkamruk-splunk <[email protected]>
1 parent 8e09b17 commit d7e1933

File tree

24 files changed

+1534
-37
lines changed

24 files changed

+1534
-37
lines changed

.chloggen/add_inspect_metrics.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
2+
change_type: breaking
3+
4+
# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver)
5+
component: dockerstatsreceiver
6+
7+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
8+
note: "Add [container.cpu.limit], [container.cpu.shares] and [container.restarts] metrics from docker container api"
9+
10+
# One or more tracking issues related to the change
11+
issues: [21087]
12+
13+
# (Optional) One or more lines of additional information to render under the primary note.
14+
# These lines will be padded with 2 spaces and then inserted directly into the document.
15+
# Use pipe (|) for multiline entries.
16+
subtext: It requires API version 1.25 or greater.

receiver/dockerstatsreceiver/config_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ func TestLoadConfig(t *testing.T) {
4040
},
4141

4242
Endpoint: "http://example.com/",
43-
DockerAPIVersion: 1.24,
43+
DockerAPIVersion: 1.25,
4444

4545
ExcludedImages: []string{
4646
"undesired-container",
@@ -95,5 +95,5 @@ func TestValidateErrors(t *testing.T) {
9595
assert.Equal(t, "endpoint must be specified", component.ValidateConfig(cfg).Error())
9696

9797
cfg = &Config{ScraperControllerSettings: scraperhelper.ScraperControllerSettings{CollectionInterval: 1 * time.Second}, Endpoint: "someEndpoint", DockerAPIVersion: 1.21}
98-
assert.Equal(t, "api_version must be at least 1.22", component.ValidateConfig(cfg).Error())
98+
assert.Equal(t, "api_version must be at least 1.25", component.ValidateConfig(cfg).Error())
9999
}

receiver/dockerstatsreceiver/documentation.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,24 @@ Number of sectors transferred to/from disk by the group and descendant groups (O
296296
| device_minor | Device minor number for block IO operations. | Any Str |
297297
| operation | Type of BlockIO operation. | Any Str |
298298
299+
### container.cpu.limit
300+
301+
CPU limit set for the container.
302+
303+
This metric is only reported if the container has limits set with -cpus, -cpuset-cpus or -cpu-quota.
304+
305+
| Unit | Metric Type | Value Type |
306+
| ---- | ----------- | ---------- |
307+
| {cpus} | Gauge | Double |
308+
309+
### container.cpu.shares
310+
311+
CPU shares set for the container.
312+
313+
| Unit | Metric Type | Value Type |
314+
| ---- | ----------- | ---------- |
315+
| 1 | Gauge | Int |
316+
299317
### container.cpu.throttling_data.periods
300318
301319
Number of periods with throttling active.
@@ -698,6 +716,14 @@ It requires docker API 1.23 or higher and kernel version >= 4.3 with pids cgroup
698716
| ---- | ----------- | ---------- | ----------------------- | --------- |
699717
| {pids} | Sum | Int | Cumulative | false |
700718
719+
### container.restarts
720+
721+
Number of restarts for the container.
722+
723+
| Unit | Metric Type | Value Type | Aggregation Temporality | Monotonic |
724+
| ---- | ----------- | ---------- | ----------------------- | --------- |
725+
| {restarts} | Sum | Int | Cumulative | true |
726+
701727
### container.uptime
702728
703729
Time elapsed since container start time.

receiver/dockerstatsreceiver/internal/metadata/generated_config.go

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

receiver/dockerstatsreceiver/internal/metadata/generated_config_test.go

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

receiver/dockerstatsreceiver/internal/metadata/generated_metrics.go

Lines changed: 173 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)