Debian Codegraph @

fs/metrics/layer/metrics.go

raw symbols SCIP
1 /*
2 Copyright The containerd Authors.
3
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
15 */
16
17 package layermetricsscip-go gomod github.com/containerd/stargz-snapshotter . `github.com/containerd/stargz-snapshotter/fs/metrics/layer`/
18
19 import (
20 "syncscip-go gomod github.com/golang/go/src go1.19 sync/"
21
22 "github.com/containerd/stargz-snapshotter/fs/layerscip-go gomod github.com/containerd/stargz-snapshotter . `github.com/containerd/stargz-snapshotter/fs/layer`/"
23 metricsscip-go gomod github.com/docker/go-metrics v0.0.1 `github.com/docker/go-metrics`/ "github.com/docker/go-metricsscip-go gomod github.com/docker/go-metrics v0.0.1 `github.com/docker/go-metrics`/"
24 "github.com/prometheus/client_golang/prometheusscip-go gomod github.com/prometheus/client_golang v1.14.0 `github.com/prometheus/client_golang/prometheus`/"
25 )
26
27 func NewLayerMetricsscip-go gomod github.com/containerd/stargz-snapshotter . `github.com/containerd/stargz-snapshotter/fs/metrics/layer`/NewLayerMetrics().(ns *metricsscip-go gomod github.com/docker/go-metrics v0.0.1 `github.com/docker/go-metrics`/.Namespacescip-go gomod github.com/docker/go-metrics v0.0.1 `github.com/docker/go-metrics`/Namespace#) *Controllerscip-go gomod github.com/containerd/stargz-snapshotter . `github.com/containerd/stargz-snapshotter/fs/metrics/layer`/Controller# {
28 if ns == nil {
29 return &Controllerscip-go gomod github.com/containerd/stargz-snapshotter . `github.com/containerd/stargz-snapshotter/fs/metrics/layer`/Controller#{}
30 }
31 c := &Controllerscip-go gomod github.com/containerd/stargz-snapshotter . `github.com/containerd/stargz-snapshotter/fs/metrics/layer`/Controller#{
32 nsscip-go gomod github.com/containerd/stargz-snapshotter . `github.com/containerd/stargz-snapshotter/fs/metrics/layer`/Controller#ns.: ns,
33 layerscip-go gomod github.com/containerd/stargz-snapshotter . `github.com/containerd/stargz-snapshotter/fs/metrics/layer`/Controller#layer.: make(map[string]layerscip-go gomod github.com/containerd/stargz-snapshotter . `github.com/containerd/stargz-snapshotter/fs/layer`/.Layerscip-go gomod github.com/containerd/stargz-snapshotter . `github.com/containerd/stargz-snapshotter/fs/layer`/Layer#),
34 }
35 c.metricsscip-go gomod github.com/containerd/stargz-snapshotter . `github.com/containerd/stargz-snapshotter/fs/metrics/layer`/Controller#metrics. = append(c.metricsscip-go gomod github.com/containerd/stargz-snapshotter . `github.com/containerd/stargz-snapshotter/fs/metrics/layer`/Controller#metrics., layerMetricsscip-go gomod github.com/containerd/stargz-snapshotter . `github.com/containerd/stargz-snapshotter/fs/metrics/layer`/layerMetrics....)
36 ns.Addscip-go gomod github.com/docker/go-metrics v0.0.1 `github.com/docker/go-metrics`/Namespace#Add().(c)
37 return c
38 }
39
40 type Controllerscip-go gomod github.com/containerd/stargz-snapshotter . `github.com/containerd/stargz-snapshotter/fs/metrics/layer`/Controller# struct {
41 nsscip-go gomod github.com/containerd/stargz-snapshotter . `github.com/containerd/stargz-snapshotter/fs/metrics/layer`/Controller#ns. *metricsscip-go gomod github.com/docker/go-metrics v0.0.1 `github.com/docker/go-metrics`/.Namespacescip-go gomod github.com/docker/go-metrics v0.0.1 `github.com/docker/go-metrics`/Namespace#
42 metricsscip-go gomod github.com/containerd/stargz-snapshotter . `github.com/containerd/stargz-snapshotter/fs/metrics/layer`/Controller#metrics. []*metricscip-go gomod github.com/containerd/stargz-snapshotter . `github.com/containerd/stargz-snapshotter/fs/metrics/layer`/metric#
43
44 layerscip-go gomod github.com/containerd/stargz-snapshotter . `github.com/containerd/stargz-snapshotter/fs/metrics/layer`/Controller#layer. map[string]layerscip-go gomod github.com/containerd/stargz-snapshotter . `github.com/containerd/stargz-snapshotter/fs/layer`/.Layerscip-go gomod github.com/containerd/stargz-snapshotter . `github.com/containerd/stargz-snapshotter/fs/layer`/Layer#
45 layerMuscip-go gomod github.com/containerd/stargz-snapshotter . `github.com/containerd/stargz-snapshotter/fs/metrics/layer`/Controller#layerMu. syncscip-go gomod github.com/golang/go/src go1.19 sync/.RWMutexscip-go gomod github.com/golang/go/src go1.19 sync/RWMutex#
46 }
47
48 func (c *Controllerscip-go gomod github.com/containerd/stargz-snapshotter . `github.com/containerd/stargz-snapshotter/fs/metrics/layer`/Controller#) Describescip-go gomod github.com/containerd/stargz-snapshotter . `github.com/containerd/stargz-snapshotter/fs/metrics/layer`/Controller#Describe().(ch chan<- *prometheusscip-go gomod github.com/prometheus/client_golang v1.14.0 `github.com/prometheus/client_golang/prometheus`/.Descscip-go gomod github.com/prometheus/client_golang v1.14.0 `github.com/prometheus/client_golang/prometheus`/Desc#) {
49 for _, e := range c.metricsscip-go gomod github.com/containerd/stargz-snapshotter . `github.com/containerd/stargz-snapshotter/fs/metrics/layer`/Controller#metrics. {
50 ch <- e.descscip-go gomod github.com/containerd/stargz-snapshotter . `github.com/containerd/stargz-snapshotter/fs/metrics/layer`/metric#desc().(c.nsscip-go gomod github.com/containerd/stargz-snapshotter . `github.com/containerd/stargz-snapshotter/fs/metrics/layer`/Controller#ns.)
51 }
52 }
53
54 func (c *Controllerscip-go gomod github.com/containerd/stargz-snapshotter . `github.com/containerd/stargz-snapshotter/fs/metrics/layer`/Controller#) Collectscip-go gomod github.com/containerd/stargz-snapshotter . `github.com/containerd/stargz-snapshotter/fs/metrics/layer`/Controller#Collect().(ch chan<- prometheusscip-go gomod github.com/prometheus/client_golang v1.14.0 `github.com/prometheus/client_golang/prometheus`/.Metricscip-go gomod github.com/prometheus/client_golang v1.14.0 `github.com/prometheus/client_golang/prometheus`/Metric#) {
55 c.layerMuscip-go gomod github.com/containerd/stargz-snapshotter . `github.com/containerd/stargz-snapshotter/fs/metrics/layer`/Controller#layerMu..RLockscip-go gomod github.com/golang/go/src go1.19 sync/RWMutex#RLock().()
56 wg := &syncscip-go gomod github.com/golang/go/src go1.19 sync/.WaitGroupscip-go gomod github.com/golang/go/src go1.19 sync/WaitGroup#{}
57 for mp, l := range c.layerscip-go gomod github.com/containerd/stargz-snapshotter . `github.com/containerd/stargz-snapshotter/fs/metrics/layer`/Controller#layer. {
58 mp, l := mp, l
59 wg.Addscip-go gomod github.com/golang/go/src go1.19 sync/WaitGroup#Add().(1)
60 go func() {
61 defer wg.Donescip-go gomod github.com/golang/go/src go1.19 sync/WaitGroup#Done().()
62 for _, e := range c.metricsscip-go gomod github.com/containerd/stargz-snapshotter . `github.com/containerd/stargz-snapshotter/fs/metrics/layer`/Controller#metrics. {
63 e.collectscip-go gomod github.com/containerd/stargz-snapshotter . `github.com/containerd/stargz-snapshotter/fs/metrics/layer`/metric#collect().(mp, l, c.nsscip-go gomod github.com/containerd/stargz-snapshotter . `github.com/containerd/stargz-snapshotter/fs/metrics/layer`/Controller#ns., ch)
64 }
65 }()
66 }
67 c.layerMuscip-go gomod github.com/containerd/stargz-snapshotter . `github.com/containerd/stargz-snapshotter/fs/metrics/layer`/Controller#layerMu..RUnlockscip-go gomod github.com/golang/go/src go1.19 sync/RWMutex#RUnlock().()
68 wg.Waitscip-go gomod github.com/golang/go/src go1.19 sync/WaitGroup#Wait().()
69 }
70
71 func (c *Controllerscip-go gomod github.com/containerd/stargz-snapshotter . `github.com/containerd/stargz-snapshotter/fs/metrics/layer`/Controller#) Addscip-go gomod github.com/containerd/stargz-snapshotter . `github.com/containerd/stargz-snapshotter/fs/metrics/layer`/Controller#Add().(key string, l layerscip-go gomod github.com/containerd/stargz-snapshotter . `github.com/containerd/stargz-snapshotter/fs/layer`/.Layerscip-go gomod github.com/containerd/stargz-snapshotter . `github.com/containerd/stargz-snapshotter/fs/layer`/Layer#) {
72 if c.nsscip-go gomod github.com/containerd/stargz-snapshotter . `github.com/containerd/stargz-snapshotter/fs/metrics/layer`/Controller#ns. == nil {
73 return
74 }
75 c.layerMuscip-go gomod github.com/containerd/stargz-snapshotter . `github.com/containerd/stargz-snapshotter/fs/metrics/layer`/Controller#layerMu..Lockscip-go gomod github.com/golang/go/src go1.19 sync/RWMutex#Lock().()
76 c.layerscip-go gomod github.com/containerd/stargz-snapshotter . `github.com/containerd/stargz-snapshotter/fs/metrics/layer`/Controller#layer.[key] = l
77 c.layerMuscip-go gomod github.com/containerd/stargz-snapshotter . `github.com/containerd/stargz-snapshotter/fs/metrics/layer`/Controller#layerMu..Unlockscip-go gomod github.com/golang/go/src go1.19 sync/RWMutex#Unlock().()
78 }
79
80 func (c *Controllerscip-go gomod github.com/containerd/stargz-snapshotter . `github.com/containerd/stargz-snapshotter/fs/metrics/layer`/Controller#) Removescip-go gomod github.com/containerd/stargz-snapshotter . `github.com/containerd/stargz-snapshotter/fs/metrics/layer`/Controller#Remove().(key string) {
81 if c.nsscip-go gomod github.com/containerd/stargz-snapshotter . `github.com/containerd/stargz-snapshotter/fs/metrics/layer`/Controller#ns. == nil {
82 return
83 }
84 c.layerMuscip-go gomod github.com/containerd/stargz-snapshotter . `github.com/containerd/stargz-snapshotter/fs/metrics/layer`/Controller#layerMu..Lockscip-go gomod github.com/golang/go/src go1.19 sync/RWMutex#Lock().()
85 delete(c.layerscip-go gomod github.com/containerd/stargz-snapshotter . `github.com/containerd/stargz-snapshotter/fs/metrics/layer`/Controller#layer., key)
86 c.layerMuscip-go gomod github.com/containerd/stargz-snapshotter . `github.com/containerd/stargz-snapshotter/fs/metrics/layer`/Controller#layerMu..Unlockscip-go gomod github.com/golang/go/src go1.19 sync/RWMutex#Unlock().()
87 }
88
89 type valuescip-go gomod github.com/containerd/stargz-snapshotter . `github.com/containerd/stargz-snapshotter/fs/metrics/layer`/value# struct {
90 vscip-go gomod github.com/containerd/stargz-snapshotter . `github.com/containerd/stargz-snapshotter/fs/metrics/layer`/value#v. float64
91 lscip-go gomod github.com/containerd/stargz-snapshotter . `github.com/containerd/stargz-snapshotter/fs/metrics/layer`/value#l. []string
92 }
93
94 type metricscip-go gomod github.com/containerd/stargz-snapshotter . `github.com/containerd/stargz-snapshotter/fs/metrics/layer`/metric# struct {
95 namescip-go gomod github.com/containerd/stargz-snapshotter . `github.com/containerd/stargz-snapshotter/fs/metrics/layer`/metric#name. string
96 helpscip-go gomod github.com/containerd/stargz-snapshotter . `github.com/containerd/stargz-snapshotter/fs/metrics/layer`/metric#help. string
97 unitscip-go gomod github.com/containerd/stargz-snapshotter . `github.com/containerd/stargz-snapshotter/fs/metrics/layer`/metric#unit. metricsscip-go gomod github.com/docker/go-metrics v0.0.1 `github.com/docker/go-metrics`/.Unitscip-go gomod github.com/docker/go-metrics v0.0.1 `github.com/docker/go-metrics`/Unit#
98 vtscip-go gomod github.com/containerd/stargz-snapshotter . `github.com/containerd/stargz-snapshotter/fs/metrics/layer`/metric#vt. prometheusscip-go gomod github.com/prometheus/client_golang v1.14.0 `github.com/prometheus/client_golang/prometheus`/.ValueTypescip-go gomod github.com/prometheus/client_golang v1.14.0 `github.com/prometheus/client_golang/prometheus`/ValueType#
99 labelsscip-go gomod github.com/containerd/stargz-snapshotter . `github.com/containerd/stargz-snapshotter/fs/metrics/layer`/metric#labels. []string
100 // getValues returns the value and labels for the data
101 getValuesscip-go gomod github.com/containerd/stargz-snapshotter . `github.com/containerd/stargz-snapshotter/fs/metrics/layer`/metric#getValues. func(l layerscip-go gomod github.com/containerd/stargz-snapshotter . `github.com/containerd/stargz-snapshotter/fs/layer`/.Layerscip-go gomod github.com/containerd/stargz-snapshotter . `github.com/containerd/stargz-snapshotter/fs/layer`/Layer#) []valuescip-go gomod github.com/containerd/stargz-snapshotter . `github.com/containerd/stargz-snapshotter/fs/metrics/layer`/value#
102 }
103
104 func (m *metricscip-go gomod github.com/containerd/stargz-snapshotter . `github.com/containerd/stargz-snapshotter/fs/metrics/layer`/metric#) descscip-go gomod github.com/containerd/stargz-snapshotter . `github.com/containerd/stargz-snapshotter/fs/metrics/layer`/metric#desc().(ns *metricsscip-go gomod github.com/docker/go-metrics v0.0.1 `github.com/docker/go-metrics`/.Namespacescip-go gomod github.com/docker/go-metrics v0.0.1 `github.com/docker/go-metrics`/Namespace#) *prometheusscip-go gomod github.com/prometheus/client_golang v1.14.0 `github.com/prometheus/client_golang/prometheus`/.Descscip-go gomod github.com/prometheus/client_golang v1.14.0 `github.com/prometheus/client_golang/prometheus`/Desc# {
105 return ns.NewDescscip-go gomod github.com/docker/go-metrics v0.0.1 `github.com/docker/go-metrics`/Namespace#NewDesc().(m.namescip-go gomod github.com/containerd/stargz-snapshotter . `github.com/containerd/stargz-snapshotter/fs/metrics/layer`/metric#name., m.helpscip-go gomod github.com/containerd/stargz-snapshotter . `github.com/containerd/stargz-snapshotter/fs/metrics/layer`/metric#help., m.unitscip-go gomod github.com/containerd/stargz-snapshotter . `github.com/containerd/stargz-snapshotter/fs/metrics/layer`/metric#unit., append([]string{"digest", "mountpoint"}, m.labelsscip-go gomod github.com/containerd/stargz-snapshotter . `github.com/containerd/stargz-snapshotter/fs/metrics/layer`/metric#labels....)...)
106 }
107
108 func (m *metricscip-go gomod github.com/containerd/stargz-snapshotter . `github.com/containerd/stargz-snapshotter/fs/metrics/layer`/metric#) collectscip-go gomod github.com/containerd/stargz-snapshotter . `github.com/containerd/stargz-snapshotter/fs/metrics/layer`/metric#collect().(mountpoint string, l layerscip-go gomod github.com/containerd/stargz-snapshotter . `github.com/containerd/stargz-snapshotter/fs/layer`/.Layerscip-go gomod github.com/containerd/stargz-snapshotter . `github.com/containerd/stargz-snapshotter/fs/layer`/Layer#, ns *metricsscip-go gomod github.com/docker/go-metrics v0.0.1 `github.com/docker/go-metrics`/.Namespacescip-go gomod github.com/docker/go-metrics v0.0.1 `github.com/docker/go-metrics`/Namespace#, ch chan<- prometheusscip-go gomod github.com/prometheus/client_golang v1.14.0 `github.com/prometheus/client_golang/prometheus`/.Metricscip-go gomod github.com/prometheus/client_golang v1.14.0 `github.com/prometheus/client_golang/prometheus`/Metric#) {
109 values := m.getValuesscip-go gomod github.com/containerd/stargz-snapshotter . `github.com/containerd/stargz-snapshotter/fs/metrics/layer`/metric#getValues.(l)
110 for _, v := range values {
111 ch <- prometheusscip-go gomod github.com/prometheus/client_golang v1.14.0 `github.com/prometheus/client_golang/prometheus`/.MustNewConstMetricscip-go gomod github.com/prometheus/client_golang v1.14.0 `github.com/prometheus/client_golang/prometheus`/MustNewConstMetric().(m.descscip-go gomod github.com/containerd/stargz-snapshotter . `github.com/containerd/stargz-snapshotter/fs/metrics/layer`/metric#desc().(ns), m.vtscip-go gomod github.com/containerd/stargz-snapshotter . `github.com/containerd/stargz-snapshotter/fs/metrics/layer`/metric#vt., v.vscip-go gomod github.com/containerd/stargz-snapshotter . `github.com/containerd/stargz-snapshotter/fs/metrics/layer`/value#v., append([]string{l.Infoscip-go gomod github.com/containerd/stargz-snapshotter . `github.com/containerd/stargz-snapshotter/fs/layer`/Layer#Info.().Digestscip-go gomod github.com/containerd/stargz-snapshotter . `github.com/containerd/stargz-snapshotter/fs/layer`/Info#Digest..Stringscip-go gomod github.com/opencontainers/go-digest v1.0.0 `github.com/opencontainers/go-digest`/Digest#String().(), mountpoint}, v.lscip-go gomod github.com/containerd/stargz-snapshotter . `github.com/containerd/stargz-snapshotter/fs/metrics/layer`/value#l....)...)
112 }
113 }