package commonmetrics
import "github.com/containerd/stargz-snapshotter/fs/metrics/common"
Index ¶
- Constants
- func AddBytesCount(operation string, layer digest.Digest, bytes int64)
- func IncOperationCount(operation string, layer digest.Digest)
- func LogLatencyForLastOnDemandFetch(ctx context.Context, layer digest.Digest, start time.Time, end time.Time)
- func MeasureLatencyInMicroseconds(operation string, layer digest.Digest, start time.Time)
- func MeasureLatencyInMilliseconds(operation string, layer digest.Digest, start time.Time)
- func Register(l log.Level)
- func WriteLatencyLogValue(ctx context.Context, layer digest.Digest, operation string, start time.Time)
- func WriteLatencyWithBytesLogValue(ctx context.Context, layer digest.Digest, latencyOperation string, start time.Time, bytesMetricName string, bytesMetricValue int64)
Constants ¶
const ( // OperationLatencyKeyMilliseconds is the key for stargz operation latency metrics in milliseconds. OperationLatencyKeyMilliseconds = "operation_duration_milliseconds" // OperationLatencyKeyMicroseconds is the key for stargz operation latency metrics in microseconds. OperationLatencyKeyMicroseconds = "operation_duration_microseconds" // OperationCountKey is the key for stargz operation count metrics. OperationCountKey = "operation_count" // BytesServedKey is the key for any metric related to counting bytes served as the part of specific operation. BytesServedKey = "bytes_served" )
const ( // prometheus metrics Mount = "mount" RemoteRegistryGet = "remote_registry_get" NodeReaddir = "node_readdir" StargzHeaderGet = "stargz_header_get" = "stargz_footer_get" StargzTocGet = "stargz_toc_get" DeserializeTocJSON = "stargz_toc_json_deserialize" PrefetchesCompleted = "all_prefetches_completed" ReadOnDemand = "read_on_demand" MountLayerToLastOnDemandFetch = "mount_layer_to_last_on_demand_fetch" OnDemandReadAccessCount = "on_demand_read_access_count" OnDemandRemoteRegistryFetchCount = "on_demand_remote_registry_fetch_count" OnDemandBytesServed = "on_demand_bytes_served" OnDemandBytesFetched = "on_demand_bytes_fetched" // logs metrics PrefetchTotal = "prefetch_total" PrefetchDownload = "prefetch_download" PrefetchDecompress = "prefetch_decompress" BackgroundFetchTotal = "background_fetch_total" BackgroundFetchDownload = "background_fetch_download" BackgroundFetchDecompress = "background_fetch_decompress" PrefetchSize = "prefetch_size" )
Lists all metric labels.
Functions ¶
func AddBytesCount ¶
AddBytesCount wraps the labels attachment as well as calling Add into a single method.
func IncOperationCount ¶
IncOperationCount wraps the labels attachment as well as calling Inc into a single method.
func LogLatencyForLastOnDemandFetch ¶
func LogLatencyForLastOnDemandFetch(ctx context.Context, layer digest.Digest, start time.Time, end time.Time)
LogLatencyForLastOnDemandFetch implements a special case for measuring the latency of last on demand fetch, which must be invoked at the end of background fetch operation only. Since this is expected to happen only once per container launch, it writes a log line, instead of directly emitting a metric. We do that in the following way: 1. We record the mount start time 2. We constantly record the timestamps when we do on demand fetch for each layer sha 3. On background fetch completed we measure the difference between the last on demand fetch and mount start time and record it as a metric
func MeasureLatencyInMicroseconds ¶
MeasureLatencyInMicroseconds wraps the labels attachment as well as calling Observe into a single method. Right now we attach the operation and layer digest, so it's possible to see the breakdown for latency by operation and individual layers. If you want this to be layer agnostic, just pass the digest from empty string, e.g. layerDigest := digest.FromString("")
func MeasureLatencyInMilliseconds ¶
MeasureLatencyInMilliseconds wraps the labels attachment as well as calling Observe into a single method. Right now we attach the operation and layer digest, so it's possible to see the breakdown for latency by operation and individual layers. If you want this to be layer agnostic, just pass the digest from empty string, e.g. layerDigest := digest.FromString("")
func Register ¶
Register registers metrics. This is always called only once.
func WriteLatencyLogValue ¶
func WriteLatencyLogValue(ctx context.Context, layer digest.Digest, operation string, start time.Time)
WriteLatencyLogValue wraps writing the log info record for latency in milliseconds. The log record breaks down by operation and layer digest.
func WriteLatencyWithBytesLogValue ¶
func WriteLatencyWithBytesLogValue(ctx context.Context, layer digest.Digest, latencyOperation string, start time.Time, bytesMetricName string, bytesMetricValue int64)
WriteLatencyWithBytesLogValue wraps writing the log info record for latency in milliseconds with adding the size in bytes. The log record breaks down by operation, layer digest and byte value.
Source Files ¶
- Version
- v0.16.3 (latest)
- Published
- Dec 12, 2024
- Platform
- linux/amd64
- Imports
- 6 packages
- Last checked
- 2 weeks ago –
Tools for package owners.