Add helper functions for Block volume Capacity detection

Similar to how NewMetricsStatFS() works, the new NewMetricsBlock()
provides the GetMetrics() interface for Block volumes.

Additional metrics for Block volumes are difficult to gather. There is
no guarantee that there is a filesystem on the volume, which makes most
of the volume metrics useless.

Advanced storage might be able to detect the actual consumption (when
thin-provisioned) vs the capacity. However, this is out of the scope for
a standard helper function and requires intimate knowledge of the used
storage system.
This commit is contained in:
Niels de Vos
2021-04-28 16:31:53 +02:00
parent 29e4fdab4d
commit 2b9c81b87d
3 changed files with 193 additions and 0 deletions

View File

@@ -35,6 +35,14 @@ func NewNotSupportedError() *MetricsError {
}
}
// NewNotImplementedError creates a new MetricsError with code NotSupported.
func NewNotImplementedError(reason string) *MetricsError {
return &MetricsError{
Code: ErrCodeNotSupported,
Msg: fmt.Sprintf("metrics support is not implemented: %s", reason),
}
}
// NewNotSupportedErrorWithDriverName creates a new MetricsError with code NotSupported.
// driver name is added to the error message.
func NewNotSupportedErrorWithDriverName(name string) *MetricsError {