Skip to content

Commit

Permalink
Ensure all timestamps used in reporting are UTC
Browse files Browse the repository at this point in the history
  • Loading branch information
colmsnowplow authored and pondzix committed Nov 6, 2024
1 parent 4fb64f0 commit 1f98b02
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions cmd/cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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),
Expand All @@ -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),
)
Expand Down
6 changes: 3 additions & 3 deletions pkg/observer/observer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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{}
}
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/source/kinesis/kinesis_source_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
4 changes: 2 additions & 2 deletions pkg/target/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 1f98b02

Please sign in to comment.