88type health struct {
99}
1010
11- func NewHealth () * health {
11+ func newHealth () * health {
1212 return & health {}
1313}
1414
@@ -18,48 +18,50 @@ func (h *health) Name() string {
1818}
1919
2020// LiveProbe implements HealthProvider.
21- func (h * health ) LiveProbe (ctx context.Context ) (Checks , error ) {
22- const oneGiB uint64 = 1 << 30
21+ func (h * health ) LiveProbe (_ context.Context ) (Checks , error ) {
22+ const oneMiB uint64 = 1 << 20
23+ const memoryThreshold uint64 = 128 * oneMiB
24+ const goroutineThreshold = 100
2325
2426 var m runtime.MemStats
2527 runtime .ReadMemStats (& m )
2628
2729 // Basic runtime health checks
2830 goroutineCheck := CheckDetail {
2931 Description : "Number of goroutines" ,
30- ObservedValue : int ( runtime .NumGoroutine () ),
32+ ObservedValue : runtime .NumGoroutine (),
3133 ObservedUnit : "goroutines" ,
3234 Status : StatusPass ,
3335 }
3436
3537 memoryCheck := CheckDetail {
3638 Description : "Memory usage" ,
37- ObservedValue : int (m .Alloc / 1024 / 1024 ), // MiB
39+ ObservedValue : int (m .Alloc / oneMiB ), //nolint:gosec // not a security issue
3840 ObservedUnit : "MiB" ,
3941 Status : StatusPass ,
4042 }
4143
4244 // Check for potential memory issues
43- if m .Alloc > oneGiB { // 1GB
45+ if m .Alloc > memoryThreshold {
4446 memoryCheck .Status = StatusWarn
4547 }
4648
4749 // Check for excessive goroutines
48- if goroutineCheck .ObservedValue > 1000 {
50+ if goroutineCheck .ObservedValue > goroutineThreshold {
4951 goroutineCheck .Status = StatusWarn
5052 }
5153
5254 return Checks {"goroutines" : goroutineCheck , "memory" : memoryCheck }, nil
5355}
5456
5557// ReadyProbe implements HealthProvider.
56- func (h * health ) ReadyProbe (ctx context.Context ) (Checks , error ) {
57- return nil , nil
58+ func (h * health ) ReadyProbe (_ context.Context ) (Checks , error ) {
59+ return nil , nil //nolint:nilnil // empty result
5860}
5961
6062// StartedProbe implements HealthProvider.
61- func (h * health ) StartedProbe (ctx context.Context ) (Checks , error ) {
62- return nil , nil
63+ func (h * health ) StartedProbe (_ context.Context ) (Checks , error ) {
64+ return nil , nil //nolint:nilnil // empty result
6365}
6466
65- var _ HealthProvider = (* health )(nil )
67+ var _ Provider = (* health )(nil )
0 commit comments