Skip to content

Remove MCP metrics merge residue from request counting - #2044

Open
groupthinking with Copilot wants to merge 2 commits into
mainfrom
copilot/remove-merge-residue
Open

groupthinking with Copilot wants to merge 2 commits into
mainfrom
copilot/remove-merge-residue

Conversation

Copilot AI commented Sep 18, 2026

Copy link
Copy Markdown
Contributor

Canonical issue

Canonical issue linkage is handled by the system.

Outcome

Request metrics now count each HTTP request once, emit valid labeled Prometheus lines, and expose a stable X-Request-Count header derived from the application request tracker.

Scope

  • Included:
    • Metrics middleware
      • stop incrementing both labeled and bare requests_total for the same request
      • record request count once at the middleware boundary
      • set X-Request-Count from application_checker.request_count
    • Counter cleanup
      • remove route-level requests_total increments from markdown endpoints that were double-counting requests already covered by middleware
    • Regression coverage
      • add a focused middleware test for labeled requests_total emission and monotonic X-Request-Count
    • Example
      req_key = f'requests_total{{method="{method}",endpoint="{endpoint}",status="{status_str}"}}'
      _safe_increment(health_service, req_key, 1.0)
      response.headers["X-Request-Count"] = str(request_count)
  • Explicitly excluded:
    • unrelated health-monitoring warnings
    • broader metrics model changes beyond the duplicate request-counter residue

Risk

  • Risk level: low
  • Failure mode:
    • request-count headers stop advancing if the health service is unavailable
    • downstream code depending on the duplicate bare requests_total inflation would observe lower, correct counts
  • Rollback:
    • revert the middleware/header change and restore the removed route-level increments

Verification

Exact checks on head 33cf0e85b2e9a91aeb7ba0654be25766806000a9.

  • Focused tests
    • PYTHONPATH=src python -m pytest tests/unit/test_middleware.py tests/unit/test_health_monitoring_service.py tests/unit/test_health_monitoring_extra.py tests/unit/test_v1_router_extended.py -k 'PrometheusMetricsMiddleware or IncrementMetric or GetMetricsPrometheusFormat or get_metrics_prometheus or MetricsEndpoint' --no-cov -q
    • manual metrics rendering check produced uvai_requests_total{method="GET",endpoint="/test",status="200"} 1.0
  • Required CI
  • Review threads resolved

Production evidence

Not applicable for this change set. This is backend request-metrics behavior with unit-level and direct runtime verification only; no Vercel preview or production deployment evidence was generated in-session.

Agent handoff

  • One canonical issue is linked
  • No competing PR implements the same issue
  • Acceptance criteria are satisfied
  • Required checks pass on the current head
  • Human decision is requested only for product, security, irreversible infrastructure, or production approval

@coderabbitai

coderabbitai Bot commented Sep 18, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository: groupthinking/EventRelay/.coderabbit.yaml

Review profile: ASSERTIVE

Plan: Advanced

Run ID: 2cf049dd-fe00-4302-830b-e01f4da6ade2

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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.

Co-authored-by: groupthinking <154503486+groupthinking@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix MCP integration service to eliminate duplicate request counters Remove MCP metrics merge residue from request counting Sep 18, 2026
@vercel

vercel Bot commented Sep 18, 2026

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
v0-uvai Ready Ready Preview, v0 Sep 18, 2026 9:43pm UTC

@github-actions

github-actions Bot commented Sep 18, 2026

Copy link
Copy Markdown
Contributor

Dependency Review Summary

The full dependency review summary was too large to display here (13153KB, limit is 1024KB).

Please download the artifact named "dependency-review-summary" to view the complete report.

View full job summary

@github-actions

Copy link
Copy Markdown
Contributor

🔍 PR Validation

⚠️ PR title should follow conventional commits format

@groupthinking
groupthinking marked this pull request as ready for review September 19, 2026 00:04
Copilot AI balanced review requested due to automatic review settings September 19, 2026 00:04

Copilot AI 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.

Copilot review overview

🟡 Changes recommended

The canonical application does not install the metrics middleware, so the v1 route loses request metrics entirely.

Get a fresh assessment by requesting another Copilot review.

Review effort: Balanced
Findings: 1 Medium severity

Open (1)
What changed in this PR

Updates backend request metrics to avoid duplicate counters and expose request counts.

Changes:

  • Centralizes request counting in metrics middleware.
  • Removes route-level duplicate increments.
  • Adds middleware regression coverage.
File Description
tests/​unit/​test_middleware.py Tests labeled metrics and request-count headers.
src/​youtube_extension/​backend/​middleware/​metrics.py Records requests once and sets the count header.
src/​youtube_extension/​backend/​main.py Removes legacy route-level counting.
src/​youtube_extension/​backend/​api/​v1/​router.py Removes v1 markdown route counting.

💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@@ -781,7 +781,6 @@ async def process_video_markdown_v1(
status_code=status.HTTP_429_TOO_MANY_REQUESTS, detail="Rate limit exceeded"
)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Remove merge residue from MCP integration service

3 participants