semvec/pypi-packages huggingface dataset:
opencensus-ext-fastapi 0.1.0
OpenCensus FastAPI Integration
License: Apache-2.0

OpenCensus FastAPI Integration
============================================================================

|pypi|

.. |pypi| image:: https://badge.fury.io/py/opencensus-ext-fastapi.svg
   :target: https://pypi.org/project/opencensus-ext-fastapi/

Installation
------------

::

    pip install opencensus-ext-fastapi

Usage
-----

.. code:: python

    from fastapi import FastAPI
    from opencensus.ext.fastapi.fastapi_middleware import FastAPIMiddleware

    app = FastAPI(__name__)
    app.add_middleware(FastAPIMiddleware)

    @app.get('/')
    def hello():
        return 'Hello World!'

Additional configuration can be provided, please read
`Customization <https://github.com/census-instrumentation/opencensus-python#customization>`_
for a complete reference.

.. code:: python

    app.add_middleware(
        FastAPIMiddleware,
        excludelist_paths=["paths"],
        excludelist_hostnames=["hostnames"],
        sampler=sampler,
        exporter=exporter,
        propagator=propagator,
    )


References
----------

* `OpenCensus Project <https://opencensus.io/>`_
opencensus-ext-flask 0.8.2
OpenCensus Flask Integration
License: Apache-2.0

OpenCensus Flask Integration
============================================================================

|pypi|

.. |pypi| image:: https://badge.fury.io/py/opencensus-ext-flask.svg
   :target: https://pypi.org/project/opencensus-ext-flask/

Installation
------------

::

    pip install opencensus-ext-flask

Usage
-----

.. code:: python

    from flask import Flask
    from opencensus.ext.flask.flask_middleware import FlaskMiddleware
    
    app = Flask(__name__)
    middleware = FlaskMiddleware(app, excludelist_paths=['_ah/health'])
    
    @app.route('/')
    def hello():
        return 'Hello World!'
    
    if __name__ == '__main__':
        import logging
        logger = logging.getLogger('werkzeug')
        logger.setLevel(logging.ERROR)
        app.run(host='localhost', port=8080, threaded=True)

Additional configuration can be provided, please read
`Customization <https://github.com/census-instrumentation/opencensus-python#customization>`_
for a complete reference.

.. code:: python

    app.config['OPENCENSUS'] = {
        'TRACE': {
            'SAMPLER': 'opencensus.trace.samplers.ProbabilitySampler(rate=1)',
            'EXPORTER': '''opencensus.ext.ocagent.trace_exporter.TraceExporter(
                service_name='foobar',
            )''',
        }
    }

References
----------

* `OpenCensus Project <https://opencensus.io/>`_