Skip to content

Add core telemetry instrumentation#407

Merged
robinaugh merged 1 commit intomainfrom
jason/rwx-44-core-telemetry-instrumentation
Mar 10, 2026
Merged

Add core telemetry instrumentation#407
robinaugh merged 1 commit intomainfrom
jason/rwx-44-core-telemetry-instrumentation

Conversation

@robinaugh
Copy link
Contributor

@robinaugh robinaugh commented Mar 9, 2026

Summary

  • Record cli.command event after every command execution (command name, flags, output format, duration, success)
  • Record cli.error event on failure (command, error type classification, handled flag)
  • Add StatsRoundTripper that accumulates API call stats and emits an aggregated api.summary event at flush time
  • Move telemetry flush from PersistentPostRun to main.go so it fires on both success and error paths (Cobra skips post-run hooks when RunE returns an error)
  • Wrap collector, sender, and stats RT behind a unified Telemetry type

Test plan

  • Unit tests for StatsRoundTripper (tracking, aggregation, telemetry endpoint exclusion, drain, transport errors, path ordering)
  • All existing unit tests pass
  • Manual verification that telemetry events are POSTed to /api/telemetry on command success and failure

@robinaugh robinaugh self-assigned this Mar 9, 2026
@robinaugh robinaugh force-pushed the jason/rwx-44-core-telemetry-instrumentation branch from dd987b7 to e6c296a Compare March 9, 2026 22:12
Base automatically changed from jason/rwx-42-telemetry-plumbing to main March 10, 2026 13:37
@robinaugh robinaugh changed the title Add core telemetry instrumentation (RWX-44) Add core telemetry instrumentation Mar 10, 2026
Record cli.command, cli.error, and api.summary events. Move telemetry
flush from PersistentPostRun to main.go so it fires on both success and
error paths. Add stats RoundTripper for API call aggregation. Wrap
collector, sender, and stats RT behind a unified Telemetry type.
@robinaugh robinaugh force-pushed the jason/rwx-44-core-telemetry-instrumentation branch from e6c296a to 5245849 Compare March 10, 2026 13:38
@robinaugh robinaugh marked this pull request as ready for review March 10, 2026 13:42

"github.com/rwx-cloud/cli/internal/cli"
internalerrors "github.com/rwx-cloud/cli/internal/errors"
"github.com/spf13/pflag"
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this give us something that cobra doesn't expose?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

pflag is used by cobra, and we just need to import it to be able to use it in a type declaration.

@robinaugh robinaugh merged commit 971f4b4 into main Mar 10, 2026
1 check passed
@robinaugh robinaugh deleted the jason/rwx-44-core-telemetry-instrumentation branch March 10, 2026 13:54
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