Skip to content

refactor: replay metrics come from spans, and ReplayMetrics is gone - #401

Merged
HardMax71 merged 1 commit into
mainfrom
refactor/replay-metrics-from-spans
Oct 18, 2026
Merged

HardMax71 merged 1 commit into
mainfrom
refactor/replay-metrics-from-spans

Conversation

@HardMax71

@HardMax71 HardMax71 commented Oct 18, 2026 •

Copy link
Copy Markdown
Owner

Summary

Part of #389, the replay area, and fixes #318: the replay queue size gauge carried a session_id label, so every session left its own series behind. The fifteen instruments in ReplayMetrics now come from spans.

Changes

EventReplayService leaves a span where it used to record each metric: replay.session_created, replay.session_started, replay.status_change, replay.event, replay.batch, replay.session_completed and replay.target. The collector's signaltometrics connector turns them into the same series. The API's scheduler gets one more job: every 10 s report_sessions reports the sessions held per status, zeros included, and the loaded events still to send, summed over sessions. replay_sessions_active goes, since running plus paused from the per-status gauge is the same number, and the dashboard panel now sums those. Labels take the span attribute names (replay_status, replay_target, ...).

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update
  • Refactoring (no functional changes)
  • CI/CD or tooling changes

Test Plan

  • Backend unit tests pass (cd backend && uv run pytest tests/unit)
  • Frontend unit tests pass (cd frontend && npm run test)
  • Backend E2E tests pass (docker compose exec -T backend sh -c 'uv sync --group test --no-dev --frozen --no-install-project --no-build && pytest tests/e2e')
  • Frontend E2E tests pass (cd frontend && npm run test:e2e)
  • API spec and client regenerated if routes or schemas changed (./deploy.sh openapi, then ./deploy.sh types), never edited by hand
  • Manual testing performed

Validation: unit 570 passed, contract 3 passed, e2e 488 passed and 1 skipped. Four real sessions run from the API container gave exactly the expected totals at the collector (4 created, 4 batches of 10, speed multipliers summing to 398). Duration and throughput are only unit-tested: no live session could complete, since main's dispatch job skips its own next run when the delay is short.

Checklist

  • My code follows the project's style guidelines
  • I have run pre-commit run --all-files and all checks pass
  • I have added tests that prove my fix/feature works
  • I have updated documentation if needed
  • My changes don't introduce new warnings

Summary by cubic

Moves replay metrics from the ReplayMetrics instruments to spans that the collector's signaltometrics connector turns into the same series, deleting ReplayMetrics as part of #389. Fixes #318 by dropping the session_id label from the queue size gauge, which had created a series per session.

  • EventReplayService now records replay.session_created, replay.session_started, replay.status_change, replay.event, replay.batch, replay.session_completed, and replay.target spans.
  • The API scheduler runs report_sessions every 10 s to report sessions per status (zeros included) and loaded events still to send.
  • replay_sessions_active is gone; the dashboard panel sums running and paused from the per-status gauge instead.
  • Labels use the span attribute names (replay_status, replay_target, ...).

Written for commit a56db99. Summary will update on new commits.

View guided diff Turn on auto-fix

EventReplayService leaves a span where it used to record each metric (replay.session_created, replay.session_started, replay.status_change, replay.event, replay.batch, replay.session_completed, replay.target), and the API's scheduler runs report_sessions every 10 s for the sessions per status and the loaded events still to send. The queue size gauge loses its session_id label (fixes #318), and the active sessions panel sums running and paused from the per-status gauge instead of a separate counter. Part of #389.
@HardMax71
HardMax71 enabled auto-merge (squash) October 18, 2026 23:36
@coderabbitai

coderabbitai Bot commented Oct 18, 2026

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: b0a39ccb-5adb-419b-a903-4b6f21fa59a9
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

@github-actions github-actions Bot added documentation Improvements or additions to documentation area: events Kafka consumers and middlewares, producer, idempotency, DLQ, replay area: observability Metrics, dashboards, alerts, logs, traces, OTel collector labels Oct 18, 2026
@sonarqubecloud

Copy link
Copy Markdown

@codecov-commenter

codecov-commenter commented Oct 18, 2026 •

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 97.82609% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...ackend/app/services/event_replay/replay_service.py 97.43% 1 Missing ⚠️
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.
Flag Coverage Δ
backend-e2e 82.77% <86.95%> (-0.14%) ⬇️
backend-unit 73.88% <69.56%> (+0.66%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
backend/app/core/dishka_lifespan.py 100.00% <100.00%> (ø)
backend/app/core/metrics/__init__.py 100.00% <ø> (ø)
backend/app/core/providers.py 95.43% <ø> (-0.06%) ⬇️
...ackend/app/services/event_replay/replay_service.py 85.66% <97.43%> (+4.06%) ⬆️

... and 2 files with indirect coverage changes

Components Coverage Δ
Backend 92.15% <97.82%> (+0.03%) ⬆️
Frontend 92.60% <ø> (ø)
🚀 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.

@HardMax71
HardMax71 merged commit 13094a3 into main Oct 18, 2026
21 checks passed
@HardMax71
HardMax71 deleted the refactor/replay-metrics-from-spans branch October 18, 2026 23:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: events Kafka consumers and middlewares, producer, idempotency, DLQ, replay area: observability Metrics, dashboards, alerts, logs, traces, OTel collector documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: replay queue metric keeps an attribute and a series for every replay session

2 participants