Skip to content

Commit

Permalink
[chore][receiver/iis] Fix lint on Windows issues (open-telemetry#29793)
Browse files Browse the repository at this point in the history
**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
  • Loading branch information
pjanotti authored Dec 12, 2023
1 parent 9d4966f commit d42a270
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
6 changes: 3 additions & 3 deletions receiver/iisreceiver/scraper.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func newIisReceiver(settings receiver.CreateSettings, cfg *Config, consumer cons
}

// start builds the paths to the watchers
func (rcvr *iisReceiver) start(ctx context.Context, host component.Host) error {
func (rcvr *iisReceiver) start(_ context.Context, _ component.Host) error {
errs := &scrapererror.ScrapeErrors{}

rcvr.totalWatcherRecorders = rcvr.buildWatcherRecorders(totalPerfCounterRecorders, errs)
Expand All @@ -82,7 +82,7 @@ func (rcvr *iisReceiver) start(ctx context.Context, host component.Host) error {
}

// scrape pulls counter values from the watchers
func (rcvr *iisReceiver) scrape(ctx context.Context) (pmetric.Metrics, error) {
func (rcvr *iisReceiver) scrape(_ context.Context) (pmetric.Metrics, error) {
var errs error
now := pcommon.NewTimestampFromTime(time.Now())

Expand Down Expand Up @@ -197,7 +197,7 @@ func (rcvr *iisReceiver) emitInstanceMap(now pcommon.Timestamp, instanceToRecord
}

// shutdown closes the watchers
func (rcvr iisReceiver) shutdown(ctx context.Context) error {
func (rcvr iisReceiver) shutdown(_ context.Context) error {
var errs error
errs = multierr.Append(errs, closeWatcherRecorders(rcvr.totalWatcherRecorders))
errs = multierr.Append(errs, closeWatcherRecorders(rcvr.siteWatcherRecorders))
Expand Down
18 changes: 10 additions & 8 deletions receiver/iisreceiver/scraper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func TestScrape(t *testing.T) {
cfg,
consumertest.NewNop(),
)
scraper.newWatcher = newMockWatcherFactory(nil, 1)
scraper.newWatcher = newMockWatcherFactory(nil)
scraper.newWatcherFromPath = newMockWatcherFactorFromPath(nil, 1)
scraper.expandWildcardPath = func(s string) ([]string, error) {
return []string{strings.Replace(s, "*", "Instance", 1)}, nil
Expand Down Expand Up @@ -72,7 +72,7 @@ func TestScrapeFailure(t *testing.T) {
)

expectedError := "failure to collect metric"
mockWatcher, err := newMockWatcherFactory(fmt.Errorf(expectedError), 1)("", "", "")
mockWatcher, err := newMockWatcherFactory(fmt.Errorf(expectedError))("", "", "")
require.NoError(t, err)
scraper.totalWatcherRecorders = []watcherRecorder{
{
Expand All @@ -83,7 +83,8 @@ func TestScrapeFailure(t *testing.T) {
},
}

scraper.scrape(context.Background())
_, err = scraper.scrape(context.Background())
require.NoError(t, err)

require.Equal(t, 1, obs.Len())
log := obs.All()[0]
Expand All @@ -107,7 +108,7 @@ func TestMaxQueueItemAgeScrapeFailure(t *testing.T) {
)

expectedError := "failure to collect metric"
mockWatcher, err := newMockWatcherFactory(fmt.Errorf(expectedError), 1)("", "", "")
mockWatcher, err := newMockWatcherFactory(fmt.Errorf(expectedError))("", "", "")
require.NoError(t, err)
scraper.queueMaxAgeWatchers = []instanceWatcher{
{
Expand All @@ -116,7 +117,8 @@ func TestMaxQueueItemAgeScrapeFailure(t *testing.T) {
},
}

scraper.scrape(context.Background())
_, err = scraper.scrape(context.Background())
require.NoError(t, err)

require.Equal(t, 1, obs.Len())
log := obs.All()[0]
Expand All @@ -136,7 +138,7 @@ func TestMaxQueueItemAgeNegativeDenominatorScrapeFailure(t *testing.T) {
)

expectedError := "Failed to scrape counter \"counter\": A counter with a negative denominator value was detected.\r\n"
mockWatcher, err := newMockWatcherFactory(fmt.Errorf(expectedError), 1)("", "", "")
mockWatcher, err := newMockWatcherFactory(fmt.Errorf(expectedError))("", "", "")
require.NoError(t, err)
scraper.queueMaxAgeWatchers = []instanceWatcher{
{
Expand All @@ -162,10 +164,10 @@ type mockPerfCounter struct {
value float64
}

func newMockWatcherFactory(watchErr error, value float64) func(string, string,
func newMockWatcherFactory(watchErr error) func(string, string,
string) (winperfcounters.PerfCounterWatcher, error) {
return func(string, string, string) (winperfcounters.PerfCounterWatcher, error) {
return &mockPerfCounter{watchErr: watchErr, value: value}, nil
return &mockPerfCounter{watchErr: watchErr, value: 1}, nil
}
}

Expand Down

0 comments on commit d42a270

Please sign in to comment.