<commit_before>.. highlight:: python

.. module:: cantal_tools


Modules Reference
=================

This is the reference of ``cantal_tools`` package modules.

.. _wsgi metrics:

WSGI metrics
------------

werkzeug_serving
~~~~~~~~~~~~~~~~

.. currentmodule:: cantal_tools.werkzeug_serving

Module provides wrapper around werkzeug's BaseWSGIServer.


.. class:: CantaledWSGIServer

   Wrapper around ``BaseWSGIServer`` from :mod:`werkzeug.serving`

   Usage::

      import cantal
      from cantal_tools import werkzeug_serving

      cantal.start()

      werkzeug_serving.CantaledWSGIServer(
          host='0.0.0.0',
          port=8080,
          ).server_forever()

----

.. _web metrics:

Web metrics
-----------

flask
~~~~~

.. currentmodule:: cantal_tools.flask

Module provides Flask application mixin overriding several methods
for request tracing.

.. class:: FlaskMixin

   Mixin overriding internal application's methods

   :param metrics: Metrics instance

   Usage::

      import flask
      import cantal
      from cantal_tools.flask import FlaskMixin

      class App(FlaskMixin, flask.Flask):
          pass

      cantal.start()

      app = App(__name__)
      app.run()

----

.. _appflow metrics:

Appflow metrics
---------------

redis
~~~~~

.. currentmodule:: cantal_tools.redis

This module provides ``patch_redis`` function and a custom ``Connection`` class:

.. function:: patch_redis(Redis)

   patches ``execute_command`` method of supplied Redis class

   Usage::

      import cantal
      import redis
      from cantal_tools.redis import patch_redis

       cantal.start()

       patch_redis(redis.Redis)
       client = Redis(host='localhost', port=6379)
       client.get('some-key')


If you don't like monkey-patching you can use the following connection class,
however you'd need to instantiate :class:`redis.ConnectionPool` yourself.

.. class:: CantaledConnection

   Wrapper around :class:`redis.Connection`

----

elasticsearch
~~~~~~~~~~~~~

.. currentmodule:: cantal_tools.elasticsearch

.. class:: CantaledTransport
<commit_msg>Fix indentation in redis usage example<commit_after>.. highlight:: python

.. module:: cantal_tools


Modules Reference
=================

This is the reference of ``cantal_tools`` package modules.

.. _wsgi metrics:

WSGI metrics
------------

werkzeug_serving
~~~~~~~~~~~~~~~~

.. currentmodule:: cantal_tools.werkzeug_serving

Module provides wrapper around werkzeug's BaseWSGIServer.


.. class:: CantaledWSGIServer

   Wrapper around ``BaseWSGIServer`` from :mod:`werkzeug.serving`

   Usage::

      import cantal
      from cantal_tools import werkzeug_serving

      cantal.start()

      werkzeug_serving.CantaledWSGIServer(
          host='0.0.0.0',
          port=8080,
          ).server_forever()

----

.. _web metrics:

Web metrics
-----------

flask
~~~~~

.. currentmodule:: cantal_tools.flask

Module provides Flask application mixin overriding several methods
for request tracing.

.. class:: FlaskMixin

   Mixin overriding internal application's methods

   :param metrics: Metrics instance

   Usage::

      import flask
      import cantal
      from cantal_tools.flask import FlaskMixin

      class App(FlaskMixin, flask.Flask):
          pass

      cantal.start()

      app = App(__name__)
      app.run()

----

.. _appflow metrics:

Appflow metrics
---------------

redis
~~~~~

.. currentmodule:: cantal_tools.redis

This module provides ``patch_redis`` function and a custom ``Connection`` class:

.. function:: patch_redis(Redis)

   patches ``execute_command`` method of supplied Redis class

   Usage::

      import cantal
      import redis
      from cantal_tools.redis import patch_redis

      cantal.start()

      patch_redis(redis.Redis)
      client = Redis(host='localhost', port=6379)
      client.get('some-key')


If you don't like monkey-patching you can use the following connection class,
however you'd need to instantiate :class:`redis.ConnectionPool` yourself.

.. class:: CantaledConnection

   Wrapper around :class:`redis.Connection`

----

elasticsearch
~~~~~~~~~~~~~

.. currentmodule:: cantal_tools.elasticsearch

.. class:: CantaledTransport

{'fraction_non_alphanumeric': 0.13189964157706094, 'fraction_numerical': 0.005734767025089606, 'mean_word_length': 3.0172744721689058, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4776238', 'n_tokens_mistral': 1310, 'n_tokens_neox': 1223, 'n_words': 331}