Skip to content

Commit

Permalink
style: add debug logs for volume plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
rahulguptajss committed Oct 25, 2024
1 parent 328b98d commit fb5920e
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions cmd/collectors/rest/plugins/volume/volume.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ import (
const HoursInMonth = 24 * 30
const ARWSupportedVersion = "9.10.0"

var enableVolumeLogging bool

type Volume struct {
*plugin.AbstractPlugin
currentVal int
Expand Down Expand Up @@ -92,6 +94,7 @@ func (v *Volume) Init() error {
if err != nil {
return fmt.Errorf("unable to get version %w", err)
}
enableVolumeLogging = os.Getenv("ENABLE_VOLUME_LOGGING") == "true"
return nil
}

Expand Down Expand Up @@ -133,8 +136,8 @@ func (v *Volume) Run(dataMap map[string]*matrix.Matrix) ([]*matrix.Matrix, *util
func (v *Volume) updateVolumeLabels(data *matrix.Matrix, volumeMap map[string]volumeInfo) {
var err error

if os.Getenv("ENABLE_VOLUME_LOGGING") == "true" {
v.SLogger.Info("Size of volumeMap", slog.Int("size", len(volumeMap)))
if enableVolumeLogging {
v.SLogger.Info("Size of volumeMap", slog.Int("size", len(volumeMap)), slog.Any("volumeMap", volumeMap))
}

cloneSplitEstimateMetric := data.GetMetric("clone_split_estimate")
Expand All @@ -150,7 +153,7 @@ func (v *Volume) updateVolumeLabels(data *matrix.Matrix, volumeMap map[string]vo
}

if volume.GetLabel("style") == "flexgroup_constituent" {
if os.Getenv("ENABLE_VOLUME_LOGGING") == "true" {
if enableVolumeLogging {
v.SLogger.Warn("Setting exportable for flexgroup constituent", slog.String("volume", volume.GetLabel("volume")), slog.Bool("exportable", v.includeConstituents))
}
volume.SetExportable(v.includeConstituents)
Expand Down Expand Up @@ -180,7 +183,7 @@ func (v *Volume) updateVolumeLabels(data *matrix.Matrix, volumeMap map[string]vo
}
} else {
// The public API does not include node root and temp volumes, while the private CLI does include them. Harvest will exclude them the same as the public API by not exporting them.
if os.Getenv("ENABLE_VOLUME_LOGGING") == "true" {
if enableVolumeLogging {
v.SLogger.Warn("Setting exportable for excluded volume", slog.String("volume", volume.GetLabel("volume")), slog.Bool("exportable", false))
}
volume.SetExportable(false)
Expand Down

0 comments on commit fb5920e

Please sign in to comment.