Skip to content

feat(telemetry): export admission_control.limit metric#4147

Open
alco wants to merge 3 commits intomainfrom
export-admission-control-limit-metric
Open

feat(telemetry): export admission_control.limit metric#4147
alco wants to merge 3 commits intomainfrom
export-admission-control-limit-metric

Conversation

@alco
Copy link
Copy Markdown
Member

@alco alco commented Apr 21, 2026

vetted by human ready for review

Summary

  • Moves limit from event metadata into measurements in Electric.AdmissionControl for both [:electric, :admission_control, :acquire] and [:electric, :admission_control, :reject] events.
  • Exports two new last_value metrics tagged by :kind in StackTelemetry:
    • electric.admission_control.acquire.limit
    • electric.admission_control.reject.limit
  • With the limit now exported alongside acquire.current, the "Electric — Admission Control" dashboard (stratovolt#1467) can plot fill percentage = acquire.current / acquire.limit per kind.

Closes electric-sql/stratovolt#1471

Test plan

  • mix test in packages/electric-telemetry (99 tests pass)
  • mix test test/electric/admission_control_test.exs in packages/sync-service (11 tests pass)
  • Verify electric.admission_control.acquire.limit and electric.admission_control.reject.limit columns appear in the admin-electric / electric-region datasets on Honeycomb after deploy

🤖 Generated with Claude Code

The limit (configured capacity) is already present in the telemetry
metadata of the :acquire event; add a last_value metric that reads it so
dashboards can plot fill percentage (acquire.current / limit) per kind.

Closes electric-sql/stratovolt#1471

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@alco alco added the claude label Apr 21, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 21, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.37%. Comparing base (388ec63) to head (e163f8f).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4147      +/-   ##
==========================================
- Coverage   89.20%   85.37%   -3.84%     
==========================================
  Files          25       40      +15     
  Lines        2520     3077     +557     
  Branches      636      641       +5     
==========================================
+ Hits         2248     2627     +379     
- Misses        270      448     +178     
  Partials        2        2              
Flag Coverage Δ
electric-telemetry 68.04% <ø> (?)
elixir 68.04% <ø> (?)
packages/experimental 87.73% <ø> (ø)
packages/react-hooks 86.48% <ø> (ø)
packages/start 82.83% <ø> (ø)
packages/typescript-client 94.30% <ø> (ø)
packages/y-electric 56.05% <ø> (ø)
typescript 89.20% <ø> (ø)
unit-tests 85.37% <ø> (-3.84%) ⬇️

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

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

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@claude
Copy link
Copy Markdown

claude Bot commented Apr 21, 2026

Claude Code Review

Summary

This iteration moves limit from event metadata into measurements for both the acquire and reject telemetry events, and adds electric.admission_control.reject.limit alongside the previously added acquire.limit. The structural change is correct and directly resolves the defensive metadata-access concern raised in iteration 2.

What's Working Well

  • Moving limit to measurements is the right model: it's a quantity, not context, and it aligns with how current is already handled in the acquire event.
  • reject.limit as a last_value tagged by :kind is a natural peer to acquire.limit and enables the same fill-percentage calculation for the reject path.
  • Tests updated correctly — assertions now reference measurements.limit instead of metadata.limit for both events.
  • Changeset covers both electric-telemetry and sync-service.

Issues Found

Suggestions (Nice to Have)

No tests for the new metric definitions

Neither electric.admission_control.acquire.limit nor the new electric.admission_control.reject.limit has a test in the electric-telemetry package verifying the metric is wired up and correctly extracts the measurement. The sync-service tests confirm the telemetry event shape is correct, but a telemetry package test would catch regressions if the metric name or extraction logic drifts. Low risk given the simplicity, but worth adding alongside the existing measurement_test.exs pattern.

Issue Conformance

No linked issue is directly accessible (private repo), but the PR description clearly explains the motivation (fill-percentage dashboards, stratovolt#1471) and the implementation matches it completely.

Previous Review Status

  • Metric renamed acquire.limit ✓ (iteration 2)
  • Defensive Map.get(metadata, :limit) suggestion → RESOLVED: limit is now in measurements; the default Telemetry.Metrics key extraction is used (no custom measurement function), so a missing :limit is handled silently at the reporter layer rather than raising a KeyError.
  • Missing test for acquire.limit → still open; now also applies to reject.limit.

Review iteration: 3 | 2026-04-21

alco and others added 2 commits April 22, 2026 01:45
Keep the exported metric name aligned with the event it reads from,
matching the convention used by the other admission_control metrics.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- Move limit from event metadata into measurements in admission_control
  :telemetry.execute/3 calls for both :acquire and :reject events.
- Export electric.admission_control.acquire.limit and reject.limit via
  plain-atom last_value metrics (no 2-arity measurement function needed).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.

1 participant