-
Notifications
You must be signed in to change notification settings - Fork 622
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* adds a java example * removes PTRACE requirement
- Loading branch information
1 parent
8f86341
commit 1a4741c
Showing
3 changed files
with
57 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
FROM openjdk:11.0.11-jdk | ||
|
||
WORKDIR /opt/app | ||
RUN git clone https://github.com/pyroscope-io/pyroscope-java.git | ||
RUN cd pyroscope-java && \ | ||
./gradlew shadowJar && \ | ||
cp agent/build/libs/pyroscope.jar /opt/app/pyroscope.jar | ||
|
||
COPY Main.java ./Main.java | ||
|
||
ENV PYROSCOPE_APPLICATION_NAME=simple.java.app | ||
ENV PYROSCOPE_PROFILING_INTERVAL=10ms | ||
ENV PYROSCOPE_PROFILER_EVENT=cpu | ||
ENV PYROSCOPE_UPLOAD_INTERVAL=10s | ||
ENV PYROSCOPE_LOG_LEVEL=debug | ||
ENV PYROSCOPE_SERVER_ADDRESS=http://pyroscope:4040 | ||
|
||
RUN javac Main.java | ||
|
||
CMD ["java", "-XX:-Inline", "-javaagent:pyroscope.jar", "Main"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
class Main { | ||
public static int work(int n) { | ||
int i = 0; | ||
for (i = 0; i < n; i++) {} | ||
return i; | ||
} | ||
|
||
public static void fastFunction() { | ||
work(20000); | ||
} | ||
|
||
public static void slowFunction() { | ||
work(80000); | ||
} | ||
|
||
public static void main(String[] args) { | ||
int i = 0; | ||
while (true) { | ||
fastFunction(); | ||
slowFunction(); | ||
i++; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
--- | ||
version: "3.9" | ||
services: | ||
pyroscope: | ||
image: "pyroscope/pyroscope:latest" | ||
environment: | ||
- "PYROSCOPE_LOG_LEVEL=debug" | ||
ports: | ||
- "4040:4040" | ||
command: | ||
- "server" | ||
app: | ||
build: . |