Metrics

Common metrics

Cantal-tools provides following metrics:

wsgi

WSGI server group of metrics. Contains the following:

wsgi.idle

Idle time and count of wsgi server;

wsgi.acquire

Duration and number of operations of socket.acquire calls;

wsgi.process

Duration and number requests processed;

wsgi.exception

Duration and number of unhandled exceptions processed;

See WSGI metrics for tools & examples using this metrics.

web

Web framework group of metrisc, as follows:

web.handle_request

Duration and number of requests handled;

web.render_template

Duration and number of templates rendered;

web.handle_exception

Duration and number of exceptions processed;

See Web metrics for tools & examples using this metrics.

appflow

Application level group of metrics. This group of metrics is allowed to extend by developer.

Basic metrics in this group are:

appflow.redis

Duration and number of redis operations;

appflow.sqlalchemy

Duration and number of SqlAlchemy queries;

appflow.elasticsearch

Duration and number of Elasticsearch queries;

See Appflow metrics for tools & examples using this metrics.

Extending common metrics

Existing metrics can be extended with following code:

# my extra appflow metrics
import cantal
import requests
from cantal_tools.metrics import appflow

appflow.ensure_branches('external_http', 'upload_file')
cantal.start()

def handler(request):
   with appflow.external_http.context():
      requests.get('http://some.host/...')
   with appflow.upload_file.context():
      do_file_upload(request.files)

Warning

Custom branches MUST be registered before cantal.start() call.

Custom metrics

Custom metrics are just cantal metrics, please see cantal’s documentation for this.