From 1f98b02062d9f11dfeffc8f649ae523551c09f91 Mon Sep 17 00:00:00 2001 From: colmsnowplow Date: Mon, 4 Nov 2024 14:08:10 +0000 Subject: [PATCH] Ensure all timestamps used in reporting are UTC --- cmd/cli/cli.go | 6 +++--- pkg/observer/observer.go | 6 +++--- pkg/source/kinesis/kinesis_source_test.go | 2 +- pkg/target/http.go | 4 ++-- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/cmd/cli/cli.go b/cmd/cli/cli.go index 6a3d121e..152c7aa3 100644 --- a/cmd/cli/cli.go +++ b/cmd/cli/cli.go @@ -57,7 +57,7 @@ func RunCli(supportedSources []config.ConfigurationPair, supportedTransformation app.Usage = appUsage app.Version = appVersion app.Copyright = appCopyright - app.Compiled = time.Now() + app.Compiled = time.Now().UTC() app.Authors = []cli.Author{ { Name: "Joshua Beemster", @@ -299,7 +299,7 @@ func handleWrite(cfg *config.Config, write func() error) error { write, retryOnlySetupErrors, onSetupError, - retry.Delay(time.Duration(cfg.Data.Retry.Setup.Delay) * time.Millisecond), + retry.Delay(time.Duration(cfg.Data.Retry.Setup.Delay)*time.Millisecond), // for now let's limit attempts to 5 for setup errors, because we don't have health check which would allow app to be killed externally. Unlimited attempts don't make sense right now. retry.Attempts(5), retry.LastErrorOnly(true), @@ -325,7 +325,7 @@ func handleWrite(cfg *config.Config, write func() error) error { write, onTransientError, // * 2 because we have initial sleep above - retry.Delay(time.Duration(cfg.Data.Retry.Transient.Delay*2) * time.Millisecond), + retry.Delay(time.Duration(cfg.Data.Retry.Transient.Delay*2)*time.Millisecond), retry.Attempts(uint(cfg.Data.Retry.Transient.MaxAttempts)), retry.LastErrorOnly(true), ) diff --git a/pkg/observer/observer.go b/pkg/observer/observer.go index 7a21ec4d..6e30e846 100644 --- a/pkg/observer/observer.go +++ b/pkg/observer/observer.go @@ -64,7 +64,7 @@ func (o *Observer) Start() { o.isRunning = true go func() { - reportTime := time.Now().Add(o.reportInterval) + reportTime := time.Now().UTC().Add(o.reportInterval) buffer := models.ObserverBuffer{} ObserverLoop: @@ -93,13 +93,13 @@ func (o *Observer) Start() { o.log.Debugf("Observer timed out after (%v) waiting for result", o.timeout) } - if time.Now().After(reportTime) { + if time.Now().UTC().After(reportTime) { o.log.Infof(buffer.String()) if o.statsClient != nil { o.statsClient.Send(&buffer) } - reportTime = time.Now().Add(o.reportInterval) + reportTime = time.Now().UTC().Add(o.reportInterval) buffer = models.ObserverBuffer{} } } diff --git a/pkg/source/kinesis/kinesis_source_test.go b/pkg/source/kinesis/kinesis_source_test.go index 3fc4d33a..3035990e 100644 --- a/pkg/source/kinesis/kinesis_source_test.go +++ b/pkg/source/kinesis/kinesis_source_test.go @@ -188,7 +188,7 @@ func TestKinesisSource_StartTimestamp(t *testing.T) { } time.Sleep(1 * time.Second) // Put a 1s buffer either side of the start timestamp - timeToStart := time.Now() + timeToStart := time.Now().UTC() time.Sleep(1 * time.Second) putErr2 := testutil.PutNRecordsIntoKinesis(kinesisClient, 10, streamName, "Second batch") diff --git a/pkg/target/http.go b/pkg/target/http.go index 79bb26a6..9bf4dab9 100644 --- a/pkg/target/http.go +++ b/pkg/target/http.go @@ -382,9 +382,9 @@ func (ht *HTTPTarget) Write(messages []*models.Message) (*models.TargetWriteResu if ht.basicAuthUsername != "" && ht.basicAuthPassword != "" { // Add basic auth if set request.SetBasicAuth(ht.basicAuthUsername, ht.basicAuthPassword) } - requestStarted := time.Now() + requestStarted := time.Now().UTC() resp, err := ht.client.Do(request) // Make request - requestFinished := time.Now() + requestFinished := time.Now().UTC() // Add request times to every message for _, msg := range goodMsgs {