Skip to content

gabloe/opencensus-python

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

OpenCensus Flask Integration

pypi

Installation

pip install opencensus-ext-flask

Usage

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 for a complete reference.

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

References

About

A stats collection and distributed tracing framework

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 100.0%