semvec/pypi-packages huggingface dataset:
probcount 0.1
A simple probabilistic counter.

=========================
 Probabilistic Counter
=========================

A simple and efficient probabilistic counter, suited for rate limiting and counting efficiently, without uploading every action to the remote database.

Usage
=============


Instructions
------------

.. code:: python

  from probcount import ProbCounter
  from functools import partial

  pc = ProbCounter()

  def old_increase_function(counter_name, value):
      # run the real call to the DB increasing the counter
      # for a redis
      # return redis.Redis().incrby(name=counter_name, amount=value)
      # or a MongoDB
      # return (pymongo.MongoClient().database_name.collection_name.find_one_and_update({"_id": counter_name},
                                                                                        {"$inc": {"value": value}},
                                                                                        {"value": 1}).get("value", 0) + value)
      pass

  def old_get_function(counter_name):
      # run the real call to the DB increasing the counter
      # for a redis
      # redis.Redis().get(name=counter_name)
      # or a MongoDB
      # pymongo.MongoClient().database_name.collection_name.find_one({"_id": counter_name}, {"value": 1}).value
      pass


  pc.create("name_of_counter", partial(old_increase_function, "name_of_counter"), partial(old_get_function, "name_of_counter"))
  pc.inc("name_of_counter", 42.0)
  pc.get("name_of_counter")


Supported Python Versions
=========================

Python Project Template supports the following versions out of the box:

* CPython 2.6, 2.7, 3.3, 3.4, 3.5, 3.6, 3.7
* PyPy 1.9

Authors
=======

* Tudor Aursulesei
metricz 0.1.5.3
Metricz makes it easy to write metrics to a Kairosdb instance running with OAuth2 security.
Keywords: metricz

===============================
Metricz
===============================

Metricz makes it easy to write metrics to a Kairosdb instance running with OAuth2 security.


Features
--------

* OAuth2 support.
* Option to batch write metrics at a later time.

Usage
-----

To simply write a metric:

.. code-block:: python

    from metricz import MetricWriter

    mw = MetricWriter(directory='/path/to/credentials/dir)

    mw.write_metric('some.metric.name', 123, {'some': 'tag'})

To write a metric with a custom timestamp:

.. code-block:: python

    import datetime

    # Make sure this is in UTC.
    timestamp = datetime.datetime(1981, 10, 26, 6, 24)

    mw.write_metric('some.metric.name', 34, {'some': 'tag'}, timestamp)


To batch write metrics:

.. code-block:: python

    # These are NOT written directly.
    mw.defer_metric('some.metric.name', 42, {'some': 'tag'})
    mw.defer_metric('some.other.metric.name', 64, {'some': 'tag'})
    mw.defer_metric('some.other.metric.name', 64, {'some': 'tag'})

    # Write all deferred metrics at once.
    mw.write_deferred()

TODO
----

* Retry on failure.
* Look at non-blocking options to write.


=======
History
=======

0.1.0 (2016-08-03)
------------------

* First release on PyPI.