From 0d1e9734e2734790701997371e61847129d1df9a Mon Sep 17 00:00:00 2001 From: brettlangdon Date: Thu, 11 Jul 2019 16:33:24 -0400 Subject: [PATCH] fix up steps --- dash-apm-python/step_3.md | 2 +- dash-apm-python/step_4.md | 2 +- dash-apm-python/step_6.md | 23 ++++++++++++----------- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/dash-apm-python/step_3.md b/dash-apm-python/step_3.md index b265668..fe77d5c 100644 --- a/dash-apm-python/step_3.md +++ b/dash-apm-python/step_3.md @@ -1,7 +1,7 @@ Add the following environment variable to the `frontend`, `node`, `pumps`, and `sensors` services in `docker-compose.yml`. -`DD_ANALYTICS_ENABLED=true`{{copy}} +`DD_TRACE_ANALYTICS_ENABLED=true`{{copy}} Our services should look like: diff --git a/dash-apm-python/step_4.md b/dash-apm-python/step_4.md index 2487846..17eb09b 100644 --- a/dash-apm-python/step_4.md +++ b/dash-apm-python/step_4.md @@ -19,4 +19,4 @@ Restart services `docker-compose up`{{execute interrupt}} Finally, open the service page for `frontend` to view the new metadata on traces. -https://app.datadoghq.com/apm/resource/frontend/flask.request/ +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 64e0fa4..22b0d64 100644 --- a/dash-apm-python/step_6.md +++ b/dash-apm-python/step_6.md @@ -2,24 +2,25 @@ 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. +Add the following to the `def simulate_all_sensors` function. ```python -time.sleep(2) +db.session.execute('SELECT pg_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}) +@tracer.wrap(name='sensor-simulator') +def simulate_all_sensors(): + db.session.execute('SELECT pg_sleep(2);') + sensors = Sensor.query.all() + for sensor in sensors: + sensor.value = random.randint(1,100) + db.session.add_all(sensors) + db.session.commit() + app.logger.info('Sensor data updated') + return [s.serialize() for s in sensors] ```{{copy}} Restart our services `docker-compose up`{{execute interrupt}}