Skip to content

Commit cf8a0d0

Browse files
authored
[chore] Remove unused methods from processHandle (#39039)
Remove unused methods from the `processHandle` interface.
1 parent 8e54ec1 commit cf8a0d0

File tree

2 files changed

+0
-18
lines changed

2 files changed

+0
-18
lines changed

receiver/hostmetricsreceiver/internal/scraper/processscraper/process.go

-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import (
1010
"runtime"
1111
"strconv"
1212
"strings"
13-
"time"
1413

1514
"github.com/shirou/gopsutil/v4/common"
1615
"github.com/shirou/gopsutil/v4/cpu"
@@ -84,13 +83,11 @@ type processHandle interface {
8483
CmdlineWithContext(context.Context) (string, error)
8584
CmdlineSliceWithContext(context.Context) ([]string, error)
8685
TimesWithContext(context.Context) (*cpu.TimesStat, error)
87-
PercentWithContext(context.Context, time.Duration) (float64, error)
8886
MemoryInfoWithContext(context.Context) (*process.MemoryInfoStat, error)
8987
MemoryPercentWithContext(context.Context) (float32, error)
9088
IOCountersWithContext(context.Context) (*process.IOCountersStat, error)
9189
NumThreadsWithContext(context.Context) (int32, error)
9290
CreateTimeWithContext(context.Context) (int64, error)
93-
ParentWithContext(context.Context) (*process.Process, error)
9491
PpidWithContext(context.Context) (int32, error)
9592
PageFaultsWithContext(context.Context) (*process.PageFaultsStat, error)
9693
NumCtxSwitchesWithContext(context.Context) (*process.NumCtxSwitchesStat, error)

receiver/hostmetricsreceiver/internal/scraper/processscraper/process_scraper_test.go

-15
Original file line numberDiff line numberDiff line change
@@ -470,11 +470,6 @@ func (p *processHandleMock) TimesWithContext(ctx context.Context) (*cpu.TimesSta
470470
return args.Get(0).(*cpu.TimesStat), args.Error(1)
471471
}
472472

473-
func (p *processHandleMock) PercentWithContext(ctx context.Context, d time.Duration) (float64, error) {
474-
args := p.MethodCalled("PercentWithContext", ctx, d)
475-
return args.Get(0).(float64), args.Error(1)
476-
}
477-
478473
func (p *processHandleMock) MemoryInfoWithContext(ctx context.Context) (*process.MemoryInfoStat, error) {
479474
args := p.MethodCalled("MemoryInfoWithContext", ctx)
480475
return args.Get(0).(*process.MemoryInfoStat), args.Error(1)
@@ -500,11 +495,6 @@ func (p *processHandleMock) CreateTimeWithContext(ctx context.Context) (int64, e
500495
return args.Get(0).(int64), args.Error(1)
501496
}
502497

503-
func (p *processHandleMock) ParentWithContext(ctx context.Context) (*process.Process, error) {
504-
args := p.MethodCalled("ParentWithContext", ctx)
505-
return args.Get(0).(*process.Process), args.Error(1)
506-
}
507-
508498
func (p *processHandleMock) PpidWithContext(ctx context.Context) (int32, error) {
509499
args := p.MethodCalled("PpidWithContext", ctx)
510500
return args.Get(0).(int32), args.Error(1)
@@ -551,9 +541,6 @@ func initDefaultsHandleMock(t mock.TestingT, handleMock *processHandleMock) {
551541
if !handleMock.IsMethodCallable(t, "TimesWithContext", mock.Anything) {
552542
handleMock.On("TimesWithContext", mock.Anything).Return(&cpu.TimesStat{}, nil)
553543
}
554-
if !handleMock.IsMethodCallable(t, "PercentWithContext", mock.Anything, mock.Anything) {
555-
handleMock.On("PercentWithContext", mock.Anything, mock.Anything).Return(float64(0), nil)
556-
}
557544
if !handleMock.IsMethodCallable(t, "MemoryInfoWithContext", mock.Anything) {
558545
handleMock.On("MemoryInfoWithContext", mock.Anything).Return(&process.MemoryInfoStat{}, nil)
559546
}
@@ -949,7 +936,6 @@ func TestScrapeMetrics_ProcessErrors(t *testing.T) {
949936
handleMock.On("CmdlineWithContext", mock.Anything).Return("cmdline", test.cmdlineError)
950937
handleMock.On("CmdlineSliceWithContext", mock.Anything).Return([]string{"cmdline"}, test.cmdlineError)
951938
handleMock.On("TimesWithContext", mock.Anything).Return(&cpu.TimesStat{}, test.timesError)
952-
handleMock.On("PercentWithContext", mock.Anything).Return(float64(0), nil)
953939
handleMock.On("MemoryInfoWithContext", mock.Anything).Return(&process.MemoryInfoStat{}, test.memoryInfoError)
954940
handleMock.On("MemoryPercentWithContext", mock.Anything).Return(float32(0), test.memoryPercentError)
955941
handleMock.On("IOCountersWithContext", mock.Anything).Return(&process.IOCountersStat{}, test.ioCountersError)
@@ -1263,7 +1249,6 @@ func newErroringHandleMock() *processHandleMock {
12631249
handleMock.On("CmdlineWithContext", mock.Anything).Return("cmdline", nil)
12641250
handleMock.On("CmdlineSliceWithContext", mock.Anything).Return([]string{"cmdline"}, nil)
12651251
handleMock.On("TimesWithContext", mock.Anything).Return(&cpu.TimesStat{}, &ProcessReadError{})
1266-
handleMock.On("PercentWithContext", mock.Anything).Return(float64(0), nil)
12671252
handleMock.On("MemoryInfoWithContext", mock.Anything).Return(&process.MemoryInfoStat{}, &ProcessReadError{})
12681253
handleMock.On("IOCountersWithContext", mock.Anything).Return(&process.IOCountersStat{}, &ProcessReadError{})
12691254
handleMock.On("NumThreadsWithContext", mock.Anything).Return(int32(0), &ProcessReadError{})

0 commit comments

Comments
 (0)