mirror of
https://github.com/kopia/kopia.git
synced 2026-05-11 08:16:12 -04: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.
43 lines
956 B
Go
43 lines
956 B
Go
package metrics
|
|
|
|
import (
|
|
"time"
|
|
)
|
|
|
|
// Throughput measures throughput by keeping track of total value and total duration.
|
|
type Throughput struct {
|
|
totalBytes *Counter
|
|
totalDuration *Counter
|
|
}
|
|
|
|
// Observe increases duration and total value counters based on the amount of time to process particular amount of data.
|
|
func (c *Throughput) Observe(size int64, dt time.Duration) {
|
|
if c == nil {
|
|
return
|
|
}
|
|
|
|
c.totalBytes.Add(size)
|
|
c.totalDuration.Add(dt.Nanoseconds())
|
|
}
|
|
|
|
// Throughput gets a persistent counter with the provided name.
|
|
func (r *Registry) Throughput(name, help string, labels map[string]string) *Throughput {
|
|
if r == nil {
|
|
return nil
|
|
}
|
|
|
|
fullName := name + labelsSuffix(labels)
|
|
|
|
c := r.allThroughput[fullName]
|
|
if c == nil {
|
|
c = &Throughput{
|
|
totalBytes: r.CounterInt64(name+"_bytes", help, labels),
|
|
totalDuration: r.CounterInt64(name+"_duration_nanos", help, labels),
|
|
}
|
|
|
|
r.allThroughput[fullName] = c
|
|
}
|
|
|
|
return c
|
|
}
|