Add usage event tracking for explain error requests#133
Conversation
There was a problem hiding this comment.
Pull request overview
Adds an internal usage-event model and recorder plumbing to track Explain Error request outcomes across both pipeline-step and console-action entry points, and persists additional provider metadata on saved explanations.
Changes:
- Introduce
UsageEvent,UsageRecorder, andUsageRecordersfor internal usage tracking. - Emit usage events from pipeline and console flows (success, cache hit, disabled, misconfigured, provider error).
- Persist provider model + input log line count on
ErrorExplanationAction, and update tests accordingly.
Reviewed changes
Copilot reviewed 8 out of 9 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
src/main/java/io/jenkins/plugins/explain_error/UsageEvent.java |
Adds immutable usage event record + enums for entry point/result. |
src/main/java/io/jenkins/plugins/explain_error/UsageRecorder.java |
Adds extension point interface for recording usage events. |
src/main/java/io/jenkins/plugins/explain_error/UsageRecorders.java |
Resolves recorders via ExtensionList and dispatches events safely. |
src/main/java/io/jenkins/plugins/explain_error/ErrorExplainer.java |
Emits usage events from the shared pipeline + console explanation paths. |
src/main/java/io/jenkins/plugins/explain_error/ConsoleExplainErrorAction.java |
Emits cache-hit/disabled usage events for console-triggered requests. |
src/main/java/io/jenkins/plugins/explain_error/ErrorExplanationAction.java |
Persists provider model + input log line count for later cache-hit attribution. |
src/test/java/io/jenkins/plugins/explain_error/UsageTrackingTest.java |
New tests validating usage events for pipeline + console flows. |
src/test/java/io/jenkins/plugins/explain_error/ExplainErrorStepTest.java |
Updates expectations for invalid-provider logging behavior. |
.gitignore |
Ignores .gstack. |
| // Check if explanation is enabled (folder-level or global) | ||
| if (!isExplanationEnabled(run)) { | ||
| logToConsole(listener, "Explanation is disabled by configuration."); | ||
| recordUsage(entryPoint, UsageEvent.Result.DISABLED, null, startTimeNanos, 0, | ||
| collectDownstreamLogs); | ||
| return null; |
There was a problem hiding this comment.
When explanation is disabled, the usage event is recorded with a null provider (and therefore "Unknown" provider/model). If the provider is configured but disabled by config, it’s still useful for tracking to include the configured provider name/model; consider resolving the provider (or reading it from the effective config) before recording the DISABLED event.
Summary
UsageEvent,UsageRecorder, andUsageRecordersto capture Explain Error request outcomes.gstackin GitTesting
close #130