API¶
-
class
flask_kadabra.Kadabra(app=None, config=None)¶ This object holds ties the Flask application object to the Kadabra library. Each app object gets its own
Kadabrainstance, which it uses to generate aMetricsCollectorfor each request.Parameters: - app (Flask) – The Flask application object to initialize.
- config (dict) – Dictionary of configuration to use for the
Kadabraclient API. For information on the acceptable values see Configuration.
-
init_app(app, config=None)¶ Configure the application to use Kadabra. Requests will have access to a
MetricsCollectorvia themetricsattribute of Flask’sgobject. You can record metrics anywhere in the context of a request like so:... g.metrics.add_count("userSignup", 1) ...
The metrics object will be closed and sent at the end of the request if any view that handles the request has been annotated with
record_metrics.
-
flask_kadabra.record_metrics(func)¶ Views that are annotated with this decorator will cause any request they handle to send all metrics collected via the Kadabra client API. For example:
@api.route('/') @record_metrics def index(): return 'Hello, world!'
Parameters: func (function) – The view function to decorate.