|
| 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 server |
| 18 | + |
| 19 | +import ( |
| 20 | + metrics "github.com/docker/go-metrics" |
| 21 | +) |
| 22 | + |
| 23 | +var ( |
| 24 | + sandboxListTimer metrics.Timer |
| 25 | + sandboxCreateNetworkTimer metrics.Timer |
| 26 | + sandboxDeleteNetwork metrics.Timer |
| 27 | + |
| 28 | + sandboxRuntimeCreateTimer metrics.LabeledTimer |
| 29 | + sandboxRuntimeStopTimer metrics.LabeledTimer |
| 30 | + sandboxRemoveTimer metrics.LabeledTimer |
| 31 | + |
| 32 | + containerListTimer metrics.Timer |
| 33 | + containerRemoveTimer metrics.LabeledTimer |
| 34 | + containerCreateTimer metrics.LabeledTimer |
| 35 | + containerStopTimer metrics.LabeledTimer |
| 36 | + containerStartTimer metrics.LabeledTimer |
| 37 | +) |
| 38 | + |
| 39 | +func init() { |
| 40 | + // these CRI metrics record latencies for successful operations around a sandbox and container's lifecycle. |
| 41 | + ns := metrics.NewNamespace("containerd", "cri", nil) |
| 42 | + |
| 43 | + sandboxListTimer = ns.NewTimer("sandbox_list", "time to list sandboxes") |
| 44 | + sandboxCreateNetworkTimer = ns.NewTimer("sandbox_create_network", "time to create the network for a sandbox") |
| 45 | + sandboxDeleteNetwork = ns.NewTimer("sandbox_delete_network", "time to delete a sandbox's network") |
| 46 | + |
| 47 | + sandboxRuntimeCreateTimer = ns.NewLabeledTimer("sandbox_runtime_create", "time to create a sandbox in the runtime", "runtime") |
| 48 | + sandboxRuntimeStopTimer = ns.NewLabeledTimer("sandbox_runtime_stop", "time to stop a sandbox", "runtime") |
| 49 | + sandboxRemoveTimer = ns.NewLabeledTimer("sandbox_remove", "time to remove a sandbox", "runtime") |
| 50 | + |
| 51 | + containerListTimer = ns.NewTimer("container_list", "time to list containers") |
| 52 | + containerRemoveTimer = ns.NewLabeledTimer("container_remove", "time to remove a container", "runtime") |
| 53 | + containerCreateTimer = ns.NewLabeledTimer("container_create", "time to create a container", "runtime") |
| 54 | + containerStopTimer = ns.NewLabeledTimer("container_stop", "time to stop a container", "runtime") |
| 55 | + containerStartTimer = ns.NewLabeledTimer("container_start", "time to start a container", "runtime") |
| 56 | + |
| 57 | + metrics.Register(ns) |
| 58 | +} |
0 commit comments