OpenTracing Shim Example¶
This example shows how to use the opentelemetry-instrumentation-opentracing-shim package to interact with libraries instrumented with opentracing-python.
rediscache library creates spans via the OpenTracing Redis
Spans are exported via the Jaeger exporter, which is attached to the
The source files required to run this example are available here.
docker run --rm \ -p 6831:6831/udp \ -p 6832:6832/udp \ -p 16686:16686 \ jaegertracing/all-in-one:1.13 \ --log-level=debug
Install Redis following the instructions.
Make sure that the Redis server is running by executing this:
Install the Python dependencies in requirements.txt
pip install -r requirements.txt
Alternatively, you can install the Python dependencies separately:
pip install \ opentelemetry-api \ opentelemetry-sdk \ opentelemetry-exporter-jaeger \ opentelemetry-opentracing-shim \ redis \ redis_opentracing
Run the Application¶
The example script calculates a few Fibonacci numbers and stores the results in
Redis. The script, the
rediscache library, and the OpenTracing Redis
integration all contribute spans to the trace.
To run the script:
After running, you can view the generated trace in the Jaeger UI.
Open the Jaeger UI in your browser at http://localhost:16686 and view traces for the “OpenTracing Shim Example” service.
main.py run should generate a trace, and each trace should include
multiple spans that represent calls to Redis.
Note that tags and logs (OpenTracing) and attributes and events (OpenTelemetry) from both tracing systems appear in the exported trace.