feat(telemetry): flow events foundations#238
Merged
LorrisSaintGenez merged 4 commits intoJun 11, 2026
Merged
Conversation
- go telemetryClient.Close() ran in PersistentPreRunE, closing the client before the command executed and racing with process exit - close the client in Execute() via defer, bounded by a 3s timeout so an unreachable telemetry endpoint never delays exit - fall back to NoOpTelemetryClient when the analytics client cannot be created instead of storing a nil interface in the context - enable analytics-go verbose logging in debug mode so successful flushes are visible with DEBUG=1 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 19 |
| Duplication | 16 |
TIP This summary will be updated as you push new changes.
…umber - Track now takes a properties map, merged with the base properties; base properties are written last so call sites cannot override them - each Track event carries a monotonic sequence number (atomic counter) so the exact order of one invocation can be reconstructed downstream: Segment stores timestamps with millisecond precision, so back-to-back events can tie Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
- events.go: typed catalog for the flow events (event name constants, Flow/Step/Direction enums), FlowTracker helper (current step and flow duration) and ErrorClass (root cause type only, never the message, which could contain user data) - Execute() reports a Command Completed event with succeeded, exit_code, duration_ms, and error_class/user_cancelled on failure, through a deferred read of the named return value Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
- don't emit an orphan Command Completed when PersistentPreRunE never ran (--help, --version, unknown flag/command, failed auth check): no Command Invoked was sent, and the command property would be empty - measure the command duration right after execution, so duration_ms never includes the update-notifier wait (which only happens on the success path and would bias the metric) - ErrorClass keeps the first informative type of the error chain instead of unwrapping to the root, which collapsed every CLI error into *errors.errorString - tests: trackCommandCompleted (skip/success/failure), sequence uniqueness under concurrency, informative wrapper type Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
8bittitan
approved these changes
Jun 11, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Foundations for the CLI flow events (GROUT-349), one atomic commit per step:
go telemetryClient.Close()ran inPersistentPreRunE, closing the client before the command executed and racing with process exit. The client is now closed viadeferinExecute(), bounded by a 3s timeout so an unreachable telemetry endpoint never delays exit.createContextfalls back toNoOpTelemetryClientinstead of storing a nil interface, and analytics-goVerboselogging is enabled in debug mode.Trackwith custom properties +sequence—Track(ctx, event, properties)merges custom properties with the base ones (base written last, so call sites cannot override them). Every event carries a monotonicsequence(atomic counter): the exact order of one invocation can be reconstructed downstream by sorting on(invocation_id, sequence)— Segment stores millisecond-precision timestamps, so back-to-back events can tie.Command Completed—pkg/telemetry/events.goholds the event name constants, theFlow/Step/Directionenums,FlowTracker(current step + flow duration) andErrorClass(first informative type of the error chain, never the error message).Execute()now emitsCommand Completed(succeeded,exit_code,duration_ms, pluserror_class/user_cancelledon failure) right before the final flush.Command CompletedwhenPersistentPreRunEnever ran (--help,--version, unknown flag/command, failed auth check: no pairedCommand Invoked, and thecommandproperty would be empty);duration_msis measured right after execution so it never includes the update-notifier wait; tests fortrackCommandCompletedand forsequenceuniqueness under concurrency.Test
GROUT-349