Step I: move memstats to metrics (#1799)

step II: update deps (serving and eventing)
step: III: remove from shared main

For https://github.com/knative/serving/issues/9787
This commit is contained in:
Victor Agababov 2020-10-12 15:14:17 -07:00 committed by GitHub
parent 54ad6c6d39
commit e3b4e9c229
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 7 deletions

View File

@ -24,7 +24,6 @@ import (
"os"
"time"
"go.opencensus.io/stats/view"
_ "go.uber.org/automaxprocs" // automatically set GOMAXPROCS based on cgroups
"go.uber.org/zap"
"golang.org/x/sync/errgroup"
@ -257,12 +256,7 @@ func ParseAndGetConfigOrDie() *rest.Config {
// MemStatsOrDie sets up reporting on Go memory usage every 30 seconds or dies
// by calling log.Fatalf.
func MemStatsOrDie(ctx context.Context) {
msp := metrics.NewMemStatsAll()
msp.Start(ctx, 30*time.Second)
if err := view.Register(msp.DefaultViews()...); err != nil {
log.Fatal("Error exporting go memstats view: ", err)
}
metrics.MemStatsOrDie(ctx)
}
// SetupLoggerOrDie sets up the logger using the config from the given context

View File

@ -18,6 +18,7 @@ package metrics
import (
"context"
"log"
"runtime"
"time"
@ -167,6 +168,17 @@ func NewMemStatsAll() *MemStatsProvider {
}
}
// MemStatsOrDie sets up reporting on Go memory usage every 30 seconds or dies
// by calling log.Fatalf.
func MemStatsOrDie(ctx context.Context) {
msp := NewMemStatsAll()
msp.Start(ctx, 30*time.Second)
if err := view.Register(msp.DefaultViews()...); err != nil {
log.Fatal("Error exporting go memstats view: ", err)
}
}
// MemStatsProvider is used to expose metrics based on Go's runtime.MemStats.
// The fields below (and their comments) are a filtered list taken from
// Go's runtime.MemStats.