| 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 layermetrics |
| 18 |
|
| 19 |
import ( |
| 20 |
"github.com/containerd/stargz-snapshotter/fs/layer" |
| 21 |
metrics "github.com/docker/go-metrics" |
| 22 |
"github.com/prometheus/client_golang/prometheus" |
| 23 |
) |
| 24 |
|
| 25 |
var layerMetrics = []*metric{ |
| 26 |
{ |
| 27 |
name: "layer_fetched_size", |
| 28 |
help: "Total fetched size of the layer", |
| 29 |
unit: metrics.Bytes, |
| 30 |
vt: prometheus.CounterValue, |
| 31 |
getValues: func(l layer.Layer) []value { |
| 32 |
return []value{ |
| 33 |
{ |
| 34 |
v: float64(l.Info().FetchedSize), |
| 35 |
}, |
| 36 |
} |
| 37 |
}, |
| 38 |
}, |
| 39 |
{ |
| 40 |
name: "layer_prefetch_size", |
| 41 |
help: "Total prefetched size of the layer", |
| 42 |
unit: metrics.Bytes, |
| 43 |
vt: prometheus.CounterValue, |
| 44 |
getValues: func(l layer.Layer) []value { |
| 45 |
return []value{ |
| 46 |
{ |
| 47 |
v: float64(l.Info().PrefetchSize), |
| 48 |
}, |
| 49 |
} |
| 50 |
}, |
| 51 |
}, |
| 52 |
{ |
| 53 |
name: "layer_size", |
| 54 |
help: "Total size of the layer", |
| 55 |
unit: metrics.Bytes, |
| 56 |
vt: prometheus.CounterValue, |
| 57 |
getValues: func(l layer.Layer) []value { |
| 58 |
return []value{ |
| 59 |
{ |
| 60 |
v: float64(l.Info().Size), |
| 61 |
}, |
| 62 |
} |
| 63 |
}, |
| 64 |
}, |
| 65 |
} |