diff --git a/dash-apm-python/index.json b/dash-apm-python/index.json index ad1656d..337eb84 100644 --- a/dash-apm-python/index.json +++ b/dash-apm-python/index.json @@ -16,12 +16,28 @@ "text": "step_3.md" }, { - "title": "Enable trace and logs", + "title": "Adding custom metadata", "text": "step_4.md" }, { - "title": "Enable process agent", + "title": "Introducing errors", "text": "step_5.md" + }, + { + "title": "Introducing latencies", + "text": "step_6.md" + }, + { + "title": "Adding manual spans", + "text": "step_7.md" + }, + { + "title": "Enable trace and logs", + "text": "step_8.md" + }, + { + "title": "Enable process agent", + "text": "step_9.md" } ], "intro": { diff --git a/dash-apm-python/step_4.md b/dash-apm-python/step_4.md index 7c1c18e..061a0e5 100644 --- a/dash-apm-python/step_4.md +++ b/dash-apm-python/step_4.md @@ -1,44 +1,22 @@ -# Enable Datadog logs agent +We can attach our own custom application metadata to spans. -Add the following environment variables to the `agent` service in `docker-compose.yml`. +Open `frontend/frontend/api.py` file. -`DD_LOGS_ENABLED=true`{{copy}} -`DD_LOGS_CONFIG_CONTAINER_COLLECT_ALL=true`{{copy}} +Add the following code after the `app = Flask('api')` on line 16. -Our service should look like: +``` python +@app.before_request +def add_user_id(): + # Get the current user's id + user_id = get_user_id() -```yaml -agent: - environment: - - DD_API_KEY - - DD_APM_ENABLED=true - - DD_TAGS='env:apm-workshop' - - DD_LOGS_ENABLED=true - - DD_LOGS_CONFIG_CONTAINER_COLLECT_ALL=true -``` + # Get the current root span (the `flask.request` span) + span = tracer.current_root_span() + span.set_tag('user_id', user_id) +```{{copy}} -# Enable trace id injection into logs +Restart services `docker-compose up`{{execute interrupt}} -Add the following environment variable to the `frontend`, `node`, `pumps`, -and `sensors` services in `docker-compose.yml`. +Finally, open the service page for `frontend` to view the new metadata on traces. -`DD_LOGS_INTEGRATION=true`{{copy}} - -Our services should look like: - -```yaml -frontend: - environment: - - DATADOG_SERVICE_NAME=frontend - - DATADOG_TRACE_AGENT_HOSTNAME=agent - - DD_ANALYTICS_ENABLED=true - - DD_LOGS_INTEGRATION=true -``` - -Afterwards restart docker services: - -`docker-compose up`{{execute interrupt}} - -Finally, open logs dashboard: - -https://app.datadoghq.com/logs +https://app.datadoghq.com/apm/resource/frontend/flask.request/ diff --git a/dash-apm-python/step_5.md b/dash-apm-python/step_5.md index 1300214..e69de29 100644 --- a/dash-apm-python/step_5.md +++ b/dash-apm-python/step_5.md @@ -1,25 +0,0 @@ -To enable the Datadog process agent add the following environment variable -to the `agent` service. - -`DD_PROCESS_AGENT_ENABLED=true`{{copy}}. - -Our service should look like: - -```yaml -agent: - environment: - - DD_API_KEY - - DD_APM_ENABLED=true - - DD_TAGS='env:apm-workshop' - - DD_LOGS_ENABLED=true - - DD_LOGS_CONFIG_CONTAINER_COLLECT_ALL=true - - DD_PROCESS_AGENT_ENABLED=true -``` - -Next, restart our docker services: - -`docker-compose up`{{execute interrupt}} - -Finally, open the process dashboard: - -https://app.datadoghq.com/process diff --git a/dash-apm-python/step_6.md b/dash-apm-python/step_6.md new file mode 100644 index 0000000..e69de29 diff --git a/dash-apm-python/step_7.md b/dash-apm-python/step_7.md new file mode 100644 index 0000000..e69de29 diff --git a/dash-apm-python/step_8.md b/dash-apm-python/step_8.md new file mode 100644 index 0000000..7c1c18e --- /dev/null +++ b/dash-apm-python/step_8.md @@ -0,0 +1,44 @@ +# Enable Datadog logs agent + +Add the following environment variables to the `agent` service in `docker-compose.yml`. + +`DD_LOGS_ENABLED=true`{{copy}} +`DD_LOGS_CONFIG_CONTAINER_COLLECT_ALL=true`{{copy}} + +Our service should look like: + +```yaml +agent: + environment: + - DD_API_KEY + - DD_APM_ENABLED=true + - DD_TAGS='env:apm-workshop' + - DD_LOGS_ENABLED=true + - DD_LOGS_CONFIG_CONTAINER_COLLECT_ALL=true +``` + +# Enable trace id injection into logs + +Add the following environment variable to the `frontend`, `node`, `pumps`, +and `sensors` services in `docker-compose.yml`. + +`DD_LOGS_INTEGRATION=true`{{copy}} + +Our services should look like: + +```yaml +frontend: + environment: + - DATADOG_SERVICE_NAME=frontend + - DATADOG_TRACE_AGENT_HOSTNAME=agent + - DD_ANALYTICS_ENABLED=true + - DD_LOGS_INTEGRATION=true +``` + +Afterwards restart docker services: + +`docker-compose up`{{execute interrupt}} + +Finally, open logs dashboard: + +https://app.datadoghq.com/logs diff --git a/dash-apm-python/step_9.md b/dash-apm-python/step_9.md new file mode 100644 index 0000000..1300214 --- /dev/null +++ b/dash-apm-python/step_9.md @@ -0,0 +1,25 @@ +To enable the Datadog process agent add the following environment variable +to the `agent` service. + +`DD_PROCESS_AGENT_ENABLED=true`{{copy}}. + +Our service should look like: + +```yaml +agent: + environment: + - DD_API_KEY + - DD_APM_ENABLED=true + - DD_TAGS='env:apm-workshop' + - DD_LOGS_ENABLED=true + - DD_LOGS_CONFIG_CONTAINER_COLLECT_ALL=true + - DD_PROCESS_AGENT_ENABLED=true +``` + +Next, restart our docker services: + +`docker-compose up`{{execute interrupt}} + +Finally, open the process dashboard: + +https://app.datadoghq.com/process