Skip to content

Add telemetry plumbing infrastructure#405

Merged
robinaugh merged 1 commit intomainfrom
jason/rwx-42-telemetry-plumbing
Mar 10, 2026
Merged

Add telemetry plumbing infrastructure#405
robinaugh merged 1 commit intomainfrom
jason/rwx-42-telemetry-plumbing

Conversation

@robinaugh
Copy link
Contributor

@robinaugh robinaugh commented Mar 9, 2026

Summary

  • Adds internal/telemetry/ package with collector and sender
  • Collector queues events in memory (thread-safe); Sender POSTs them as JSON to POST /api/telemetry
  • At CLI exit, Flush() fires a non-blocking goroutine to deliver queued events
  • No integration with the API client's HTTP transport — telemetry is fully decoupled

Test plan

  • 7 unit tests covering collector and sender
  • All existing unit tests pass
  • Lint clean

@robinaugh robinaugh self-assigned this Mar 9, 2026
@robinaugh robinaugh force-pushed the jason/rwx-42-telemetry-plumbing branch 3 times, most recently from aa8c0c2 to 387feea Compare March 9, 2026 16:20
@robinaugh robinaugh changed the title Add telemetry plumbing infrastructure (RWX-42) Add telemetry plumbing infrastructure Mar 9, 2026
@robinaugh robinaugh marked this pull request as ready for review March 9, 2026 16:44
@TAGraves
Copy link
Member

TAGraves commented Mar 9, 2026

The buffering part of this PR seems like it's adding a lot of complexity and I'm not sure it's really the right solution anyway (it seems unlikely we'd ever exceed 8kb but if we did, shouldn't we just make a dedicate API call to cloud to report the information that couldn't be set in the header? I'd prefer we just rip out the buffering for now and add something to the header to indicate the payload was too big, and solve for that if we ever actually get to that point

@robinaugh
Copy link
Contributor Author

The buffering part of this PR seems like it's adding a lot of complexity and I'm not sure it's really the right solution anyway (it seems unlikely we'd ever exceed 8kb but if we did, shouldn't we just make a dedicate API call to cloud to report the information that couldn't be set in the header? I'd prefer we just rip out the buffering for now and add something to the header to indicate the payload was too big, and solve for that if we ever actually get to that point

The buffer would also be used to cache telemetry reports for CLI calls that don't make API calls, such as rwx lint. If we added a dedicated endpoint for reporting overflow, that same endpoint could be used for those cases as well, as long as it is non-blocking.

@robinaugh robinaugh force-pushed the jason/rwx-42-telemetry-plumbing branch 7 times, most recently from 10ac1b3 to 16cef38 Compare March 9, 2026 17:59
}

url := fmt.Sprintf("https://%s%s", s.host, telemetryEndpoint)
resp, err := http.Post(url, "application/json", bytes.NewReader(data))
Copy link
Member

Choose a reason for hiding this comment

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

Should this be leveraging our other roundtripping logic s/t it picks up the access token if it exists?

Copy link
Member

Choose a reason for hiding this comment

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

notably without a token, the WAF will probably block this

Copy link
Member

Choose a reason for hiding this comment

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

Oh and CLI headers and such

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good call - wrapped this in the existing roundtripper so we get tokens and user agent. Will tackle the WAF separately, but FWIW this PR should be safe to go in any time before that because it does not yet wire up any real calls to the telemetry endpoint.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Logged RWX-65: Allow unauthenticated POST to /api/telemetry through WAF and marked the rest of the CLI issues in Linear as being blocked by that work.

Use the API client's RoundTripper for telemetry transport so requests
pick up the access token, User-Agent header, and host configuration
automatically.
@robinaugh robinaugh force-pushed the jason/rwx-42-telemetry-plumbing branch from 16cef38 to 036d518 Compare March 9, 2026 21:26
@robinaugh robinaugh requested a review from kylekthompson March 9, 2026 21:27
@robinaugh robinaugh mentioned this pull request Mar 9, 2026
3 tasks
@robinaugh robinaugh merged commit fbfae5c into main Mar 10, 2026
1 check passed
@robinaugh robinaugh deleted the jason/rwx-42-telemetry-plumbing branch March 10, 2026 13:37
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.

3 participants