pkg/process/metrics: add an instance prefix (#2190)
* pkg/process/metrics: add an instance prefix the distinction between which satellite is sending which data should go in the instance field, not the suffix or application fields. (un)fortunately, the instance id is deliberately not configurable because we don't want it to be easy to accidentally have multiple applications collide with the same instance id. so we're currently stuffing the human readable instance in the suffix. :( perhaps a reasonable tradeoff would be an optional instance prefix that allows operators to put their domain name in the instance Change-Id: I6fcc8498be908c5740439cc00f77474ad151febd * linting Change-Id: I9f9a44fa9a2634ef5e4f89548d42d57ce9e4450e
This commit is contained in:
parent
b3da72c21c
commit
8c57434ded
@ -22,12 +22,24 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
metricInterval = flag.Duration("metrics.interval", telemetry.DefaultInterval, "how frequently to send up telemetry")
|
||||
metricCollector = flag.String("metrics.addr", "collectora.storj.io:9000", "address to send telemetry to")
|
||||
metricApp = flag.String("metrics.app", filepath.Base(os.Args[0]), "application name for telemetry identification")
|
||||
metricAppSuffix = flag.String("metrics.app-suffix", "-"+cfgstruct.DefaultsType(), "application suffix")
|
||||
metricInterval = flag.Duration("metrics.interval", telemetry.DefaultInterval, "how frequently to send up telemetry")
|
||||
metricCollector = flag.String("metrics.addr", flagDefault("", "collectora.storj.io:9000"), "address to send telemetry to")
|
||||
metricApp = flag.String("metrics.app", filepath.Base(os.Args[0]), "application name for telemetry identification")
|
||||
metricAppSuffix = flag.String("metrics.app-suffix", flagDefault("-dev", "-release"), "application suffix")
|
||||
metricInstancePrefix = flag.String("metrics.instance-prefix", "", "instance id prefix")
|
||||
)
|
||||
|
||||
const (
|
||||
maxInstanceLength = 52
|
||||
)
|
||||
|
||||
func flagDefault(dev, release string) string {
|
||||
if cfgstruct.DefaultsType() == "release" {
|
||||
return release
|
||||
}
|
||||
return dev
|
||||
}
|
||||
|
||||
// InitMetrics initializes telemetry reporting. Makes a telemetry.Client and calls
|
||||
// its Run() method in a goroutine.
|
||||
func InitMetrics(ctx context.Context, r *monkit.Registry, instanceID string) (err error) {
|
||||
@ -40,6 +52,10 @@ func InitMetrics(ctx context.Context, r *monkit.Registry, instanceID string) (er
|
||||
if instanceID == "" {
|
||||
instanceID = telemetry.DefaultInstanceID()
|
||||
}
|
||||
instanceID = *metricInstancePrefix + instanceID
|
||||
if len(instanceID) > maxInstanceLength {
|
||||
instanceID = instanceID[:maxInstanceLength]
|
||||
}
|
||||
c, err := telemetry.NewClient(*metricCollector, telemetry.ClientOpts{
|
||||
Interval: *metricInterval,
|
||||
Application: *metricApp + *metricAppSuffix,
|
||||
|
3
scripts/testdata/satellite-config.yaml.lock
vendored
3
scripts/testdata/satellite-config.yaml.lock
vendored
@ -208,6 +208,9 @@ kademlia.operator.wallet: ""
|
||||
# application suffix
|
||||
# metrics.app-suffix: "-release"
|
||||
|
||||
# instance id prefix
|
||||
# metrics.instance-prefix: ""
|
||||
|
||||
# how frequently to send up telemetry
|
||||
# metrics.interval: 1m0s
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user