emit budget_remaining metric to OTel#87
Merged
cchinchilla-dev merged 2 commits intomainfrom Apr 3, 2026
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
Pull request overview
Adds first-class OpenTelemetry emission for “budget remaining” by extending the observability surface (metrics + observer hooks) and wiring the engine to publish remaining budget updates during workflow execution.
Changes:
- Add OTel observable gauge
agentloom_budget_remaining_usdand store per-workflow remaining budget for callback-based export. - Introduce
WorkflowObserver.on_budget_remaining()and wireWorkflowEngineto emit remaining budget after each costed step. - Update/extend tests to cover the new observer hook and
_budget_remainingstate updates.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
src/agentloom/observability/metrics.py |
Adds _budget_remaining store and an OTel observable gauge callback; updates set_budget_remaining() to populate both OTel (dict) and Prometheus (gauge). |
src/agentloom/observability/observer.py |
Adds on_budget_remaining() hook to forward remaining budget to metrics. |
src/agentloom/core/engine.py |
Emits on_budget_remaining after each successful, costed step when a workflow budget is configured. |
tests/observability/test_observer.py |
Adds tests for the new observer hook behavior. |
tests/observability/test_metrics.py |
Adds assertion that set_budget_remaining() populates _budget_remaining. |
src/agentloom/tools/sandbox.py |
Removes section-separator comments only (no behavioral change). |
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.
Summary
agentloom_budget_remaining_usdinMetricsManager, following the same callback pattern as the circuit breaker gaugeset_budget_remaining()to write to both OTel and Prometheus backends (was Prometheus-only)on_budget_remaining()hook toWorkflowObserver# ---) fromobserver.py,metrics.py,sandbox.pyTest plan
uv run pytest— 690 pass, 7 e2e deselecteduv run mypy src/— no issuesuv run ruff check src/ tests/— all checks passedon_budget_remainingobserver hook and_budget_remainingdict populationCloses #15