1// Copyright (C) 2019 Storj Labs, Inc. 2// See LICENSE for copying information. 3 4package cmd 5 6import ( 7 "context" 8 9 "github.com/spf13/cobra" 10 11 "storj.io/common/fpath" 12 "storj.io/private/cfgstruct" 13 "storj.io/private/process" 14 "storj.io/uplink/telemetry" 15) 16 17func getConfDir() string { 18 if param := cfgstruct.FindConfigDirParam(); param != "" { 19 return param 20 } 21 return fpath.ApplicationDir("storj", "uplink") 22} 23 24func withTelemetry(cmd *cobra.Command) (context.Context, context.CancelFunc) { 25 ctx, _ := process.Ctx(cmd) 26 addr := cmd.Flag("metrics.addr") 27 if addr == nil || addr.Value.String() == "" { 28 return ctx, nil 29 } 30 31 return telemetry.Enable(ctx) 32} 33 34func enableTracing(config map[string]interface{}) { 35 config["tracing.enabled"] = true 36 config["tracing.sample"] = 1 37} 38