def bootstrap(name='MicroService'): log_level = logging.DEBUG logger = logging.getLogger('') logging.getLogger('').handlers = [] logging.basicConfig(format='%(asctime)s %(message)s', level=log_level) config = jConfig( config={ # usually read from some yaml config 'sampler': { 'type': 'const', 'param': 1, }, 'logging': True, }, service_name=name, validate=True, metrics_factory=PrometheusMetricsFactory(namespace=name), ) openapi_dict = load_yaml_file() app = App(name, use_tracer=config.initialize_tracer(), use_metric=True, use_optimizer=True, use_cors=True) app.add_api(openapi_dict, resolver=MultipleResourceResolver('api')) # set the WSGI application callable to allow using uWSGI: # uwsgi --http :8080 -w app # start "python Tutorial2.py" and open "http://localhost:8080/v1.0/" app.run(port=int(os.getenv("SERVER_PORT", 8080)))
from connexion_plus import App from connexion.resolver import RestyResolver from jaeger_client import Config as jConfig from jaeger_client.metrics.prometheus import PrometheusMetricsFactory import logging config = jConfig( config={ 'logging': True, }, # use this, if you want to track your tracing itself with prometheus metrics_factory = PrometheusMetricsFactory(namespace=__name__), ) jaeger_tracer = config.initialize_tracer() app = App(__name__, use_tracer=jaeger_tracer, use_metric=True, use_logging_level=logging.DEBUG) app.add_api('openapi.yaml', resolver=RestyResolver('api')) app.run(port=8080, server='gevent')