From 187c88ad2550560de502af16d2aa9a1e8e46e1f9 Mon Sep 17 00:00:00 2001 From: Paulo Janotti Date: Mon, 22 Jan 2024 09:00:22 -0800 Subject: [PATCH] [chore][pkg/windowsperfcounters] Fix lint on Windows (#30671) **Description:** Fixing lint issues when GOOS=windows. This is in preparation to eventually include lint with GOOS=windows as part of CI. **Link to tracking Issue:** N/A **Testing:** `make` on component folder on a Windows box **Documentation:** N/A Co-authored-by: Daniel Jaglowski --- pkg/winperfcounters/watcher.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pkg/winperfcounters/watcher.go b/pkg/winperfcounters/watcher.go index efac1b3a97865..16b1bfb025766 100644 --- a/pkg/winperfcounters/watcher.go +++ b/pkg/winperfcounters/watcher.go @@ -6,6 +6,7 @@ package winperfcounters // import "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/winperfcounters" import ( + "errors" "fmt" "time" @@ -103,8 +104,8 @@ func (pc *perfCounter) Path() string { func (pc *perfCounter) ScrapeData() ([]CounterValue, error) { if err := pc.query.CollectData(); err != nil { - pdhErr, ok := err.(*win_perf_counters.PdhError) - if !ok || pdhErr.ErrorCode != win_perf_counters.PDH_CALC_NEGATIVE_DENOMINATOR { + var pdhErr *win_perf_counters.PdhError + if !errors.As(err, &pdhErr) || pdhErr.ErrorCode != win_perf_counters.PDH_CALC_NEGATIVE_DENOMINATOR { return nil, fmt.Errorf("failed to collect data for performance counter '%s': %w", pc.path, err) }