pkg/process: reduce noise in storj-sim (#2988)

* Don't display stack for failure to start debug endpoints
* Don't display stack for disabled telemetry
This commit is contained in:
Egon Elbre 2019-09-10 10:32:53 +03:00 committed by GitHub
parent 40ca660c06
commit e03e6844f8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 4 deletions

View File

@ -5,6 +5,7 @@ package process
import (
"context"
"errors"
"flag"
"fmt"
"log"
@ -245,7 +246,8 @@ func cleanup(cmd *cobra.Command) {
err = initDebug(logger, monkit.Default)
if err != nil {
logger.Error("failed to start debug endpoints", zap.Error(err))
withoutStack := errors.New(err.Error())
logger.Debug("failed to start debug endpoints", zap.Error(withoutStack))
}
var workErr error

View File

@ -43,8 +43,10 @@ func flagDefault(dev, release string) string {
// InitMetrics initializes telemetry reporting. Makes a telemetry.Client and calls
// its Run() method in a goroutine.
func InitMetrics(ctx context.Context, log *zap.Logger, r *monkit.Registry, instanceID string) (err error) {
log = log.Named("telemetry")
if *metricCollector == "" || *metricInterval == 0 {
return Error.New("telemetry disabled")
log.Info("disabled")
return nil
}
if r == nil {
r = monkit.Default

View File

@ -105,7 +105,7 @@ func NewClient(log *zap.Logger, remoteAddr string, opts ClientOpts) (rv *Client,
// Run calls Report roughly every Interval
func (c *Client) Run(ctx context.Context) {
c.log.Sugar().Debugf("Initialized telemetry batcher with id = %q", c.opts.InstanceId)
c.log.Sugar().Debugf("Initialized batcher with id = %q", c.opts.InstanceId)
for {
time.Sleep(jitter(c.interval))
if ctx.Err() != nil {
@ -114,7 +114,7 @@ func (c *Client) Run(ctx context.Context) {
err := c.Report(ctx)
if err != nil {
c.log.Sugar().Errorf("failed sending telemetry report: %v", err)
c.log.Sugar().Errorf("failed sending report: %v", err)
}
}
}