O'Reilly logo

Kubernetes for Developers by Joseph Heck

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Add the libraries and code to generate traces

We start by adding two libraries for the tracing to our project: jaeger-client and flask_opentracing. flask-opentracing adds tracing into Flask projects so that you can easily have all HTTP endpoints traced automatically. The OpenTracing project doesn't include any collectors, so we also need a library to collect and send the trace data somewhere, in this case, jaeger-client.

The example also adds the requests library, as in this example we will add an HTTP endpoint that makes a remote request, processes the responses, and returns the values—and add tracing to that sequence.

Importing the libraries and initializing the tracer is fairly straightforward:

import opentracingfrom jaeger_client import ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required