Skip to content

Add goal lifecycle metrics#20799

Merged
etraut-openai merged 3 commits into
mainfrom
etraut/goal-metrics
May 5, 2026
Merged

Add goal lifecycle metrics#20799
etraut-openai merged 3 commits into
mainfrom
etraut/goal-metrics

Conversation

@etraut-openai
Copy link
Copy Markdown
Collaborator

@etraut-openai etraut-openai commented May 2, 2026

Why

Adding goal metrics makes it possible to track how often goals are created, completed, and stopped by budget limits, plus the final token and wall-clock usage for terminal outcomes.

What Changed

  • Added OpenTelemetry metric constants for goal lifecycle tracking:
    • codex.goal.created: increments each time a new persisted goal is created or an existing goal is replaced with a new objective.
    • codex.goal.completed: increments when a goal transitions to complete.
    • codex.goal.budget_limited: increments when a goal transitions to budget_limited because its token budget has been reached.
    • codex.goal.token_count: records the final persisted token count when a goal transitions to complete or budget_limited.
    • codex.goal.duration_s: records the final persisted elapsed wall-clock time, in seconds, when a goal transitions to complete or budget_limited.
  • Emitted creation metrics when a goal is created or replaced.
  • Emitted terminal outcome counters and final usage histograms when a goal transitions to complete or budget_limited, avoiding double-counting later in-flight accounting for already budget-limited goals.
  • Added focused codex-core tests for create/complete metrics and one-time budget-limit metrics.

@etraut-openai etraut-openai marked this pull request as ready for review May 2, 2026 16:49
@etraut-openai etraut-openai requested a review from a team as a code owner May 2, 2026 16:49
@etraut-openai etraut-openai marked this pull request as draft May 2, 2026 16:51
@etraut-openai etraut-openai marked this pull request as ready for review May 2, 2026 16:51
@etraut-openai etraut-openai changed the title [codex] Add goal lifecycle metrics Add goal lifecycle metrics May 2, 2026
Comment thread codex-rs/core/src/session/tests.rs Outdated
Comment thread codex-rs/core/src/goals.rs
Comment thread codex-rs/core/src/goals.rs
Comment thread codex-rs/core/src/goals.rs Outdated
etraut-openai added a commit that referenced this pull request May 5, 2026
@etraut-openai
Copy link
Copy Markdown
Collaborator Author

@codex review

@etraut-openai etraut-openai requested a review from jif-oai May 5, 2026 02:12
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: 03f1a23197

ℹ️ 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/goals.rs Outdated
Copy link
Copy Markdown
Collaborator

@jif-oai jif-oai left a comment

Choose a reason for hiding this comment

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

This will become sketchy the day we have multi-clients but good fo rnow

@etraut-openai etraut-openai merged commit 91b7350 into main May 5, 2026
26 checks passed
@etraut-openai etraut-openai deleted the etraut/goal-metrics branch May 5, 2026 16:21
@github-actions github-actions Bot locked and limited conversation to collaborators May 5, 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.

2 participants