This repository has been archived by the owner on May 26, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from hendrikKahl/cache-metrics
add prometheus metrics to cache
- Loading branch information
Showing
95 changed files
with
19,546 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
// SPDX-FileCopyrightText: 2021 SAP SE or an SAP affiliate company and Gardener contributors. | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package metrics | ||
|
||
import "github.com/prometheus/client_golang/prometheus" | ||
|
||
const ( | ||
ociClientNamespaceName = "ociclient" | ||
cacheSubsystemName = "cache" | ||
) | ||
|
||
var ( | ||
// CacheMemoryUsage discloses memory used by caches | ||
CacheMemoryUsage = prometheus.NewGaugeVec( | ||
prometheus.GaugeOpts{ | ||
Namespace: ociClientNamespaceName, | ||
Subsystem: cacheSubsystemName, | ||
Name: "memory_usage_bytes", | ||
Help: "Bytes in memory currently used by cache instance.", | ||
}, | ||
[]string{"path"}, | ||
) | ||
|
||
// CacheDiskUsage discloses disk used by caches | ||
CacheDiskUsage = prometheus.NewGaugeVec( | ||
prometheus.GaugeOpts{ | ||
Namespace: ociClientNamespaceName, | ||
Subsystem: cacheSubsystemName, | ||
Name: "disk_usage_bytes", | ||
Help: "Bytes on disk currently used by cache instance.", | ||
}, | ||
[]string{"path"}, | ||
) | ||
|
||
// CachedItems discloses the number of items stored by caches | ||
CachedItems = prometheus.NewGaugeVec( | ||
prometheus.GaugeOpts{ | ||
Namespace: ociClientNamespaceName, | ||
Subsystem: cacheSubsystemName, | ||
Name: "items_total", | ||
Help: "Total number of items currently cached by instance.", | ||
}, | ||
[]string{"path"}, | ||
) | ||
|
||
// CacheHitsDisk discloses the number of hits for items cached on disk | ||
CacheHitsDisk = prometheus.NewCounterVec( | ||
prometheus.CounterOpts{ | ||
Namespace: ociClientNamespaceName, | ||
Subsystem: cacheSubsystemName, | ||
Name: "disk_hits_total", | ||
Help: "Total number of hits for items cached on disk by an instance.", | ||
}, | ||
[]string{"path"}, | ||
) | ||
|
||
// CacheHitsMemory discloses the number of hits for items cached in memory | ||
CacheHitsMemory = prometheus.NewCounterVec( | ||
prometheus.CounterOpts{ | ||
Namespace: ociClientNamespaceName, | ||
Subsystem: cacheSubsystemName, | ||
Name: "memory_hits_total", | ||
Help: "Total number of hits for items cached in memory by an instance.", | ||
}, | ||
[]string{"path"}, | ||
) | ||
) | ||
|
||
// RegisterCacheMetrics allows to register ociclient cache metrics with a given prometheus registerer | ||
func RegisterCacheMetrics(reg prometheus.Registerer) { | ||
reg.MustRegister(CacheHitsDisk) | ||
reg.MustRegister(CacheHitsMemory) | ||
reg.MustRegister(CachedItems) | ||
reg.MustRegister(CacheDiskUsage) | ||
reg.MustRegister(CacheMemoryUsage) | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.