Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: upgrade to async-profiler 2 #68

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ In order to profile a Java application in pod `mypod` for 1 minute and save the
```shell
kubectl flame mypod -t 1m --lang java -f /tmp/flamegraph.svg
```
Note that Java is using async-profiler 2 that also supports HTML flamegraph by switching the file extension to `.html`.

### Profiling Alpine based container
Profiling Java application in alpine based containers require using `--alpine` flag:
```shell
Expand Down
8 changes: 3 additions & 5 deletions agent/docker/jvm/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@ RUN go get -d -v ./...
RUN cd agent && go build -o /go/bin/agent

FROM openjdk:8 as asyncprofiler
RUN echo deb http://deb.debian.org/debian stretch-backports main > /etc/apt/sources.list.d/stretch-backports.list && \
apt-get update && \
apt-get -y install build-essential
RUN git clone https://github.com/edeNFed/async-profiler.git
RUN cd async-profiler && make
RUN curl -o async-profiler-2.5-linux-x64.tar.gz -L \
https://github.com/jvm-profiling-tools/async-profiler/releases/download/v2.5/async-profiler-2.5-linux-x64.tar.gz
RUN tar -xvf async-profiler-2.5-linux-x64.tar.gz && mv async-profiler-2.5-linux-x64 async-profiler

FROM bitnami/minideb:stretch
RUN mkdir -p /app/async-profiler/build
Expand Down
7 changes: 4 additions & 3 deletions agent/docker/jvm/Dockerfile.alpine
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ RUN go get -d -v ./...
RUN cd agent && go build -o /go/bin/agent

FROM openjdk:8-alpine as asyncprofiler
RUN apk add build-base git linux-headers
RUN git clone https://github.com/edeNFed/async-profiler.git
RUN cd async-profiler && make
RUN apk add build-base linux-headers curl
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For unpacking the tar.gz file, the alpine tar package is needed because the existing tar command from busybox doesn't support all necessary features.

Suggested change
RUN apk add build-base linux-headers curl
RUN apk add build-base linux-headers curl tar

RUN curl -o async-profiler-2.5-linux-musl-x64.tar.gz -L \
https://github.com/jvm-profiling-tools/async-profiler/releases/download/v2.5/async-profiler-2.5-linux-musl-x64.tar.gz
RUN tar -xvf async-profiler-2.5-linux-musl-x64.tar.gz && mv async-profiler-2.5-linux-musl-x64 async-profiler

FROM alpine
RUN mkdir -p /app/async-profiler/build
Expand Down
2 changes: 1 addition & 1 deletion agent/profiler/jvm.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (

const (
profilerDir = "/tmp/async-profiler"
fileName = "/tmp/flamegraph.svg"
fileName = "/tmp/flamegraph.html"
profilerSh = profilerDir + "/profiler.sh"
)

Expand Down