参考Skywalking Github:Setup java agent
- 更多agent 配置可以参考agent config
- vm options:
-javaagent:incubator-skywalking/skywalking-agent/skywalking-agent.jar
-Dskywalking.agent.application_code=hello-world-demo
-Dskywalking.collector.backend_service=localhost:11800
java -javaagent:/apache-skywalking-apm-incubating/agent/skywalking-agent.jar -Dskywalking.collector.backend_service=localhost -Dskywalking.agent.application_code=hello-world-demo-0004 -jar target/sky-demo-1.0-SNAPSHOT.jar
- Dockerfile
FROM openjdk:8-jre-alpine
LABEL maintainer="[email protected]"
ENV SW_APPLICATION_CODE=java-agent-demo \
SW_COLLECTOR_SERVERS=localhost:11800
COPY skywalking-agent /apache-skywalking-apm-incubating/agent
COPY target/sky-demo-1.0-SNAPSHOT.jar /demo.jar
ENTRYPOINT java -javaagent:/apache-skywalking-apm-incubating/agent/skywalking-agent.jar -Dskywalking.collector.backend_service=${SW_COLLECTOR_SERVERS} \
-Dskywalking.agent.application_code=${SW_APPLICATION_CODE} -jar /demo.jar
- 构建并运行
docker build -t hello-demo .
docker run -p 10101:10101 -e SW_APPLICATION_CODE=hello-world-demo-005 -e SW_COLLECTOR_SERVERS=127.10.0.2:11800 hello-demo