Skip to content

feat: GCP cloud logging streams#1454

Draft
adityathebe wants to merge 1 commit intomainfrom
feat/gcp-cloud-logging-stream
Draft

feat: GCP cloud logging streams#1454
adityathebe wants to merge 1 commit intomainfrom
feat/gcp-cloud-logging-stream

Conversation

@adityathebe
Copy link
Copy Markdown
Member

No description provided.

Comment on lines +285 to +286
// https://stackoverflow.com/questions/76765079/v2-entriestail-always-returns-invalid-argument
// https: //cloud.google.com/logging/docs/reference/v2/rest/v2/entries/tail?apix=true&apix_params=%7B%22resource%22%3A%5B%7B%22resourceNames%22%3A%5B%22projects%2Fworkload-prod-eu-02%22%5D%7D%5D%7D#Reason
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tail API returns Bad Request for some reason

@adityathebe adityathebe requested a review from Copilot June 12, 2025 08:29
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Adds support for streaming GCP Cloud Logging entries and scaffolding for end-to-end tests.

  • Introduce StreamRequest, StreamItem, and Stream method in gcpcloudlogging for tailing logs.
  • Update New to initialize both admin and service clients via loggingapi.
  • Add a pending E2E test for streaming logs and adjust suite setup to skip dummy data.

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
tests/e2e/suite_test.go Pass WithoutDummyData option to BeforeSuite setup.
tests/e2e/gcp_test.go Add pending GCP log-streaming test (TODO cleanup commented code).
logs/gcpcloudlogging/cloud_logging.go Implement Stream, define streaming types, update New API.
logs/gcpcloudlogging/zz_generated.deepcopy.go Auto-generated DeepCopy for StreamRequest.
Comments suppressed due to low confidence (3)

logs/gcpcloudlogging/cloud_logging.go:238

  • [nitpick] Inconsistent context usage: New and Search use dutycxt.Context but Stream accepts context.Context. For consistency and to leverage dutycxt features, consider aligning all methods to use the same context type.
func (gcp *cloudLogging) Stream(ctx context.Context, request StreamRequest) (<-chan StreamItem, error) {

logs/gcpcloudlogging/cloud_logging.go:38

  • [nitpick] Public types and methods (StreamRequest, StreamItem, and Stream) lack top-level doc comments. Add GoDoc comments to explain their purpose and usage.
type StreamRequest struct {

logs/gcpcloudlogging/cloud_logging.go:270

  • The max function is undefined here, causing a compile error. Implement a helper (e.g., func max(a, b int) int) or inline the comparison to choose between request.BufferWindow and 1.
ticker := time.NewTicker(time.Duration(max(request.BufferWindow, 1)) * time.Millisecond)

Comment thread tests/e2e/gcp_test.go
Comment thread tests/e2e/gcp_test.go
Comment on lines +259 to +261
req.BufferWindow = fmt.Sprintf("%d", request.BufferWindow*1000)
} else {
req.BufferWindow = "2000"
Copy link

Copilot AI Jun 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There’s a unit mismatch: BufferWindow is documented as seconds but is used both to set milliseconds in the API request and as milliseconds for the ticker. Clarify units or convert consistently.

Suggested change
req.BufferWindow = fmt.Sprintf("%d", request.BufferWindow*1000)
} else {
req.BufferWindow = "2000"
req.BufferWindow = fmt.Sprintf("%d", request.BufferWindow*1000) // Convert seconds to milliseconds
} else {
req.BufferWindow = fmt.Sprintf("%d", 2*1000) // Default to 2 seconds, converted to milliseconds

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants