internal/event: fix the agent start time

The current use of start time in the cache key prevents re-use of agents under
some circumstances, so we update it later in the exporter instead.

Change-Id: I2f6927d65a0841f77a0ee1b848b5a3b243936083
Reviewed-on: https://go-review.googlesource.com/c/tools/+/231257
Run-TryBot: Ian Cottrell <iancottrell@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
Ian Cottrell 2020-04-30 17:03:22 -04:00
parent f26c0dd982
commit d351ea090f
1 changed files with 3 additions and 3 deletions

View File

@ -66,9 +66,6 @@ func Connect(config *Config) *Exporter {
return nil
}
resolved := *config
if resolved.Start.IsZero() {
resolved.Start = time.Now()
}
if resolved.Host == "" {
hostname, _ := os.Hostname()
resolved.Host = hostname
@ -93,6 +90,9 @@ func Connect(config *Config) *Exporter {
}
exporter := &Exporter{config: resolved}
exporters[resolved] = exporter
if exporter.config.Start.IsZero() {
exporter.config.Start = time.Now()
}
go func() {
for range time.Tick(exporter.config.Rate) {
exporter.Flush()