Skip to content

Commit

Permalink
Consider the case when log stream has no log events (#18)
Browse files Browse the repository at this point in the history
  • Loading branch information
yutachaos authored Apr 6, 2020
1 parent 4ab3d98 commit f630140
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion cloudwatch/stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,21 @@ func (cwl *Client) ListStreams(ctx context.Context, groupName string, since int6
hasUpdatedStream := false
minLastIngestionTime := int64(math.MaxInt64)
for _, stream := range res.LogStreams {

// If there is no log event in the log stream, FirstEventTimestamp, LastEventTimestamp, LastIngestionTime, and UploadSequenceToken will be nil.
// This activity is not officially documented.
if stream.FirstEventTimestamp == nil || stream.LastEventTimestamp == nil || stream.LastIngestionTime == nil || stream.UploadSequenceToken == nil {
continue
}

if *stream.LastIngestionTime < minLastIngestionTime {
minLastIngestionTime = *stream.LastIngestionTime
}
if !cwl.config.LogStreamNameFilter.MatchString(*stream.LogStreamName) {
continue
}
// Use LastIngestionTime because LastEventTimestamp is updated slowly...
if stream.LastIngestionTime == nil || *stream.LastIngestionTime < since {
if *stream.LastIngestionTime < since {
continue
}
hasUpdatedStream = true
Expand Down

0 comments on commit f630140

Please sign in to comment.