Skip to content

Add usage event tracking for explain error requests#133

Merged
shenxianpeng merged 3 commits intomainfrom
fix-130
Apr 7, 2026
Merged

Add usage event tracking for explain error requests#133
shenxianpeng merged 3 commits intomainfrom
fix-130

Conversation

@shenxianpeng
Copy link
Copy Markdown
Member

@shenxianpeng shenxianpeng commented Apr 5, 2026

Summary

  • add UsageEvent, UsageRecorder, and UsageRecorders to capture Explain Error request outcomes
  • record usage for pipeline and console flows, including success, cache hits, disabled, misconfigured, and provider error cases
  • persist provider model and input log line counts on saved explanations and update tests for tracking and invalid provider behavior
  • ignore .gstack in Git

Testing

  • Not run (not requested)

close #130

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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, and UsageRecorders for 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.

Comment on lines 81 to 86
// 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;
Copy link

Copilot AI Apr 5, 2026

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
@shenxianpeng shenxianpeng marked this pull request as ready for review April 5, 2026 05:35
@shenxianpeng shenxianpeng requested a review from a team as a code owner April 5, 2026 05:35
@shenxianpeng shenxianpeng added the enhancement For changelog: Minor enhancement. use `major-rfe` for changes to be highlighted label Apr 5, 2026
@shenxianpeng shenxianpeng merged commit 4c219aa into main Apr 7, 2026
17 checks passed
@shenxianpeng shenxianpeng deleted the fix-130 branch April 7, 2026 06:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement For changelog: Minor enhancement. use `major-rfe` for changes to be highlighted

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add internal usage event tracking for Explain Error requests

2 participants