Skip to content

refactor(observability): simplify run outcome tracking, route span attributes and proxy log deprecations - #4605

Merged
kwakayama merged 1 commit into
mainfrom
refactor/obs-1860-simplify
Sep 27, 2026
Merged

kwakayama merged 1 commit into
mainfrom
refactor/obs-1860-simplify

Conversation

@kwakayama

@kwakayama kwakayama commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

Follow-up cleanup of the observability code merged in #4600, #4601, #4602, #4603 and #4604. No behavior change: span attribute names, metric and label names, and log field names are unchanged.

Simplifications

Reviewed and left as is

  • markSpanFailed (otlp-setup), ServiceTracerSpan.markFailed and telemetryErrorType do not overlap. The first two set an error status on two different span types. telemetryErrorType classifies a thrown error. HostedAgentRunSpan.markFailed stays optional because hosts implement that public interface.
  • __getTenantSeriesScopeCountForTests asserts that series registries do not outlive their targets. That memory bound has no other observable signal, and it follows the existing __getDirectTargetCountForTests pattern.

Part of veryfront/veryfront-issue-inbox#1860

Summary by CodeRabbit

  • Bug Fixes
    • Run outcomes now report tool-call failures and error codes consistently across completed, cancelled, and failed runs.
    • Tenant attribute limits now apply only to tenant-owned attributes; reserved project labels do not count toward the limit. This provides more accurate tenant attribute measurements.
  • Documentation
    • Clarified that camelCase log fields are deprecated aliases of their snake_case counterparts.

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Your trial has ended. Reactivate Greptile to resume code reviews.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for security reviews. Please try again later.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 26, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-26T23:55:37.304317Z 62ab7db PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions

Copy link
Copy Markdown

📦 Client bundle boundary

Entrypoint Modules Source size Server leaks
src/index.client.ts 289 2321 KiB ✅ 0

A server module in a client graph aborts hydration in the browser. New leaks fail CI; known leaks are tracked in scripts/lint/client-bundle-baseline.json to burn down.

@coderabbitai

coderabbitai Bot commented Sep 26, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 0f4e2670-7340-4c17-87ff-29b44823f630

📥 Commits

Reviewing files that changed from the base of the PR and between 927fb54 and 62ab7db.

📒 Files selected for processing (4)
  • src/internal-agents/run-stream.ts
  • src/metrics/index.ts
  • src/proxy/logger.ts
  • src/routing/registry/registry.ts

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

The changes update run outcome tracking and telemetry attribute handling. They also revise logger field deprecation comments and simplify a condition in route registry span attribute construction.

Changes

Run outcome tracking

Layer / File(s) Summary
Track outcomes through terminal reporting
src/internal-agents/run-stream.ts
A tracker collects tool-call errors, errors from child-agent tool calls, and the first stable RunError code. Terminal error selection, span attributes, and log fields use the tracker. The AgentRunTerminalError fallback remains in place.

Tenant attribute sampling

Layer / File(s) Summary
Count tenant-owned attributes
src/metrics/index.ts
The tenant sample count now tracks tenant-owned attributes. Reserved project labels remain excluded from the limit.

Logger field documentation

Layer / File(s) Summary
Document field aliases
src/proxy/logger.ts
Comments mark camelCase fields as deprecated aliases and direct users to the corresponding snake_case fields.

Route registry span attributes

Layer / File(s) Summary
Gate route attribute construction
src/routing/registry/registry.ts
The function returns the existing attributes when both projectSlug and projectId are absent. Attribute construction is unchanged when either is present.

Priority: ⬇️ Low

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Refactor

Merge Risk: ⚪ Minimal · up to 62ab7

No actionable issue remains in the supplied review evidence; the PR is mergeable after normal checks.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 6 functions across 4 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main observability refactoring, including run outcome tracking, route span attributes, and proxy log deprecations.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@gitar-bot

gitar-bot Bot commented Sep 26, 2026

Copy link
Copy Markdown

Important

You are using the Gitar free plan. Upgrade to unlock code review, CI analysis, auto-apply, custom automations, and more.

Gitar

Copy link
Copy Markdown
Contributor Author

Code review: 90/100

Clean, low-risk refactor. Traced each change against its pre-refactor equivalent; behavior is unchanged.

  • createRunOutcomeTracker in run-stream.ts consolidates three duplicated spanAttributes/logFields blocks (finalized, cancelled, failed) into one factory. The else if chain is safe because event only ever matches one of ToolCallStart, ToolCallResult, or RunError per call.
  • buildRouteRegistrySpanAttributes's early return (if (!projectSlug && !projectId) return attributes;) is logically equivalent to the original (projectSlug || projectId) guard on both blocks, and removes a nesting level as described.
  • ownAttributes rename and the LogEntry doc-comment cleanup in proxy/logger.ts are cosmetic only, no logic touched.
  • PR description is precise: it maps each simplification to the PR that introduced it and calls out what was reviewed and deliberately left alone (markSpanFailed vs. ServiceTracerSpan.markFailed vs. telemetryErrorType, the tenant-scope test helper). That's a good practice for a cleanup PR.
  • No test changes accompany this, which is fine for a pure refactor with existing coverage, but I could not execute deno task test:file in this environment (no deno binary available) to confirm run-stream.test.ts and registry.test.ts still pass on this exact head. CI's test/coverage shards were still in progress at review time, worth confirming they land green before merge.

Minor nit, non-blocking: in createRunOutcomeTracker, toolCallId is destructured from payload but toolCallName is accessed as payload.toolCallName in the same condition. Consistent either way would read slightly cleaner, but it's not a defect.


Generated by Claude Code

@codecov

codecov Bot commented Sep 27, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@sonarqubecloud

Copy link
Copy Markdown

@kwakayama
kwakayama added this pull request to the merge queue Sep 27, 2026
Merged via the queue into main with commit c76449d Sep 27, 2026
68 checks passed
@kwakayama
kwakayama deleted the refactor/obs-1860-simplify branch September 27, 2026 00:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant