diff --git a/cmd/collectors/rest/plugins/volume/volume.go b/cmd/collectors/rest/plugins/volume/volume.go index 22a69c57e..e3965f1fd 100644 --- a/cmd/collectors/rest/plugins/volume/volume.go +++ b/cmd/collectors/rest/plugins/volume/volume.go @@ -25,6 +25,8 @@ import ( const HoursInMonth = 24 * 30 const ARWSupportedVersion = "9.10.0" +var enableVolumeLogging bool + type Volume struct { *plugin.AbstractPlugin currentVal int @@ -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 } @@ -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") @@ -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) @@ -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)