You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When collecting metrics for Prometheus, I found using previously declared Gauge/etc. was not convenient.
The following code snippet shows how I reuse the Gauge/etc. in Go:
typeCollectorstruct {
sync.MutexusedMemory*prometheus.GaugeVec
}
func (c*Collector) Collect(chchan<- prometheus.Metric) {
// Only one Collect call in progress at a time.c.Lock()
deferc.Unlock()
c.usedMemory.Reset()
...fori:=0; i<int(numDevices); i++ {
c.usedMemory.WithLabelValues(index, uuid, name, sn, slot).Set(float64(mem.Used))
}
...
}
I can reuse usedMemory for multiple devices and update the labels (similar to dimensions). But dimensions is a public let in Gauge/etc., I can't mutate its values.
Actual behavior
dimensions is a public let in Gauge/etc., I can't mutate its values after init.
Steps to reproduce
N/A
If possible, minimal yet complete reproducer code (or URL to code)
N/A
SwiftMetrics version/commit hash
2.4.1
Swift & OS version (output of swift --version && uname -a)
~ swift --version
swift-driver version: 1.62.15 Apple Swift version 5.7.1 (swiftlang-5.7.1.135.3 clang-1400.0.29.51)
Target: arm64-apple-macosx13.0
~ uname -a
Darwin bogon 22.6.0 Darwin Kernel Version 22.6.0: Sun Dec 17 22:14:44 PST 2023; root:xnu-8796.141.3.703.2~2/RELEASE_ARM64_T8103 arm64
The text was updated successfully, but these errors were encountered:
Expected behavior
When collecting metrics for Prometheus, I found using previously declared Gauge/etc. was not convenient.
The following code snippet shows how I reuse the Gauge/etc. in Go:
I can reuse
usedMemory
for multiple devices and update the labels (similar todimensions
). Butdimensions
is apublic let
in Gauge/etc., I can't mutate its values.Actual behavior
dimensions
is apublic let
in Gauge/etc., I can't mutate its values after init.Steps to reproduce
N/A
If possible, minimal yet complete reproducer code (or URL to code)
N/A
SwiftMetrics version/commit hash
2.4.1
Swift & OS version (output of
swift --version && uname -a
)The text was updated successfully, but these errors were encountered: