Skip to content

Commit

Permalink
periodically dump event metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
yb01 committed Jul 13, 2022
1 parent 23ea196 commit e0e95d1
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
19 changes: 16 additions & 3 deletions resource-management/cmds/service-api/app/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"time"

"global-resource-service/resource-management/pkg/aggregrator"
"global-resource-service/resource-management/pkg/common-lib/types/event"
"global-resource-service/resource-management/pkg/distributor"
"global-resource-service/resource-management/pkg/service-api/endpoints"
"global-resource-service/resource-management/pkg/store/redis"
Expand All @@ -16,9 +17,10 @@ import (
)

type Config struct {
ResourceUrls []string
MasterIp string
MasterPort string
ResourceUrls []string
MasterIp string
MasterPort string
EventMetricsDumpFrequency time.Duration
}

// Run and create new service-api. This should never exit.
Expand Down Expand Up @@ -77,6 +79,17 @@ func Run(c *Config) error {
return err
}

// start the event metrics report
klog.V(3).Infof("Starting the event metrics reporting routine...")
wg.Add(1)
go func() {
defer wg.Done()
for {
time.Sleep(c.EventMetricsDumpFrequency)
event.PrintLatencyReport()
}
}()

wg.Wait()
return nil
}
3 changes: 2 additions & 1 deletion resource-management/cmds/service-api/service-api.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ func main() {
flag.StringVar(&c.MasterIp, "master_ip", "localhost", "Service IP address, if not set, default to localhost")
flag.StringVar(&c.MasterPort, "master_port", "8080", "Service port, if not set, default to 8080")
flag.StringVar(&urls, "resource_urls", "", "Resource urls of the resource manager services in each region")

flag.DurationVar(&c.EventMetricsDumpFrequency, "metrics_dump_frequency", 5*time.Minute, "Frequency to dump the event metrics, default 5m")

if !flag.Parsed() {
klog.InitFlags(nil)
flag.Parse()
Expand Down

0 comments on commit e0e95d1

Please sign in to comment.