cmd/segment-reaper: add metrics for zombie segments count

Change-Id: I106c6795946283165ba3de8465e5898346da1a3f
This commit is contained in:
Cameron Ayer 2020-08-19 10:59:20 -04:00 committed by Cameron Ayer
parent dbb53151f0
commit 3e343b683b
5 changed files with 16 additions and 2 deletions

View File

@ -44,6 +44,11 @@ func cmdDetect(cmd *cobra.Command, args []string) (err error) {
ctx, _ := process.Ctx(cmd)
log := zap.L()
if err := process.InitMetricsWithHostname(ctx, log, nil); err != nil {
log.Warn("Failed to initialize telemetry batcher on segment reaper", zap.Error(err))
}
db, err := metainfo.NewStore(log.Named("pointerdb"), detectCfg.DatabaseURL)
if err != nil {
return errs.New("error connecting database: %+v", err)
@ -97,5 +102,8 @@ func cmdDetect(cmd *cobra.Command, args []string) (err error) {
log.Info("number of last inline segments", zap.Int("segments", observer.lastInlineSegments))
log.Info("number of remote segments", zap.Int("segments", observer.remoteSegments))
log.Info("number of zombie segments", zap.Int("segments", observer.zombieSegments))
return nil
mon.IntVal("zombie_segments").Observe(int64(observer.zombieSegments)) //locked
return process.Report(ctx)
}

View File

@ -4,6 +4,7 @@
package main
import (
"github.com/spacemonkeygo/monkit/v3"
"github.com/spf13/cobra"
"storj.io/private/process"
@ -11,6 +12,8 @@ import (
)
var (
mon = monkit.Package()
rootCmd = &cobra.Command{
Use: "segment-reaper",
Short: "A tool for detecting and deleting zombie segments",

2
go.mod
View File

@ -45,6 +45,6 @@ require (
storj.io/common v0.0.0-20200818131620-f9cddf66b4be
storj.io/drpc v0.0.14
storj.io/monkit-jaeger v0.0.0-20200518165323-80778fc3f91b
storj.io/private v0.0.0-20200729145012-46794d335b51
storj.io/private v0.0.0-20200818170340-c2963305092f
storj.io/uplink v1.2.0
)

2
go.sum
View File

@ -736,5 +736,7 @@ storj.io/monkit-jaeger v0.0.0-20200518165323-80778fc3f91b h1:Bbg9JCtY6l3HrDxs3BX
storj.io/monkit-jaeger v0.0.0-20200518165323-80778fc3f91b/go.mod h1:gj4vuCeyCRjRmH8LIrgoyU9Dc9uR6H+/GcDUXmTbf80=
storj.io/private v0.0.0-20200729145012-46794d335b51 h1:wX/vLW1gzp/+sNXxt1fwJ9z3ZNpabQSBnY5IZXhtkhc=
storj.io/private v0.0.0-20200729145012-46794d335b51/go.mod h1:3BB0H9SmnJDfgk55uZli6DLHmhLiOdKiDY58ZI2e+pk=
storj.io/private v0.0.0-20200818170340-c2963305092f h1:1EC5IuctBVgxs3SQI2N2f6u5QdwTaX8IM9QAkFKGbMQ=
storj.io/private v0.0.0-20200818170340-c2963305092f/go.mod h1:3BB0H9SmnJDfgk55uZli6DLHmhLiOdKiDY58ZI2e+pk=
storj.io/uplink v1.2.0 h1:7gGfkTv7zT9ivSCMqu7QirUMdHVaeBnlZgqgWhRKEd4=
storj.io/uplink v1.2.0/go.mod h1:U7VFTdoZiBgmijKdvB5dUfi6V5Ew9PAHhUVyy8rJWBs=

View File

@ -1,3 +1,4 @@
storj.io/storj/cmd/segment-reaper."zombie_segments" IntVal
storj.io/storj/satellite/accounting/tally."total.bytes" IntVal
storj.io/storj/satellite/accounting/tally."total.inline_bytes" IntVal
storj.io/storj/satellite/accounting/tally."total.inline_segments" IntVal