Skip to content

Commit ed16170

Browse files
authored
Merge pull request #3666 from crosbymichael/metrics
Add metrics type alias
2 parents a0dafd9 + f3148d0 commit ed16170

8 files changed

Lines changed: 122 additions & 77 deletions

File tree

metrics/cgroups/blkio.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ package cgroups
2121
import (
2222
"strconv"
2323

24-
"github.com/containerd/cgroups"
24+
v1 "github.com/containerd/containerd/metrics/types/v1"
2525
metrics "github.com/docker/go-metrics"
2626
"github.com/prometheus/client_golang/prometheus"
2727
)
@@ -33,7 +33,7 @@ var blkioMetrics = []*metric{
3333
unit: metrics.Total,
3434
vt: prometheus.GaugeValue,
3535
labels: []string{"op", "device", "major", "minor"},
36-
getValues: func(stats *cgroups.Metrics) []value {
36+
getValues: func(stats *v1.Metrics) []value {
3737
if stats.Blkio == nil {
3838
return nil
3939
}
@@ -46,7 +46,7 @@ var blkioMetrics = []*metric{
4646
unit: metrics.Total,
4747
vt: prometheus.GaugeValue,
4848
labels: []string{"op", "device", "major", "minor"},
49-
getValues: func(stats *cgroups.Metrics) []value {
49+
getValues: func(stats *v1.Metrics) []value {
5050
if stats.Blkio == nil {
5151
return nil
5252
}
@@ -59,7 +59,7 @@ var blkioMetrics = []*metric{
5959
unit: metrics.Bytes,
6060
vt: prometheus.GaugeValue,
6161
labels: []string{"op", "device", "major", "minor"},
62-
getValues: func(stats *cgroups.Metrics) []value {
62+
getValues: func(stats *v1.Metrics) []value {
6363
if stats.Blkio == nil {
6464
return nil
6565
}
@@ -72,7 +72,7 @@ var blkioMetrics = []*metric{
7272
unit: metrics.Total,
7373
vt: prometheus.GaugeValue,
7474
labels: []string{"op", "device", "major", "minor"},
75-
getValues: func(stats *cgroups.Metrics) []value {
75+
getValues: func(stats *v1.Metrics) []value {
7676
if stats.Blkio == nil {
7777
return nil
7878
}
@@ -85,7 +85,7 @@ var blkioMetrics = []*metric{
8585
unit: metrics.Total,
8686
vt: prometheus.GaugeValue,
8787
labels: []string{"op", "device", "major", "minor"},
88-
getValues: func(stats *cgroups.Metrics) []value {
88+
getValues: func(stats *v1.Metrics) []value {
8989
if stats.Blkio == nil {
9090
return nil
9191
}
@@ -98,7 +98,7 @@ var blkioMetrics = []*metric{
9898
unit: metrics.Total,
9999
vt: prometheus.GaugeValue,
100100
labels: []string{"op", "device", "major", "minor"},
101-
getValues: func(stats *cgroups.Metrics) []value {
101+
getValues: func(stats *v1.Metrics) []value {
102102
if stats.Blkio == nil {
103103
return nil
104104
}
@@ -111,7 +111,7 @@ var blkioMetrics = []*metric{
111111
unit: metrics.Total,
112112
vt: prometheus.GaugeValue,
113113
labels: []string{"op", "device", "major", "minor"},
114-
getValues: func(stats *cgroups.Metrics) []value {
114+
getValues: func(stats *v1.Metrics) []value {
115115
if stats.Blkio == nil {
116116
return nil
117117
}
@@ -120,7 +120,7 @@ var blkioMetrics = []*metric{
120120
},
121121
}
122122

123-
func blkioValues(l []*cgroups.BlkIOEntry) []value {
123+
func blkioValues(l []*v1.BlkIOEntry) []value {
124124
var out []value
125125
for _, e := range l {
126126
out = append(out, value{

metrics/cgroups/cpu.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ package cgroups
2121
import (
2222
"strconv"
2323

24-
"github.com/containerd/cgroups"
24+
v1 "github.com/containerd/containerd/metrics/types/v1"
2525
metrics "github.com/docker/go-metrics"
2626
"github.com/prometheus/client_golang/prometheus"
2727
)
@@ -32,7 +32,7 @@ var cpuMetrics = []*metric{
3232
help: "The total cpu time",
3333
unit: metrics.Nanoseconds,
3434
vt: prometheus.GaugeValue,
35-
getValues: func(stats *cgroups.Metrics) []value {
35+
getValues: func(stats *v1.Metrics) []value {
3636
if stats.CPU == nil {
3737
return nil
3838
}
@@ -48,7 +48,7 @@ var cpuMetrics = []*metric{
4848
help: "The total kernel cpu time",
4949
unit: metrics.Nanoseconds,
5050
vt: prometheus.GaugeValue,
51-
getValues: func(stats *cgroups.Metrics) []value {
51+
getValues: func(stats *v1.Metrics) []value {
5252
if stats.CPU == nil {
5353
return nil
5454
}
@@ -64,7 +64,7 @@ var cpuMetrics = []*metric{
6464
help: "The total user cpu time",
6565
unit: metrics.Nanoseconds,
6666
vt: prometheus.GaugeValue,
67-
getValues: func(stats *cgroups.Metrics) []value {
67+
getValues: func(stats *v1.Metrics) []value {
6868
if stats.CPU == nil {
6969
return nil
7070
}
@@ -81,7 +81,7 @@ var cpuMetrics = []*metric{
8181
unit: metrics.Nanoseconds,
8282
vt: prometheus.GaugeValue,
8383
labels: []string{"cpu"},
84-
getValues: func(stats *cgroups.Metrics) []value {
84+
getValues: func(stats *v1.Metrics) []value {
8585
if stats.CPU == nil {
8686
return nil
8787
}
@@ -100,7 +100,7 @@ var cpuMetrics = []*metric{
100100
help: "The total cpu throttle periods",
101101
unit: metrics.Total,
102102
vt: prometheus.GaugeValue,
103-
getValues: func(stats *cgroups.Metrics) []value {
103+
getValues: func(stats *v1.Metrics) []value {
104104
if stats.CPU == nil {
105105
return nil
106106
}
@@ -116,7 +116,7 @@ var cpuMetrics = []*metric{
116116
help: "The total cpu throttled periods",
117117
unit: metrics.Total,
118118
vt: prometheus.GaugeValue,
119-
getValues: func(stats *cgroups.Metrics) []value {
119+
getValues: func(stats *v1.Metrics) []value {
120120
if stats.CPU == nil {
121121
return nil
122122
}
@@ -132,7 +132,7 @@ var cpuMetrics = []*metric{
132132
help: "The total cpu throttled time",
133133
unit: metrics.Nanoseconds,
134134
vt: prometheus.GaugeValue,
135-
getValues: func(stats *cgroups.Metrics) []value {
135+
getValues: func(stats *v1.Metrics) []value {
136136
if stats.CPU == nil {
137137
return nil
138138
}

metrics/cgroups/hugetlb.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
package cgroups
2020

2121
import (
22-
"github.com/containerd/cgroups"
22+
v1 "github.com/containerd/containerd/metrics/types/v1"
2323
metrics "github.com/docker/go-metrics"
2424
"github.com/prometheus/client_golang/prometheus"
2525
)
@@ -31,7 +31,7 @@ var hugetlbMetrics = []*metric{
3131
unit: metrics.Bytes,
3232
vt: prometheus.GaugeValue,
3333
labels: []string{"page"},
34-
getValues: func(stats *cgroups.Metrics) []value {
34+
getValues: func(stats *v1.Metrics) []value {
3535
if stats.Hugetlb == nil {
3636
return nil
3737
}
@@ -51,7 +51,7 @@ var hugetlbMetrics = []*metric{
5151
unit: metrics.Total,
5252
vt: prometheus.GaugeValue,
5353
labels: []string{"page"},
54-
getValues: func(stats *cgroups.Metrics) []value {
54+
getValues: func(stats *v1.Metrics) []value {
5555
if stats.Hugetlb == nil {
5656
return nil
5757
}
@@ -71,7 +71,7 @@ var hugetlbMetrics = []*metric{
7171
unit: metrics.Bytes,
7272
vt: prometheus.GaugeValue,
7373
labels: []string{"page"},
74-
getValues: func(stats *cgroups.Metrics) []value {
74+
getValues: func(stats *v1.Metrics) []value {
7575
if stats.Hugetlb == nil {
7676
return nil
7777
}

0 commit comments

Comments
 (0)