storj/cmd/statreceiver/print.go

30 lines
559 B
Go
Raw Normal View History

2019-01-24 20:15:10 +00:00
// Copyright (C) 2019 Storj Labs, Inc.
// See LICENSE for copying information.
package main
import (
"fmt"
"sync"
"time"
)
// Printer is a MetricDest that writes to stdout
type Printer struct {
2019-01-01 09:41:27 +00:00
mu sync.Mutex
}
// NewPrinter creates a Printer
func NewPrinter() *Printer {
return &Printer{}
}
// Metric implements MetricDest
2019-01-01 09:41:27 +00:00
func (p *Printer) Metric(application, instance string, key []byte, val float64, ts time.Time) error {
p.mu.Lock()
defer p.mu.Unlock()
_, err := fmt.Println(application, instance, string(key), val, ts.Unix())
return err
}