Skip to content

Commit

Permalink
fixing lint
Browse files Browse the repository at this point in the history
  • Loading branch information
Paramadon committed Dec 4, 2024
1 parent cd78e5e commit aff4bc5
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 19 deletions.
6 changes: 3 additions & 3 deletions extension/agenthealth/handler/stats/agent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const (
)

type Stats struct {
CpuPercent *float64 `json:"cpu,omitempty"`
CPUPercent *float64 `json:"cpu,omitempty"`
MemoryBytes *uint64 `json:"mem,omitempty"`
FileDescriptorCount *int32 `json:"fd,omitempty"`
ThreadCount *int32 `json:"th,omitempty"`
Expand All @@ -36,8 +36,8 @@ type Stats struct {
// Merge the other Stats into the current. If the field is not nil,
// then it'll overwrite the existing one.
func (s *Stats) Merge(other Stats) {
if other.CpuPercent != nil {
s.CpuPercent = other.CpuPercent
if other.CPUPercent != nil {
s.CPUPercent = other.CPUPercent
}
if other.MemoryBytes != nil {
s.MemoryBytes = other.MemoryBytes
Expand Down
22 changes: 11 additions & 11 deletions extension/agenthealth/handler/stats/agent/agent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@ import (
)

func TestMerge(t *testing.T) {
stats := &Stats{CpuPercent: aws.Float64(1.2)}
assert.EqualValues(t, 1.2, *stats.CpuPercent)
stats := &Stats{CPUPercent: aws.Float64(1.2)}
assert.EqualValues(t, 1.2, *stats.CPUPercent)
assert.Nil(t, stats.MemoryBytes)
stats.Merge(Stats{
CpuPercent: aws.Float64(1.3),
CPUPercent: aws.Float64(1.3),
MemoryBytes: aws.Uint64(123),
})
assert.EqualValues(t, 1.3, *stats.CpuPercent)
assert.EqualValues(t, 1.3, *stats.CPUPercent)
assert.EqualValues(t, 123, *stats.MemoryBytes)
stats.Merge(Stats{
CpuPercent: aws.Float64(1.5),
CPUPercent: aws.Float64(1.5),
MemoryBytes: aws.Uint64(133),
FileDescriptorCount: aws.Int32(456),
ThreadCount: aws.Int32(789),
Expand All @@ -36,7 +36,7 @@ func TestMerge(t *testing.T) {
RegionType: aws.String("RegionType"),
Mode: aws.String("Mode"),
})
assert.EqualValues(t, 1.5, *stats.CpuPercent)
assert.EqualValues(t, 1.5, *stats.CPUPercent)
assert.EqualValues(t, 133, *stats.MemoryBytes)
assert.EqualValues(t, 456, *stats.FileDescriptorCount)
assert.EqualValues(t, 789, *stats.ThreadCount)
Expand Down Expand Up @@ -109,15 +109,15 @@ func TestMarshalWithStatusCodes(t *testing.T) {

func TestMergeFullWithStatusCodes(t *testing.T) {
stats := &Stats{
CpuPercent: aws.Float64(1.0),
CPUPercent: aws.Float64(1.0),
StatusCodes: map[string][5]int{"operation1": {1, 0, 0, 0, 0}},
}
stats.Merge(Stats{
CpuPercent: aws.Float64(2.0),
CPUPercent: aws.Float64(2.0),
StatusCodes: map[string][5]int{"operation1": {0, 1, 0, 0, 0}, "operation2": {1, 1, 1, 1, 1}},
})

assert.Equal(t, 2.0, *stats.CpuPercent)
assert.Equal(t, 2.0, *stats.CPUPercent)
assert.Equal(t, [5]int{1, 1, 0, 0, 0}, stats.StatusCodes["operation1"])
assert.Equal(t, [5]int{1, 1, 1, 1, 1}, stats.StatusCodes["operation2"])
}
Expand All @@ -133,7 +133,7 @@ func TestMarshal(t *testing.T) {
},
"WithPartial": {
stats: &Stats{
CpuPercent: aws.Float64(1.2),
CPUPercent: aws.Float64(1.2),
MemoryBytes: aws.Uint64(123),
ThreadCount: aws.Int32(789),
PayloadBytes: aws.Int(5678),
Expand All @@ -142,7 +142,7 @@ func TestMarshal(t *testing.T) {
},
"WithFull": {
stats: &Stats{
CpuPercent: aws.Float64(1.2),
CPUPercent: aws.Float64(1.2),
MemoryBytes: aws.Uint64(123),
FileDescriptorCount: aws.Int32(456),
ThreadCount: aws.Int32(789),
Expand Down
2 changes: 1 addition & 1 deletion extension/agenthealth/handler/stats/handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func TestStatsHandler(t *testing.T) {
zap.NewNop(),
agent.NewOperationsFilter(),
[]agent.StatsProvider{
newMockStatsProvider(&agent.Stats{CpuPercent: aws.Float64(1.2)}),
newMockStatsProvider(&agent.Stats{CPUPercent: aws.Float64(1.2)}),
newMockStatsProvider(&agent.Stats{MemoryBytes: aws.Uint64(123)}),
newMockStatsProvider(stats),
},
Expand Down
2 changes: 1 addition & 1 deletion extension/agenthealth/handler/stats/provider/process.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func (p *processStats) updateLoop() {

func (p *processStats) refresh() {
p.stats.Store(agent.Stats{
CpuPercent: p.cpuPercent(),
CPUPercent: p.cpuPercent(),
MemoryBytes: p.memoryBytes(),
FileDescriptorCount: p.fileDescriptorCount(),
ThreadCount: p.threadCount(),
Expand Down
6 changes: 3 additions & 3 deletions extension/agenthealth/handler/stats/provider/process_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,11 @@ func TestProcessStats(t *testing.T) {
mock := &mockProcessMetrics{}
provider := newProcessStats(mock, time.Millisecond)
got := provider.getStats()
assert.NotNil(t, got.CpuPercent)
assert.NotNil(t, got.CPUPercent)
assert.NotNil(t, got.MemoryBytes)
assert.NotNil(t, got.FileDescriptorCount)
assert.NotNil(t, got.ThreadCount)
assert.EqualValues(t, 1, *got.CpuPercent)
assert.EqualValues(t, 1, *got.CPUPercent)
assert.EqualValues(t, 2, *got.MemoryBytes)
assert.EqualValues(t, 3, *got.FileDescriptorCount)
assert.EqualValues(t, 4, *got.ThreadCount)
Expand All @@ -82,7 +82,7 @@ func TestProcessStats(t *testing.T) {
}

func isAgentStatsReset(stats agent.Stats) bool {
return stats.CpuPercent == nil &&
return stats.CPUPercent == nil &&
stats.MemoryBytes == nil &&
stats.FileDescriptorCount == nil &&
stats.ThreadCount == nil &&
Expand Down

0 comments on commit aff4bc5

Please sign in to comment.