Skip to content

feat(vanity-gateway): add per-model shadow drop metric#430

Open
FamousDirector wants to merge 1 commit into
mainfrom
jcameron/shadow-drop-metric
Open

feat(vanity-gateway): add per-model shadow drop metric#430
FamousDirector wants to merge 1 commit into
mainfrom
jcameron/shadow-drop-metric

Conversation

@FamousDirector

@FamousDirector FamousDirector commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Why

Dropped shadow dispatches are currently visible only through trace attributes
and a debug log. Operators need a Prometheus counter to distinguish configured
sampling from dispatch loss and identify affected shadow targets.

What changed

  • Added nvcf_ai_api_gateway_shadow_requests_dropped_total.
  • Labeled drops by openai_model_name and bounded reason.
  • Pre-initialized every configured shadow target and reason combination.
  • Recorded multi-target failures against their corresponding target models.
  • Added focused metric coverage and operator documentation.

Customer Release Notes

Not customer visible.

Plan Summary

Not applicable.

Usage

sum by (openai_model_name, reason) (
  rate(nvcf_ai_api_gateway_shadow_requests_dropped_total[5m])
)

Testing

  • go test ./gateway
  • bazel run //:gazelle
  • bazel mod tidy
  • bazel test //gateway:gateway_test
  • bazel test //... --flaky_test_attempts=3

All passed. No additional QA required.

Notes

openai_model_name identifies the configured shadow target. The label adds
three bounded reason series per configured target.

References

Closes #428

Related Merge Requests/Pull Requests

None.

Dependencies

No new or updated dependency versions. go.opentelemetry.io/otel/metric
v1.43.0 was already present indirectly and is now a direct dependency.

Summary by CodeRabbit

  • New Features

    • Added Prometheus metrics for shadow request dispatches dropped before replay.
    • Metrics identify the target model and drop reason, including body read errors, body rewrite errors, and concurrency limits.
    • Metrics are initialized and recorded for configured shadow targets.
  • Documentation

    • Documented the new shadow-drop metric and its labels.
  • Tests

    • Added coverage verifying metric initialization and per-model, per-reason counts.

Expose dropped shadow dispatches by target model and bounded reason, with zero-initialized series for configured targets.

Refs: #428
@coderabbitai

coderabbitai Bot commented Jul 24, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: f6aab288-4612-4145-a7af-41866943e498

📥 Commits

Reviewing files that changed from the base of the PR and between cdde9cc and f031740.

📒 Files selected for processing (9)
  • src/invocation-plane-services/vanity-gateway/MODULE.bazel
  • src/invocation-plane-services/vanity-gateway/README.md
  • src/invocation-plane-services/vanity-gateway/gateway/BUILD.bazel
  • src/invocation-plane-services/vanity-gateway/gateway/gateway.go
  • src/invocation-plane-services/vanity-gateway/gateway/openai_director.go
  • src/invocation-plane-services/vanity-gateway/gateway/shadow.go
  • src/invocation-plane-services/vanity-gateway/gateway/shadow_metrics.go
  • src/invocation-plane-services/vanity-gateway/gateway/shadow_metrics_test.go
  • src/invocation-plane-services/vanity-gateway/go.mod

📝 Walkthrough

Walkthrough

The vanity gateway now exposes an OpenTelemetry counter for dropped shadow dispatches, labeled by target model and drop reason. Metrics are initialized during model mapping, recorded during shadow dispatch summaries, documented, wired into Bazel, and covered by focused tests.

Changes

Shadow Drop Metrics

Layer / File(s) Summary
Metric implementation
src/invocation-plane-services/vanity-gateway/gateway/shadow_metrics.go
Defines the counter, drop-reason labels, initialization, OpenTelemetry setup, and per-model recording helpers.
Gateway integration
src/invocation-plane-services/vanity-gateway/gateway/gateway.go, src/invocation-plane-services/vanity-gateway/gateway/openai_director.go, src/invocation-plane-services/vanity-gateway/gateway/shadow.go, src/invocation-plane-services/vanity-gateway/gateway/BUILD.bazel, src/invocation-plane-services/vanity-gateway/go.mod, src/invocation-plane-services/vanity-gateway/MODULE.bazel, src/invocation-plane-services/vanity-gateway/README.md
Initializes metrics during gateway startup and model mapping, records drops during shadow dispatch summaries, adds build dependencies, and documents the metric labels and reasons.
Metric validation
src/invocation-plane-services/vanity-gateway/gateway/shadow_metrics_test.go
Uses a manual OpenTelemetry reader to verify initialized and incremented values for each model and drop reason.

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

Sequence Diagram(s)

sequenceDiagram
  participant NVCFGateway
  participant buildModelMapping
  participant recordShadowDispatchSummary
  participant shadowDroppedCounter
  NVCFGateway->>NVCFGateway: setupShadowMetrics()
  buildModelMapping->>shadowDroppedCounter: initializeShadowDropMetrics(target models)
  recordShadowDispatchSummary->>shadowDroppedCounter: recordShadowDropMetrics(reasons, target models)
  shadowDroppedCounter-->>recordShadowDispatchSummary: increment labeled counters
Loading
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. 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 follows Conventional Commits and accurately describes the main feature added to vanity-gateway.
Linked Issues check ✅ Passed The PR meets the metric, labeling, pre-initialization, per-model increment, multi-target, and test requirements from #428.
Out of Scope Changes check ✅ Passed The dependency, build, and README updates support the new shadow-drop metric and do not appear unrelated.
✨ 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 jcameron/shadow-drop-metric

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 golangci-lint (2.12.2)

level=error msg="[linters_context] typechecking error: pattern ./...: directory prefix . does not contain main module or its selected dependencies"


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

@FamousDirector
FamousDirector marked this pull request as ready for review July 24, 2026 19:28
@FamousDirector
FamousDirector requested a review from a team as a code owner July 24, 2026 19:28
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.

feat(vanity-gateway): expose dropped shadow request metric

2 participants