Skip to main content

Connexion with benefits for microservices

Project description

Connexion with benefits for microservices.

Connexion Plus

If you want to use Connexion for your microservice, you have to add an opentracing or prometheus client on your own. With this library, you instantiate everything before your connexion app starts and this library will take care to put it all together, so you get everything fine.

If you want to know more about the used libraries, please go to the corresponding documentaries.

Dependencies

[Connexion](https://github.com/zalando/connexion)
[opentracing-python-instrumentation](https://github.com/uber-common/opentracing-python-instrumentation)
[Flask-Opentracing](https://github.com/opentracing-contrib/python-flask)
[jaeger-client](https://pypi.org/project/jaeger-client/)
[requests](https://pypi.org/project/requests/)
[prometheus-flask-exporter](https://pypi.org/project/prometheus-flask-exporter/)

Importing

import connexion_plus as conn

OpenTracing / Jaeger-Client

Currently, all opentracing implementation (e.g. jaeger-client) are supported for tracing. If you want to use it, you have to initialize the client before you start your connexion app and give it via the tracer-parameter to the connexion_plus Factory, where the magic happens.

The following example uses jaeger-client (pip install jaeger-client) implementation.

import connexion_plus as conn
from jaeger_client import Config as jConfig

config = jConfig(
        config={
            'logging': True,
        },
    )
jaeger_tracer = config.initialize_tracer()

app = connexion.App(__name__)
conn.addServices(app, use_tracer=jaeger_tracer)

Prometheus / Metrics

Currently, it is only the prometheus-flask-exporter supported for connexion, so only for flask connexion. You only have to set the metrics-parameter to True

import connexion_plus

app = connexion.App(__name__)
conn.addServices(app, use_metric=True)

Example

If you want to use tracer and metrics together, see here a complete example. This currently works only with flask (see prometheus)

import connexion_plus
from jaeger_client import Config as jConfig
from jaeger_client.metrics.prometheus import PrometheusMetricsFactory

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 = connexion.App(__name__)
conn.addServices(app, use_tracer=jaeger_tracer, use_metric=True)

If you add the line metrics_factory=PrometheusMetricsFactory(namespace='yourAppName') to your jaeger-client-config, you get the metrics out of jaeger to your flask app.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

connexion-plus-0.5.tar.gz (2.8 kB view hashes)

Uploaded Source

Built Distribution

connexion_plus-0.5-py3-none-any.whl (3.6 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page