Skip to content

Conversation

@dkropachev
Copy link
Collaborator

@dkropachev dkropachev commented Jan 31, 2026

Summary

The scales library had its last release in 2015 and was only tested on Python 2.7/3.3. This change replaces it with a self-contained metrics implementation that provides the same functionality:

  • IntStat: Thread-safe integer counter
  • PmfStat: Percentile/distribution statistics with reservoir sampling
  • Stat: Gauge statistics with callable evaluation
  • StatsCollection: Named collections of statistics
  • Global registry for metrics access via getStats()

The new implementation maintains API compatibility with the existing metrics interface used by the driver.

Test plan

  • Unit tests pass (600 passed)
  • Self-contained metrics module tests verified
  • All modified files import correctly
  • Integration tests with metrics enabled

Fixes #665

@dkropachev dkropachev force-pushed the remove-scales-dependency branch 2 times, most recently from d2d6b18 to 9e60f4e Compare February 1, 2026 03:34
@dkropachev dkropachev self-assigned this Feb 1, 2026
The scales library had its last release in 2015 and was only tested on
Python 2.7/3.3. This change replaces it with a self-contained metrics
implementation that provides the same functionality:

- IntStat: Thread-safe integer counter
- PmfStat: Percentile/distribution statistics with reservoir sampling
- Stat: Gauge statistics with callable evaluation
- StatsCollection: Named collections of statistics
- Global registry for metrics access via getStats()

The new implementation maintains API compatibility with the existing
metrics interface used by the driver.

Fixes #665
- Add comparison operators (__eq__, __ne__, __lt__, __le__, __gt__, __ge__)
  to IntStat class for direct comparison with integers
- Add __hash__ method to IntStat for use in sets/dicts
- Add Metrics.shutdown() method to remove stats from global registry
- Call metrics.shutdown() from Cluster.shutdown() to prevent stale
  weakref errors when accessing getStats() after cluster shutdown
- Fix test using 'is' instead of '==' for IntStat comparison
- Add unit tests for new comparison operators and shutdown functionality
@dkropachev dkropachev force-pushed the remove-scales-dependency branch from 9e60f4e to 70d218b Compare February 1, 2026 06:26
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.

Evaluate scales dependency

2 participants