Skip to content

Add Guardian review metrics#24897

Merged
jif-oai merged 2 commits into
mainfrom
jif/guardian-metrics
May 28, 2026
Merged

Add Guardian review metrics#24897
jif-oai merged 2 commits into
mainfrom
jif/guardian-metrics

Conversation

@jif-oai
Copy link
Copy Markdown
Collaborator

@jif-oai jif-oai commented May 28, 2026

Why

Guardian reviews already emit analytics events, but we do not expose aggregate OpenTelemetry metrics for review volume, latency, token usage, or terminal outcomes. That makes it harder to monitor Guardian behavior during rollouts and to compare review outcomes by source, action type, session kind, model, and failure mode.

What Changed

  • Added Guardian review metric names for count, total duration, time to first token, and token usage in codex-rs/otel.
  • Added core/src/guardian/metrics.rs to convert GuardianReviewAnalyticsResult into sanitized metric tags covering decision, terminal status, failure reason, approval request source, reviewed action, session kind, risk/outcome, model, reasoning effort, and context/truncation state.
  • Emitted the new metrics from track_guardian_review for each terminal Guardian review result.

Testing

  • Added guardian_review_metrics_record_counts_durations_and_token_usage, which verifies the emitted count, duration, TTFT, token usage histograms, and tag set through the in-memory metrics exporter.

@jif-oai jif-oai requested a review from a team as a code owner May 28, 2026 10:56
@jif-oai jif-oai changed the title feat: guardian metrics Add Guardian review metrics May 28, 2026
@jif-oai
Copy link
Copy Markdown
Collaborator Author

jif-oai commented May 28, 2026

@codex review

Copy link
Copy Markdown
Contributor

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f87e53261e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread codex-rs/core/src/guardian/review.rs
@jif-oai jif-oai merged commit 3abf967 into main May 28, 2026
31 checks passed
@jif-oai jif-oai deleted the jif/guardian-metrics branch May 28, 2026 12:07
@github-actions github-actions Bot locked and limited conversation to collaborators May 28, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant