storj/cmd/statreceiver/print.go
2019-01-01 11:41:27 +02:00

30 lines
559 B
Go

// Copyright (C) 2018 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 {
mu sync.Mutex
}
// NewPrinter creates a Printer
func NewPrinter() *Printer {
return &Printer{}
}
// Metric implements MetricDest
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
}