diff --git a/dash-apm-python/step_4.md b/dash-apm-python/step_4.md index 061a0e5..2487846 100644 --- a/dash-apm-python/step_4.md +++ b/dash-apm-python/step_4.md @@ -2,7 +2,7 @@ We can attach our own custom application metadata to spans. Open `frontend/frontend/api.py` file. -Add the following code after the `app = Flask('api')` on line 16. +Add the following code after the `app = Flask('api')`. ``` python @app.before_request diff --git a/dash-apm-python/step_5.md b/dash-apm-python/step_5.md index e69de29..a998e27 100644 --- a/dash-apm-python/step_5.md +++ b/dash-apm-python/step_5.md @@ -0,0 +1,29 @@ +What happens when unexpected exceptions are raised from our application? + +Open `frontend/frontend/api.py` file in the editor. + +Add the following code to the beginning of the `def simulate_sensors` route. + +``` python +maybe_raise_exception() +```{{copy}} + +The end result function should look like: + +``` python +@app.route('/simulate_sensors') +def simulate_sensors(): + maybe_raise_exception() + + app.logger.info('Simulating refresh of sensor data') + resp = requests.get('http://sensors:5002/refresh_sensors') + resp.raise_for_status() + sensors = resp.json() + return jsonify(sensors) +```{{copy}} + +Restart our services `docker-compose up`{{execute interrupt}}. + +Open the `/simulate_sensors` resource page for our `frontend` service. + +https://app.datadoghq.com/apm/service/frontend/flask.request diff --git a/dash-apm-python/step_6.md b/dash-apm-python/step_6.md index e69de29..64e0fa4 100644 --- a/dash-apm-python/step_6.md +++ b/dash-apm-python/step_6.md @@ -0,0 +1,29 @@ +With APM we can easily visualize where latencies are coming from. + +Open `sensors/sensors.py` file in the editor. + +Add the following to the `def refresh_sensors` endpoint. + +```python +time.sleep(2) +```{{copy}} + +When we are done the function should look like: + +``` python +@app.route('/refresh_sensors') +def refresh_sensors(): + app.logger.info('Calling refresh sensor simulator') + sensors = simulate_all_sensors() + + time.sleep(2) + + return jsonify({'sensor_count': len(sensors), + 'system_status': sensors}) +```{{copy}} + +Restart our services `docker-compose up`{{execute interrupt}} + +Open the service page for our `frontend` service. + +https://app.datadoghq.com/apm/service/frontend/flask.request