From aff4bc5de9f2da63d1b17577c1906c990d43af8f Mon Sep 17 00:00:00 2001 From: Paramadon Date: Wed, 4 Dec 2024 03:40:05 -0500 Subject: [PATCH] fixing lint --- .../agenthealth/handler/stats/agent/agent.go | 6 ++--- .../handler/stats/agent/agent_test.go | 22 +++++++++---------- .../agenthealth/handler/stats/handler_test.go | 2 +- .../handler/stats/provider/process.go | 2 +- .../handler/stats/provider/process_test.go | 6 ++--- 5 files changed, 19 insertions(+), 19 deletions(-) diff --git a/extension/agenthealth/handler/stats/agent/agent.go b/extension/agenthealth/handler/stats/agent/agent.go index 5bc84133db..de52ab8ae6 100644 --- a/extension/agenthealth/handler/stats/agent/agent.go +++ b/extension/agenthealth/handler/stats/agent/agent.go @@ -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"` @@ -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 diff --git a/extension/agenthealth/handler/stats/agent/agent_test.go b/extension/agenthealth/handler/stats/agent/agent_test.go index f88ba822eb..b53f8787d8 100644 --- a/extension/agenthealth/handler/stats/agent/agent_test.go +++ b/extension/agenthealth/handler/stats/agent/agent_test.go @@ -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), @@ -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) @@ -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"]) } @@ -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), @@ -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), diff --git a/extension/agenthealth/handler/stats/handler_test.go b/extension/agenthealth/handler/stats/handler_test.go index 108c6aa120..c677524838 100644 --- a/extension/agenthealth/handler/stats/handler_test.go +++ b/extension/agenthealth/handler/stats/handler_test.go @@ -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), }, diff --git a/extension/agenthealth/handler/stats/provider/process.go b/extension/agenthealth/handler/stats/provider/process.go index 4e88ebbee5..e6687c9188 100644 --- a/extension/agenthealth/handler/stats/provider/process.go +++ b/extension/agenthealth/handler/stats/provider/process.go @@ -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(), diff --git a/extension/agenthealth/handler/stats/provider/process_test.go b/extension/agenthealth/handler/stats/provider/process_test.go index 8ab3382271..7a350265eb 100644 --- a/extension/agenthealth/handler/stats/provider/process_test.go +++ b/extension/agenthealth/handler/stats/provider/process_test.go @@ -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) @@ -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 &&