Skip to content

fix: validate exporter counter ranges#3948

Open
pinehill99 wants to merge 3 commits into
orchestration-agent:mainfrom
pinehill99:patch-17
Open

fix: validate exporter counter ranges#3948
pinehill99 wants to merge 3 commits into
orchestration-agent:mainfrom
pinehill99:patch-17

Conversation

@pinehill99
Copy link
Copy Markdown

Fixes #3846

Summary

  • add optional MetricsCollector.snapshot(max_counter_value=...) validation for exporter-facing counter range limits
  • preserve unrestricted Python integer counters for normal in-memory collection when no exporter limit is requested
  • raise OverflowError with the metric name before an exporter snapshot can expose an out-of-range counter
  • use RLock so timer snapshot tests do not deadlock when stop_timer() records an observation
  • export the existing AgentStatus symbol so the repository's current full test suite collects

Scope and overlap

The issue asks for optional max counter validation for exporter mode. This implementation keeps the limit at the snapshot/export boundary instead of rejecting or capping normal in-memory increments, which preserves existing collector behavior while protecting exporter-facing snapshots.

Current overlap checked on 2026-05-25 KST: issue #3846 is open and has two matching open PRs, #3847 and #3878. #3847 appears to use a constructor/increment-time max_counter_value style guard; #3878 caps counters and exposes max metadata. This PR intentionally competes with a snapshot/export-boundary implementation.

Validation

  • RED: python3 -m pytest tests/test_metrics.py::TestMetricsCollector::test_snapshot_rejects_counter_above_export_limit -q failed before implementation with TypeError: MetricsCollector.snapshot() got an unexpected keyword argument 'max_counter_value'
  • python3 -m pytest tests/test_metrics.py -q -> 6 passed
  • python3 -m pytest tests/test_metrics.py tests/test_config.py tests/test_agent_registry.py -q -> 19 passed
  • python3 -m pytest tests -q -> 24 passed
  • uv run flake8 src/agent/__init__.py src/common/metrics.py tests/test_metrics.py -> passed with pyproject dev-dependencies deprecation warning only
  • python3 -m py_compile src/agent/__init__.py src/common/metrics.py tests/test_metrics.py -> passed
  • git diff --check -> passed

Risk control

Initial web commit for orchestration-agent#3846 exporter snapshot range validation; remaining files will be added before opening the PR.
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.

[ Bounty $4k ] [ Metrics ] Handle exporter counter range limits — large counters

1 participant