2018-05-30 15:03:44 +01:00
|
|
|
// Copyright (C) 2018 Storj Labs, Inc.
|
|
|
|
// See LICENSE for copying information.
|
|
|
|
|
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"flag"
|
|
|
|
"fmt"
|
|
|
|
|
2018-06-27 09:02:49 +01:00
|
|
|
"github.com/spf13/cobra"
|
|
|
|
|
2018-05-30 15:03:44 +01:00
|
|
|
"storj.io/storj/pkg/process"
|
|
|
|
"storj.io/storj/pkg/telemetry"
|
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
|
|
|
addr = flag.String("addr", ":9000", "address to listen for metrics on")
|
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
process.Must(process.Main(process.ServiceFunc(run)))
|
|
|
|
}
|
|
|
|
|
2018-06-27 09:02:49 +01:00
|
|
|
func run(ctx context.Context, _ *cobra.Command, _ []string) error {
|
2018-05-30 15:03:44 +01:00
|
|
|
s, err := telemetry.Listen(*addr)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
defer s.Close()
|
|
|
|
fmt.Printf("listening on %s\n", s.Addr())
|
|
|
|
return s.Serve(ctx, telemetry.HandlerFunc(handle))
|
|
|
|
}
|
|
|
|
|
|
|
|
func handle(application, instance string, key []byte, val float64) {
|
|
|
|
fmt.Printf("%s %s %s %v\n", application, instance, string(key), val)
|
|
|
|
}
|