Skip to content

Remove scales dependency with self-contained metrics implementation#681

Merged
dkropachev merged 2 commits intomasterfrom
remove-scales-dependency
Feb 2, 2026
Merged

Remove scales dependency with self-contained metrics implementation#681
dkropachev merged 2 commits intomasterfrom
remove-scales-dependency

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
@dkropachev dkropachev merged commit e2894fb into master Feb 2, 2026
25 of 26 checks passed
@dkropachev dkropachev deleted the remove-scales-dependency branch February 2, 2026 19:51
@Lorak-mmk
Copy link

Note: Even if API of new classes is the same, this is technically a breaking change, right?
I doubt it will cause problems for anyone, but we should put at least a warning in the changelong anyway.
@dkropachev

# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How could this file be possibly authored by Datastax? Is it taken from some upstream commit we don't yet have?

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

3 participants