Skip to content

Commit 63129f5

Browse files
committed
Track interval duration sums as ints not floats
1 parent c3bdb3e commit 63129f5

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

pkg/monitortests/testframework/intervaldurationsum/monitortest.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import (
2020
//
2121
// The generated autodl file will have the following schema:
2222
// - IntervalSource (string): The source type of the intervals
23-
// - TotalDurationSeconds (float64): Sum of all interval durations in seconds for that source
23+
// - TotalDurationSeconds (int): Sum of all interval durations in seconds for that source
2424
//
2525
// The autodl file will be named: interval_duration_sum{timeSuffix}-autodl.json
2626
type intervalDurationSum struct {
@@ -70,17 +70,17 @@ func (w *intervalDurationSum) WriteContentToStorage(ctx context.Context, storage
7070
return eventInterval.Source == source
7171
})
7272

73-
var totalDurationSeconds float64
73+
var totalDurationSeconds int
7474
for _, interval := range matchingIntervals {
75-
duration := interval.To.Sub(interval.From).Seconds()
75+
duration := int(interval.To.Sub(interval.From).Seconds())
7676
totalDurationSeconds += duration
7777
}
7878

79-
logger.Infof("Total duration for source %s: %.2f seconds across %d intervals", source, totalDurationSeconds, len(matchingIntervals))
79+
logger.Infof("Total duration for source %s: %d seconds across %d intervals", source, totalDurationSeconds, len(matchingIntervals))
8080

8181
rows = append(rows, map[string]string{
8282
"IntervalSource": string(source),
83-
"TotalDurationSeconds": fmt.Sprintf("%.2f", totalDurationSeconds),
83+
"TotalDurationSeconds": fmt.Sprintf("%d", totalDurationSeconds),
8484
})
8585
}
8686

@@ -89,7 +89,7 @@ func (w *intervalDurationSum) WriteContentToStorage(ctx context.Context, storage
8989
TableName: "interval_duration_sum",
9090
Schema: map[string]dataloader.DataType{
9191
"IntervalSource": dataloader.DataTypeString,
92-
"TotalDurationSeconds": dataloader.DataTypeFloat64,
92+
"TotalDurationSeconds": dataloader.DataTypeInteger,
9393
},
9494
Rows: rows,
9595
}

0 commit comments

Comments
 (0)