Browse Source

update steps

master
Brett Langdon 7 years ago
parent
commit
e49fe2f5a9
No known key found for this signature in database GPG Key ID: E6600FB894DB3D19
9 changed files with 57 additions and 58 deletions
  1. +6
    -0
      dash-apm-python/background.sh
  2. +12
    -2
      dash-apm-python/index.json
  3. +7
    -0
      dash-apm-python/step_11.md
  4. +5
    -0
      dash-apm-python/step_12.md
  5. +3
    -3
      dash-apm-python/step_4.md
  6. +5
    -26
      dash-apm-python/step_5.md
  7. +7
    -0
      dash-apm-python/step_5_background.sh
  8. +5
    -27
      dash-apm-python/step_6.md
  9. +7
    -0
      dash-apm-python/step_6_background.sh

+ 6
- 0
dash-apm-python/background.sh View File

@ -1,6 +1,12 @@
#!/usr/bin/env bash
# Setup workshop code
mkdir /tracing-workshop
git clone https://github.com/brettlangdon/distributed-tracing-with-apm-workshop /tracing-workshop
cd /tracing-workshop
# Try to install yaml_cli helper
(cd /tmp/ && git clone https://github.com/Gallore/yaml_cli && cd ./yaml_cli && python setup.py install) || true
# Start pulling containers as soon as they load
docker-compose pull

+ 12
- 2
dash-apm-python/index.json View File

@ -21,11 +21,13 @@
},
{
"title": "Introducing errors",
"text": "step_5.md"
"text": "step_5.md",
"courseData": "step_5_background.sh"
},
{
"title": "Introducing latencies",
"text": "step_6.md"
"text": "step_6.md",
"courseData": "step_6_background.sh"
},
{
"title": "Enable trace and logs",
@ -42,6 +44,14 @@
{
"title": "Setup custom dashboard",
"text": "step_10.md"
},
{
"title": "Introducing failures",
"text": "step_11.md"
},
{
"title": "Restart stopped service",
"text": "step_12.md"
}
],
"intro": {


+ 7
- 0
dash-apm-python/step_11.md View File

@ -0,0 +1,7 @@
In this phase we are going to introduce a service failure.
Open a new terminal window and run:
`docker-compose stop pumps`
to cause the `pumps` service to stop.

+ 5
- 0
dash-apm-python/step_12.md View File

@ -0,0 +1,5 @@
Before continuing to the next step please be sure to restart the `pumps` service.
`docker-compose start pumps`.
You may close the new terminal window you have opened in the previous step.

+ 3
- 3
dash-apm-python/step_4.md View File

@ -6,13 +6,13 @@ Add the following code after the `app = Flask('api')`.
``` python
@app.before_request
def add_user_id():
def add_customer_id():
# Get the current user's id
user_id = get_user_id()
customer_id = get_customer_id()
# Get the current root span (the `flask.request` span)
span = tracer.current_root_span()
span.set_tag('user_id', user_id)
span.set_tag(customer_id', customer_id)
```{{copy}}
`restart-services`{{execute interrupt}}


+ 5
- 26
dash-apm-python/step_5.md View File

@ -1,29 +1,8 @@
What happens when unexpected exceptions are raised from our application?
In this phase we are going to introduce an exception into our application
to see how we can track it down.
Open `frontend/frontend/api.py` file in the editor.
`restart-services`{{execute interrupt}} to continue.
Add the following code to the beginning of the `def simulate_sensors` route.
Open the `frontend` service page to continue.
``` 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-services`{{execute interrupt}}.
Open the `/simulate_sensors` resource page for our `frontend` service.
https://app.datadoghq.com/apm/service/frontend/flask.request
https://app.datadoghq.com/apm/service/frontend

+ 7
- 0
dash-apm-python/step_5_background.sh View File

@ -0,0 +1,7 @@
#!/usr/bin/env bash
command -v yaml_cli > /dev/null && \
yaml_cli -i docker-compose.yml \
-o docker-compose.yml \
--list-append \
-s services:frontend:environment 'WORKSHOP_ADD_ERRORS=true'

+ 5
- 27
dash-apm-python/step_6.md View File

@ -1,30 +1,8 @@
With APM we can easily visualize where latencies are coming from.
In this phase we are going to introduce an latency into our application
to see how we can track it down.
Open `sensors/sensors.py` file in the editor.
`restart-services`{{execute interrupt}} to continue.
Add the following to the `def simulate_all_sensors` function.
Open the `frontend` service page to continue.
```python
db.session.execute('SELECT pg_sleep(2);')
```{{copy}}
When we are done the function should look like:
``` python
@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-services`{{execute interrupt}}
Open the service page for our `frontend` service.
https://app.datadoghq.com/apm/service/frontend/flask.request
https://app.datadoghq.com/apm/service/frontend

+ 7
- 0
dash-apm-python/step_6_background.sh View File

@ -0,0 +1,7 @@
#!/usr/bin/env bash
command -v yaml_cli > /dev/null && \
yaml_cli -i docker-compose.yml \
-o docker-compose.yml \
--list-append \
-s services:sensors:environment 'WORKSHOP_ADD_LATENCY=true'

Loading…
Cancel
Save