github.com/keybase/client/go@v0.0.0-20240309051027-028f7c731f8b/kbfs/libfs/metrics_file.go (about) 1 // Copyright 2015-2016 Keybase Inc. All rights reserved. 2 // Use of this source code is governed by a BSD 3 // license that can be found in the LICENSE file. 4 5 package libfs 6 7 import ( 8 "bytes" 9 "time" 10 11 "github.com/keybase/client/go/kbfs/libkbfs" 12 "github.com/keybase/client/go/kbfs/metricsutil" 13 "golang.org/x/net/context" 14 ) 15 16 // GetEncodedMetrics returns metrics encoded as bytes for metrics file. 17 func GetEncodedMetrics(config libkbfs.Config) func(context.Context) ([]byte, time.Time, error) { 18 return func(context.Context) ([]byte, time.Time, error) { 19 if registry := config.MetricsRegistry(); registry != nil { 20 b := bytes.NewBuffer(nil) 21 metricsutil.WriteMetrics(registry, b) 22 return b.Bytes(), time.Time{}, nil 23 } 24 return []byte("Metrics have been turned off.\n"), time.Time{}, nil 25 } 26 }