Revisiting the grocery store
It's finally time to use all this new knowledge about auto-instrumentation to clean up the grocery store application. This section will showcase the simplified code that continues to produce the telemetry we've come to expect over the last few chapters. The custom decorators have been removed, as has the code configuring the tracer provider, meter provider, and log emitter provider. All we're left with now is the application code.
Legacy inventory
The legacy inventory service is a great place to start. It is a small Flask application with a single endpoint. The Flask instrumentor, installed at the beginning of the chapter via the opentelemetry-instrumentation-flask
package, will replace the manual instrumentation code we previously added. The following code instantiates the Flask app and provides the /inventory
endpoint:
legacy_inventory.py
#!/usr/bin/env python3 from flask import Flask, jsonify app = Flask(__name__) @app.route...