# Rack: Demo application for Datadog APM A generic Rack web application with some common use scenarios. For generating Datadog APM traces and profiles. ## Installation Install [direnv](https://github.com/direnv/direnv) for applying local settings. 1. `cp .envrc.sample .envrc` and add your Datadog API key. 2. `direnv allow` to load the env var. 4. `docker-compose run --rm app bin/setup` ## Running the application ### To monitor performance of Docker containers with Datadog ```sh docker run --rm --name dd-agent -v /var/run/docker.sock:/var/run/docker.sock:ro -v /proc/:/host/proc/:ro -v /sys/fs/cgroup/:/host/sys/fs/cgroup:ro -e API_KEY=$DD_API_KEY datadog/docker-dd-agent:latest ``` ### Starting the web server Run `docker-compose up` to auto-start the webserver. It should bind to `localhost:80`. Alternatively, you can run it manually with: ```sh docker-compose run --rm -p 80:80 app bin/run ``` The `` argument is optional, and will default to `DD_DEMO_ENV_PROCESS` if not provided. See [Processes](#processes) for more details. ##### Processes Within the container, run `bin/run ` where `` is one of the following values: - `puma`: Puma web server - `unicorn`: Unicorn web server - `irb`: IRB session Alternatively, set `DD_DEMO_ENV_PROCESS` to run a particular process by default when `bin/run` is run. ##### Features Set `DD_DEMO_ENV_FEATURES` to a comma-delimited list of any of the following values to activate the feature: - `tracing`: Tracing instrumentation - `profiling`: Profiling (NOTE: Must also set `DD_PROFILING_ENABLED` to match.) - `debug`: Enable diagnostic debug mode - `analytics`: Enable trace analytics - `runtime_metrics`: Enable runtime metrics - `pprof_to_file`: Dump profiling pprof to file instead of agent. e.g. `DD_DEMO_ENV_FEATURES=tracing,profiling` ##### Routes ```sh # Health check curl -v localhost/health # Basic demo scenarios curl -v localhost/basic/fibonacci curl -v -XPOST localhost/basic/default # Job demo scenarios curl -v -XPOST localhost/jobs ``` ### Load tester Docker configuration automatically creates and runs [Wrk](https://github.com/wg/wrk) load testing containers. By default it runs the `basic/default` scenario described in the `wrk` image to give a baseload. You can modify the `load-tester` container in `docker-compose.yml` to change the load type or scenario run. Set the container's `command` to any set of arguments `wrk` accepts. You can also define your own custom scenario by creating a LUA file, mounting it into the container, and passing it as an argument via `command`. ### Running integration tests You can run integration tests using the following and substituting for the Ruby major and minor version (e.g. `2.7`) ```sh ./script/build-images -v ./script/ci -v ``` Or inside a running container: ```sh ./bin/test ```