Skip to content

fix(metrics): a cache refresh's provider calls are not the run's (#1145) - #1147

Merged
egyptiangio merged 1 commit into
devfrom
fix/1145-counter-excludes-cache-refresh
Oct 23, 2026
Merged

egyptiangio merged 1 commit into
devfrom
fix/1145-counter-excludes-cache-refresh

Conversation

@egyptiangio

Copy link
Copy Markdown
Collaborator

The provider call counter behind the run history API Calls column is process-global, so a team/league cache refresh (startup, daily, or the manual button) running alongside a generation added its calls to the run: 1,110 against a normal 480 on a run triggered seconds after a container restart, with espn:teams 352 and espn:groups 93 belonging to the refresh.

  • call_metrics: thread-local exclusion. excluded() context manager for a thread that outlives the work (a scheduler thread must count again afterwards), exclude_current_thread as a ThreadPoolExecutor initializer for worker pools. record_call / record_rate_limit / record_failure return early on an excluded thread.
  • CacheRefresher.refresh runs under excluded(); both of its worker pools carry the initializer.
  • Tests: the block records nothing and resets, pool workers are excluded while the caller still counts, and the refresher's wiring is pinned.

The run-scoped call counter is process-global, so a team/league cache
refresh overlapping a generation was attributed to the run (1,110 calls
against a normal 480 on a run triggered seconds after a restart). The
refresher now runs under call_metrics.excluded() and its two worker pools
mark their threads with exclude_current_thread; the record functions
ignore an excluded thread.
@egyptiangio
egyptiangio merged commit 1a27a05 into dev Oct 23, 2026
8 checks passed
@egyptiangio
egyptiangio deleted the fix/1145-counter-excludes-cache-refresh branch October 23, 2026 18:10
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.

1 participant