atmos
atmos copied to clipboard
Telemetry - `atmos` cmd
what
- Added telemetry to
atmoscustom command
why
- Collect info about usage atmos commands
References
- #1308
Summary by CodeRabbit
-
New Features
- Introduced anonymous telemetry to collect usage data and improve the product, with clear opt-out options via configuration or environment variables.
- Added configuration options for telemetry, including enablement, endpoint, and token settings.
- Telemetry events now capture command executions, errors, CI/CD environment details, Docker usage, and workspace IDs for enhanced support.
-
Documentation
- Updated documentation to explain telemetry collection, opt-out methods, and data details, including a dedicated "Telemetry" section and updated copyright.
-
Bug Fixes
- None.
-
Tests
- Added comprehensive tests for telemetry features, including environment detection, Docker detection, event capturing, and configuration handling.
-
Chores
- Updated dependencies and configuration files to support new telemetry features and improved test coverage.
[!WARNING]
This PR exceeds the recommended limit of 1,000 lines.
Large PRs are difficult to review and may be rejected due to their size.
Please verify that this PR does not address multiple issues. Consider refactoring it into smaller, more focused PRs to facilitate a smoother review process.
๐ Walkthrough
Walkthrough
This change introduces anonymous telemetry to Atmos, capturing and sending usage data to a configurable endpoint using PostHog. It adds configuration options for telemetry, detection of execution environments (CI, Docker), event capture in command flows, documentation updates, and comprehensive tests and mocks for the new telemetry logic.
Changes
| Files/Groups | Change Summary |
|---|---|
| README.md, README.yaml | Added documentation for telemetry, opt-out instructions, and updated copyright year. |
| pkg/config/atmos.yaml, .../describe_config*.golden, .../indentation* | Added settings.telemetry section to configuration and updated CLI config snapshots. |
| pkg/schema/schema.go | Added TelemetrySettings struct and field to AtmosSettings. |
| pkg/config/cache.go | Added InstallationId field to cache and updated save logic. |
| pkg/config/load.go | Bound telemetry settings to environment variables. |
| codecov.yml | Excluded mock directories from coverage. |
| go.mod | Added PostHog Go SDK and updated dependencies. |
| cmd/cmd_utils.go | Inserted telemetry capture calls throughout command processing and error handling. |
| pkg/telemetry/telemetry.go, utils.go | Introduced telemetry client, event capture, and utility functions for command/event tracking. |
| pkg/telemetry/ci.go, docker.go | Added detection for CI/CD and Docker environments. |
| pkg/telemetry/mock/*, pkg/telemetry/telemetry_test.go, utils_test.go | Added mocks and comprehensive unit/integration tests for telemetry logic and environment detection. |
| pkg/telemetry/ci_test.go, docker_test.go | Added tests for CI/CD and Docker detection logic. |
Sequence Diagram(s)
sequenceDiagram
participant User
participant AtmosCLI
participant TelemetryUtils
participant PostHog
User->>AtmosCLI: Runs a command
AtmosCLI->>TelemetryUtils: CaptureCmd(cmd, err)
TelemetryUtils->>TelemetryUtils: Detect config, env, CI, Docker
TelemetryUtils->>TelemetryUtils: Prepare event properties
TelemetryUtils->>PostHog: Send event (if enabled)
PostHog-->>TelemetryUtils: Ack (or error ignored)
TelemetryUtils-->>AtmosCLI: Return
AtmosCLI-->>User: Command output
Assessment against linked issues
| Objective | Addressed | Explanation |
|---|---|---|
| Telemetry captures: version, commands, errors, workspace ID, OS, arch, CI providers, Docker, BitBucket, ADO (DEV-2965) | โ | |
| No arguments to commands are logged (DEV-2965) | โ | |
| Telemetry can be disabled via config or env var (DEV-2965) | โ | |
| Configurable endpoint and short timeout for telemetry (DEV-2965) | โ | |
| Anonymous UUID stored in cache (DEV-2965) | โ |
Assessment against linked issues: Out-of-scope changes
No out-of-scope changes found.
Suggested labels
no-release
Suggested reviewers
- aknysh
- osterman
โจ Finishing Touches
- [ ] ๐ Generate Docstrings
๐งช Generate Unit Tests
- [ ] Create PR with Unit Tests
- [ ] Post Copyable Unit Tests in Comment
- [ ] Commit Unit Tests in branch
DEV-2965/telemetry-cmd
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
๐ชง Tips
Chat
There are 3 ways to chat with CodeRabbit:
- Review comments: Directly reply to a review comment made by CodeRabbit. Example:
I pushed a fix in commit <commit_id>, please review it.Explain this complex logic.Open a follow-up GitHub issue for this discussion.
- Files and specific lines of code (under the "Files changed" tab): Tag
@coderabbitaiin a new review comment at the desired location with your query. Examples:@coderabbitai explain this code block.@coderabbitai modularize this function.
- PR comments: Tag
@coderabbitaiin a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:@coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.@coderabbitai read src/utils.ts and explain its main purpose.@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.@coderabbitai help me debug CodeRabbit configuration file.
Support
Need help? Create a ticket on our support page for assistance with any issues or questions.
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.
CodeRabbit Commands (Invoked using PR comments)
@coderabbitai pauseto pause the reviews on a PR.@coderabbitai resumeto resume the paused reviews.@coderabbitai reviewto trigger an incremental review. This is useful when automatic reviews are disabled for the repository.@coderabbitai full reviewto do a full review from scratch and review all the files again.@coderabbitai summaryto regenerate the summary of the PR.@coderabbitai generate docstringsto generate docstrings for this PR.@coderabbitai generate sequence diagramto generate a sequence diagram of the changes in this PR.@coderabbitai auto-generate unit teststo generate unit tests for this PR.@coderabbitai resolveresolve all the CodeRabbit review comments.@coderabbitai configurationto show the current CodeRabbit configuration for the repository.@coderabbitai helpto get help.
Other keywords and placeholders
- Add
@coderabbitai ignoreanywhere in the PR description to prevent this PR from being reviewed. - Add
@coderabbitai summaryor@auto-summaryto generate the high-level summary at a specific location in the PR description. - Add
@coderabbitaior@auto-titleanywhere in the PR title to generate the title automatically.
Documentation and Community
- Visit our Documentation for detailed information on how to use CodeRabbit.
- Join our Discord Community to get help, request features, and share feedback.
- Follow us on X/Twitter for updates and announcements.
Codecov Report
Attention: Patch coverage is 0% with 23 lines in your changes missing coverage. Please review.
Please upload report for BASE (
DEV-2965/consolidate-cmd-telemetry@86aa42e). Learn more about missing BASE report.
| Files with missing lines | Patch % | Lines |
|---|---|---|
| cmd/cmd_utils.go | 0.00% | 23 Missing :warning: |
Additional details and impacted files
@@ Coverage Diff @@
## DEV-2965/consolidate-cmd-telemetry #1340 +/- ##
=====================================================================
Coverage ? 50.96%
=====================================================================
Files ? 243
Lines ? 26111
Branches ? 0
=====================================================================
Hits ? 13307
Misses ? 11157
Partials ? 1647
| Flag | Coverage ฮ | |
|---|---|---|
| unittests | 50.96% <0.00%> (?) |
Flags with carried forward coverage won't be shown. Click here to find out more.
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
:rocket: New features to boost your workflow:
- :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
@mergifyio rebase
rebase
โ Branch has been successfully rebased
๐ฅ This pull request now has conflicts. Could you fix it @goruha? ๐