Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/content.en/docs/release-notes/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Information about release notes of INFINI Framework is provided here.
### 🚀 Features
### 🐛 Bug fix
### ✈️ Improvements
- refactor: add EventSink support to overall utilization collector #387

## 1.4.2 (2026-06-23)
### ❌ Breaking changes
Expand Down
11 changes: 10 additions & 1 deletion modules/metrics/host/overall/overall.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ const DefaultBandwidthMbps = 1000
// Metric collects overall system utilization percentages for CPU, memory, disk, disk I/O and network.
// Each disk and network interface is monitored independently to identify specific bottlenecks.
type Metric struct {
event.EventSink

Enabled bool `config:"enabled"`
IntervalSeconds float64 `config:"interval_seconds"`
YellowThreshold float64 `config:"yellow_threshold"`
Expand Down Expand Up @@ -99,6 +101,12 @@ type deviceUtilization struct {
}

func New(cfg *config.Config) (*Metric, error) {
return NewWithSink(cfg, event.DefaultEventSink)
}

// NewWithSink creates a Metric with a custom event sink, allowing callers
// to redirect events to their own sink instead of the global one.
func NewWithSink(cfg *config.Config, sink event.EventSink) (*Metric, error) {
me := &Metric{
Enabled: true,
IntervalSeconds: 10,
Expand All @@ -108,6 +116,7 @@ func New(cfg *config.Config) (*Metric, error) {
prevNetIO: make(map[string]*netIOSnapshot),
netBandwidth: make(map[string]float64),
}
me.EventSink = sink

err := cfg.Unpack(&me)
if err != nil {
Expand Down Expand Up @@ -235,7 +244,7 @@ func (m *Metric) Collect() error {
fields["status"] = status
fields["bottleneck"] = bottleneck

return event.Save(&event.Event{
return m.Save(&event.Event{
Metadata: event.EventMetadata{
Category: "host",
Name: "overall",
Expand Down
Loading