Hello,
I am encountering an intermittent issue while developing with Go and using the GCP Logging API to fetch log entries. The process fails with the following error message on the first attempt but succeeds on subsequent attempts:
error:
rpc error: code = Canceled desc = The operation was cancelled
ex)
func main() {
ctx := context.Background() client, err := logadmin.NewClient(ctx, "YOUR_PROJECT_ID")
if err != nil {
log.Fatalf("Failed to create client: %v", err)
}
req := &logadmin.ListLogEntriesRequest{
ResourceNames: []string{"projects/YOUR_PROJECT_ID"},
Filter: `timestamp >= "2024-05-27T07:05:00Z" AND timestamp <= "2024-05-27T07:11:00Z"`,
}
it := client.Entries(ctx, req)
for {
entry, err := it.Next()
if err == iterator.Done {
break
}
return
}