Skip to content

gabsn/apm-toy-app

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

apm-toy-app

A simple app to trace.

full_trace

Prerequisites

  1. Install docker and docker-compose (you can try sudo pip install docker-compose)
  2. Install go and dep (the dependency management tool we use for this project).
  3. You need a Datadog account. If you don't have one, just use the free trial.

Get the app running

  1. Get your Datadog API key (Integrations > APIs in the app) and paste it here

Note: each time you'll change your API key, you'll need to rebuild the datadog-agent docker image.

  1. Get your Datadog API key (Integrations > APIs) and paste it here

  2. Get the dependencies

dep ensure

And then run the app

docker-compose up

This command should launch a minimal golang server along with redis, postgres and the datadog-agent.

  1. Go to http://localhost:8080/, you should get something like that:
(247 hits) - City: Utrecht, 234323 inhabitants

Each time you hit this URL, the golang server will return a different city and its population from postgres and will also tell you how many times you hit this endpoint.

Check the datadog-agent status

  1. Connect to the container running the datadog-agent
docker exec -it apmtoyapp_datadog_1 bash
  1. Run the info command of the agent
service datadog-agent info
  1. Check that postgres and redis are properly reporting metrics
 Checks
  ======

    postgres (5.16.0)
    -----------------
      - instance #0 [OK]
      - Collected 15 metrics, 0 events & 1 service check

    redisdb (5.16.0)
    ----------------
      - instance #0 [OK]
      - Collected 36 metrics, 0 events & 1 service check
      - Dependencies:
          - redis: 2.10.5
  1. Go in the Datadog app, Metrics > Explorer and check you can see your metrics in the app.

metrics explorer

Trace the app

  1. Try to trace the app by yourself. All the libraries we support are in this directory.

  2. If you're stuck, you can use this diff to see how to trace the app.

  3. If you still can't get any trace in the Datadog app, just checkout on the app-traced branch to get the app already traced (but it's better if you do it yourself, so you can understand the process).

Once it's done, restart the app (dep ensure && docker-compose up) and hit the URL multiple times.

You should see some traces appear in the Datadog app (APM > Traces).

traces

  1. Congratulations! Now you understand how it works and you can try to trace your own apps (see here all the libraries we support).

If you have any question, feel free to ask it on #apm (Datadog's public slack).

Possible issues

  • If you encounter some dependency issues, try to run dep ensure (make sure you have dep installed).

  • If you want to make modifications to the datadog image, you have to manually rebuild it with docker build --no-cache datadog -t apmtoyapp_datadog.