Skip to content

Commit

Permalink
chore: add a docker-compose file for local development
Browse files Browse the repository at this point in the history
add a docker-compose file with the locally built and compiled
agent as well as the datadog-agent communicating with each other
to make local development more seamless
  • Loading branch information
Gandem committed Jun 12, 2024
1 parent 8171585 commit 10f361b
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ otel-profiling-agent
tracer.ebpf
tracer.ebpf.arm64
tracer.ebpf.x86
.env
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,29 @@ sudo otel-profiling-agent -tags 'service:myservice;remote_symbols:yes' -collecti

For this to work you need to run a Datadog agent that listens for APM traffic at `localhost:8126`. If your agent is reachable under a different address, you can modify the `-collection-agent` parameter accordingly.

## Development

A `docker-compose.yml` file is provided to help run the agent in a container for local development.

First, create a `.env` file with the following content:

```
ARCH=amd64 # required
DD_API_KEY=your-api-key # required
DD_SITE=datadoghq.com # optional, defaults to "datadoghq.com"
OTEL_PROFILING_AGENT_SERVICE=my-service # optional, defaults to "otel-profiling-agent-dev"
OTEL_PROFILING_AGENT_REPORTER_INTERVAL=10s # optional, defaults to 60s
```

Then, you can run the agent with the following command:

```
docker-compose up
```

The agent will submit profiling data to the Datadog Agent using the value of OTEL_PROFILING_AGENT_SERVICE as the service name.


The contents of the original upstream README are below.

---
Expand Down
33 changes: 33 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: "otel-profiling"

services:
agent:
build:
context: .
args:
- arch=${ARCH:?error}
privileged: true
pid: "host"
network_mode: "host"
volumes:
- ~dd/otel-profiling-agent:/agent
command: bash -c "sudo mount -t debugfs none /sys/kernel/debug && make && sudo /agent/otel-profiling-agent -tags 'service:${OTEL_PROFILING_AGENT_SERVICE:-otel-profiling-agent-dev};remote_symbols:yes' -collection-agent "http://localhost:8200" -reporter-interval ${OTEL_PROFILING_AGENT_REPORTER_INTERVAL:-60s} -samples-per-second 20 -save-cpuprofile"

datadog-agent:
image: gcr.io/datadoghq/agent:7
cgroup: host
environment:
DD_SITE: ${DD_SITE:-datadoghq.com}
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
- /proc/:/host/proc/:ro
- /sys/fs/cgroup/:/host/sys/fs/cgroup:ro
ports:
- "8200:8126"
secrets:
- dd-api-key
entrypoint: [ '/bin/sh', '-c', 'export DD_API_KEY=$$(cat /run/secrets/dd-api-key) ; /bin/entrypoint.sh' ]

secrets:
dd-api-key:
environment: DD_API_KEY

0 comments on commit 10f361b

Please sign in to comment.