Skip to content

feat(manifest): observability metrics for path resolution - #835

Merged
vilenarios merged 2 commits into
developfrom
feat/manifest-resolution-metrics
Aug 10, 2026
Merged

feat(manifest): observability metrics for path resolution#835
vilenarios merged 2 commits into
developfrom
feat/manifest-resolution-metrics

Conversation

@vilenarios

Copy link
Copy Markdown
Contributor

Adds the observability layer (1e) for manifest path resolution. Independent of the resolution PR (#833) — touches only metrics.ts and the data handler, no overlap — and is meaningful now (data-path metrics) and richer once #833 lands (index-path metrics start firing).

Metrics

  • manifest_resolutions_total{source,resolution_type} — resolutions by source (index = served from the persistent/cached index without parsing the body, vs data = on-demand body parse) and resolution_type (path/index/fallback/unresolved). The index-vs-data ratio is the effectiveness signal for the resolution index + cache.
  • manifest_unresolved_root_total — root/index requests that resolved to nothing (a malformed-manifest signal that today only surfaces as a user 404).
  • manifest_resolution_duration_seconds{source} — resolution latency by source (bounded lookup vs body parse).

Placement

Instruments the two existing resolution sites in src/routes/data/handlers.ts. index is counted only when the index actually determined the outcome (complete); a miss falls through and is counted at the data-parse site, so each resolution is counted once.

Tests

manifest-resolution-metrics.test.ts (new, 4): verifies label routing (source × resolution_type), duration observation, and that the unresolved-root counter fires for an unresolved root but not for an unresolved sub-path. Handler suite unaffected (96/96); lint clean; zero new type errors.

Notes

No new env var and no metrics doc exists in docs/, so nothing to sync there.

🤖 Generated with Claude Code

https://claude.ai/code/session_01LPbcF2M3P1XcM8mU8FWEf9

@coderabbitai

coderabbitai Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@vilenarios, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 29 minutes

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 52fafb63-4360-4251-a5f5-98a61f2b72b6

📥 Commits

Reviewing files that changed from the base of the PR and between 3e81d66 and 407d9ea.

📒 Files selected for processing (3)
  • src/metrics.ts
  • src/routes/data/handlers.ts
  • src/routes/data/manifest-resolution-metrics.test.ts
📝 Walkthrough

Walkthrough

The change adds Prometheus metrics for manifest resolution outcomes, unresolved root requests, and resolution duration. Data handlers record metrics for index-based and manifest-parsing resolution paths. Tests cover labels, counters, histograms, and unresolved cases.

Changes

Manifest resolution metrics

Layer / File(s) Summary
Metric definitions and recording helper
src/metrics.ts, src/routes/data/handlers.ts
Defines manifest resolution counters and duration histograms. Adds recordManifestResolutionMetrics to classify results, record duration, and count unresolved root paths.
Resolution-path instrumentation and tests
src/routes/data/handlers.ts, src/routes/data/manifest-resolution-metrics.test.ts
Records metrics for complete index resolutions and manifest parsing. Tests resolved and unresolved roots, sub-path handling, labels, counters, and durations.

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

Possibly related PRs

  • ar-io/ar-io-node#832: Modifies manifest path resolution and resolved versus unresolved path handling.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the added observability metrics for manifest path resolution.
Description check ✅ Passed The description directly explains the new metrics, instrumentation scope, tests, and relationship to manifest path resolution.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/manifest-resolution-metrics

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.

@codecov

codecov Bot commented Aug 5, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 79.46%. Comparing base (3e81d66) to head (407d9ea).

Additional details and impacted files
@@             Coverage Diff             @@
##           develop     #835      +/-   ##
===========================================
+ Coverage    79.43%   79.46%   +0.02%     
===========================================
  Files          138      138              
  Lines        53401    53439      +38     
  Branches      4087     4087              
===========================================
+ Hits         42420    42465      +45     
+ Misses       10928    10921       -7     
  Partials        53       53              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@vilenarios

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (3)
src/routes/data/handlers.ts (1)

1384-1414: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Use TSDoc for the exported metrics recorder.

Convert the line-comment block into a TSDoc block for recordManifestResolutionMetrics. Document the input fields and root-path behavior.

As per coding guidelines, “Add or improve TSDoc comments on code you touch.”

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/routes/data/handlers.ts` around lines 1384 - 1414, Replace the
line-comment block above recordManifestResolutionMetrics with a TSDoc comment.
Document the function’s purpose, the source, resolution, manifestPath, and
durationMs inputs, and clarify that unresolved root paths increment the
corresponding metric.

Source: Coding guidelines

src/routes/data/manifest-resolution-metrics.test.ts (1)

14-49: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Document the new test helpers.

Add TSDoc comments for counterValue, histogramCount, and resolution. State the expected metric shape and label behavior.

As per coding guidelines, “Add or improve TSDoc comments on code you touch.”

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/routes/data/manifest-resolution-metrics.test.ts` around lines 14 - 49,
Add TSDoc comments to the counterValue, histogramCount, and resolution helpers.
Document the expected metric data shape, how label filters are matched, the
fallback value when no metric matches, and that resolution creates a default
ManifestResolution with optional field overrides.

Source: Coding guidelines

src/metrics.ts (1)

1728-1732: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Keep operational metric documentation in help.

Remove the comments that duplicate each metric’s operational behavior. Keep only code-local context that the help field cannot express. Based on learnings, Prometheus metrics in src/metrics.ts must use their help field as operational documentation and must not duplicate that purpose in comments or TSDoc.

Also applies to: 1739-1748

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/metrics.ts` around lines 1728 - 1732, Remove the operational behavior
comments adjacent to the manifest path resolution metrics, including the related
block around the additional referenced lines, while preserving any code-local
context that is not expressible through the metrics’ help fields. Keep the
metric definitions and their help values unchanged.

Source: Learnings

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@src/metrics.ts`:
- Around line 1728-1732: Remove the operational behavior comments adjacent to
the manifest path resolution metrics, including the related block around the
additional referenced lines, while preserving any code-local context that is not
expressible through the metrics’ help fields. Keep the metric definitions and
their help values unchanged.

In `@src/routes/data/handlers.ts`:
- Around line 1384-1414: Replace the line-comment block above
recordManifestResolutionMetrics with a TSDoc comment. Document the function’s
purpose, the source, resolution, manifestPath, and durationMs inputs, and
clarify that unresolved root paths increment the corresponding metric.

In `@src/routes/data/manifest-resolution-metrics.test.ts`:
- Around line 14-49: Add TSDoc comments to the counterValue, histogramCount, and
resolution helpers. Document the expected metric data shape, how label filters
are matched, the fallback value when no metric matches, and that resolution
creates a default ManifestResolution with optional field overrides.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 6b056a44-295d-478a-b234-2eef086f9834

📥 Commits

Reviewing files that changed from the base of the PR and between 3e81d66 and 18c6688.

📒 Files selected for processing (3)
  • src/metrics.ts
  • src/routes/data/handlers.ts
  • src/routes/data/manifest-resolution-metrics.test.ts

vilenarios added a commit that referenced this pull request Aug 5, 2026
Addresses CodeRabbit review on #835:
- Convert the metric-definition comments to `/** */` block form, matching the
  existing convention in metrics.ts (e.g. the optimistic-tx counters). The
  operational context (index-vs-data effectiveness signal, malformed-manifest
  signal) is retained — it is not expressible via the `help` fields alone.
- Add TSDoc to recordManifestResolutionMetrics documenting its inputs.
- Add TSDoc to the counterValue / histogramCount / resolution test helpers.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LPbcF2M3P1XcM8mU8FWEf9
@vilenarios

Copy link
Copy Markdown
Contributor Author

Thanks @coderabbitai — addressed in fac809f:

1. metrics.ts comments — converted the metric-definition comments from // to /** */ block form, matching the existing convention in this file (e.g. the optimisticTx* counters carry multi-line /** */ rationale blocks). I kept the operational context — the index-vs-data effectiveness signal and the malformed-manifest signal — since that's guidance not expressible through the one-line help fields, and it's consistent with how neighboring metrics are documented here.

2. recordManifestResolutionMetrics — replaced the line-comment block with TSDoc documenting source, resolution, manifestPath, and durationMs, including that an unresolved root increments manifest_unresolved_root_total.

3. Test helpers — added TSDoc to counterValue, histogramCount, and resolution describing the prom-client sample shape, label matching, the 0 fallback, and the default resolution.

Lint clean, metrics tests 4/4.

@coderabbitai

coderabbitai Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Tip

For best results, initiate chat on the files or code changes.

@vilenarios Thank you for the update. The documentation changes and test results address the review feedback.

🐇 ✅


If you found this review helpful, would you consider giving us a shout-out on X?

Thank you for using CodeRabbit!

You are interacting with an AI system.

vilenarios and others added 2 commits August 5, 2026 04:46
Instruments the two manifest resolution sites in the data handler:

- `manifest_resolutions_total{source,resolution_type}` — counts resolutions
  split by source (`index` = served from the persistent/cached index without
  parsing the body, vs `data` = on-demand body parse) and how the path
  resolved (path / index / fallback / unresolved). The index-vs-data ratio is
  the effectiveness signal for the resolution index and cache.
- `manifest_unresolved_root_total` — root/index requests that resolved to
  nothing, i.e. a malformed-manifest signal that today only surfaces as a user
  404.
- `manifest_resolution_duration_seconds{source}` — resolution latency by
  source.

`index` is counted only when the index actually determined the outcome
(complete); misses fall through and are counted at the data-parse site.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LPbcF2M3P1XcM8mU8FWEf9
Addresses CodeRabbit review on #835:
- Convert the metric-definition comments to `/** */` block form, matching the
  existing convention in metrics.ts (e.g. the optimistic-tx counters). The
  operational context (index-vs-data effectiveness signal, malformed-manifest
  signal) is retained — it is not expressible via the `help` fields alone.
- Add TSDoc to recordManifestResolutionMetrics documenting its inputs.
- Add TSDoc to the counterValue / histogramCount / resolution test helpers.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LPbcF2M3P1XcM8mU8FWEf9
@vilenarios
vilenarios force-pushed the feat/manifest-resolution-metrics branch from fac809f to 407d9ea Compare August 5, 2026 04:47
@vilenarios
vilenarios merged commit 03b3a76 into develop Aug 10, 2026
4 checks passed
@vilenarios
vilenarios deleted the feat/manifest-resolution-metrics branch August 10, 2026 20:45
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