mirror of
https://github.com/kopia/kopia.git
synced 2026-01-25 23:08:01 -05:00
This may be a breaking change for users who rely on particular kopia metrics (unlikely):
- introduced blob-level metrics:
* `kopia_blob_download_full_blob_bytes_total`
* `kopia_blob_download_partial_blob_bytes_total`
* `kopia_blob_upload_bytes_total`
* `kopia_blob_storage_latency_ms` - per-method latency distribution
* `kopia_blob_errors_total` - per-method error counter
- updated cache metrics to indicate particular cache
* `kopia_cache_hit_bytes_total{cache="CACHE_TYPE"}`
* `kopia_cache_hit_total{cache="CACHE_TYPE"}`
* `kopia_cache_malformed_total{cache="CACHE_TYPE"}`
* `kopia_cache_miss_total{cache="CACHE_TYPE"}`
* `kopia_cache_miss_errors_total{cache="CACHE_TYPE"}`
* `kopia_cache_miss_bytes_total{cache="CACHE_TYPE"}`
* `kopia_cache_store_errors_total{cache="CACHE_TYPE"}`
where `CACHE_TYPE` is one of `contents`, `metadata` or `index-blobs`
- reorganized and unified content-level metrics:
* `kopia_content_write_bytes_total`
* `kopia_content_write_duration_nanos_total`
* `kopia_content_compression_attempted_bytes_total`
* `kopia_content_compression_attempted_duration_nanos_total`
* `kopia_content_compression_savings_bytes_total`
* `kopia_content_compressible_bytes_total`
* `kopia_content_non_compressible_bytes_total`
* `kopia_content_after_compression_bytes_total`
* `kopia_content_decompressed_bytes_total`
* `kopia_content_decompressed_duration_nanos_total`
* `kopia_content_encrypted_bytes_total`
* `kopia_content_encrypted_duration_nanos_total`
* `kopia_content_hashed_bytes_total`
* `kopia_content_hashed_duration_nanos_total`
* `kopia_content_deduplicated_bytes_total`
* `kopia_content_read_bytes_total`
* `kopia_content_read_duration_nanos_total`
* `kopia_content_decrypted_bytes_total`
* `kopia_content_decrypted_duration_nanos_total`
* `kopia_content_uploaded_bytes_total`
Also introduced `internal/metrics` framework which constructs Prometheus metrics in a uniform way and will allow us to include some of these metrics in telemetry report in future PRs.
72 lines
1.9 KiB
Go
72 lines
1.9 KiB
Go
package cache
|
|
|
|
import "github.com/kopia/kopia/internal/metrics"
|
|
|
|
type metricsStruct struct {
|
|
metricHitCount *metrics.Counter
|
|
metricHitBytes *metrics.Counter
|
|
metricMissCount *metrics.Counter
|
|
metricMalformedCacheDataCount *metrics.Counter
|
|
metricMissBytes *metrics.Counter
|
|
metricMissErrors *metrics.Counter
|
|
metricStoreErrors *metrics.Counter
|
|
}
|
|
|
|
func initMetricsStruct(mr *metrics.Registry, cacheID string) metricsStruct {
|
|
labels := map[string]string{
|
|
"cache": cacheID,
|
|
}
|
|
|
|
return metricsStruct{
|
|
metricHitCount: mr.CounterInt64(
|
|
"cache_hit",
|
|
"Number of time content was retrieved from the cache", labels),
|
|
|
|
metricHitBytes: mr.CounterInt64(
|
|
"cache_hit_bytes",
|
|
"Number of bytes retrieved from the cache", labels),
|
|
|
|
metricMissCount: mr.CounterInt64(
|
|
"cache_miss",
|
|
"Number of time content was not found in the cache and fetched from the storage", labels),
|
|
|
|
metricMalformedCacheDataCount: mr.CounterInt64(
|
|
"cache_malformed",
|
|
"Number of times malformed content was read from the cache", labels),
|
|
|
|
metricMissBytes: mr.CounterInt64(
|
|
"cache_miss_bytes",
|
|
"Number of bytes retrieved from the underlying storage", labels),
|
|
|
|
metricMissErrors: mr.CounterInt64(
|
|
"cache_miss_errors",
|
|
"Number of time content could not be found in the underlying storage", labels),
|
|
|
|
metricStoreErrors: mr.CounterInt64(
|
|
"cache_store_errors",
|
|
"Number of time content could not be saved in the cache", labels),
|
|
}
|
|
}
|
|
|
|
func (s *metricsStruct) reportMissError() {
|
|
s.metricMissErrors.Add(1)
|
|
}
|
|
|
|
func (s *metricsStruct) reportMissBytes(length int64) {
|
|
s.metricMissCount.Add(1)
|
|
s.metricMissBytes.Add(length)
|
|
}
|
|
|
|
func (s *metricsStruct) reportHitBytes(length int64) {
|
|
s.metricHitCount.Add(1)
|
|
s.metricHitBytes.Add(length)
|
|
}
|
|
|
|
func (s *metricsStruct) reportMalformedData() {
|
|
s.metricMalformedCacheDataCount.Add(1)
|
|
}
|
|
|
|
func (s *metricsStruct) reportStoreError() {
|
|
s.metricStoreErrors.Add(1)
|
|
}
|