Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[receiver/hostmetrics] Have the hostmetrics receiver file system scraper use more debug messages #18895

Merged
merged 1 commit into from
Feb 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions .chloggen/enhance-hostmetrics-filesystem-log-level.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: enhancement

# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver)
component: hostmetrics

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Have the hostmetrics receiver file system scraper use more debug messages

# One or more tracking issues related to the change
issues: [18236]

# (Optional) One or more lines of additional information to render under the primary note.
# These lines will be padded with 2 spaces and then inserted directly into the document.
# Use pipe (|) for multiline entries.
subtext: Log a debug message instead of an error if the collector does not
have the permissions to access a locked drive on the host. We do not want to
log an error message on every poll for this case.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"context"
"fmt"
"path/filepath"
"strings"
"time"

"github.com/shirou/gopsutil/v3/disk"
Expand All @@ -27,6 +28,7 @@ import (
"go.opentelemetry.io/collector/pdata/pmetric"
"go.opentelemetry.io/collector/receiver"
"go.opentelemetry.io/collector/receiver/scrapererror"
"go.uber.org/zap"

"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/hostmetricsreceiver/internal/scraper/filesystemscraper/internal/metadata"
)
Expand Down Expand Up @@ -84,7 +86,15 @@ func (s *scraper) scrape(_ context.Context) (pmetric.Metrics, error) {
if len(partitions) == 0 {
return pmetric.NewMetrics(), scrapererror.NewPartialScrapeError(err, metricsLen)
}
errors.AddPartial(0, fmt.Errorf("failed collecting partitions information: %w", err))
if strings.Contains(strings.ToLower(err.Error()), "locked") {
// Log a debug message instead of an error message if a drive is
// locked and unavailable. For this particular case, we do not want
// to log an error message on every poll.
// See: https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/18236
s.settings.Logger.Debug("failed collecting locked partitions information: %w", zap.Error(err))
} else {
errors.AddPartial(0, fmt.Errorf("failed collecting partitions information: %w", err))
}
}

usages := make([]*deviceUsage, 0, len(partitions))
Expand Down