-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(scaffold): support integration with skywalking
- Loading branch information
Showing
8 changed files
with
167 additions
and
12 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
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
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
64 changes: 64 additions & 0 deletions
64
generators/app/templates/1.docs/guides/if_skywalking.integrate_skywalking.tmpl.md
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,64 @@ | ||
# Integrate Skywalking | ||
|
||
## Download agent | ||
|
||
要与skywalking集成,你需要使用java agent。 | ||
|
||
你可以通过执行以下命令下载skywalking的java agent | ||
|
||
### linux/macos | ||
|
||
```shell | ||
curl -# -o agent.tar.gz http://mirrors.tuna.tsinghua.edu.cn/apache/skywalking/${swVersion}/apache-skywalking-apm-${swVersion}.tar.gz | ||
mkdir -p agent | ||
tar -zxvf agent.tar.gz | ||
rm -rf agent/skywalking | ||
mv apache-skywalking-apm-bin/agent agent/skywalking | ||
rm agent.tar.gz | ||
rm -rf apache-skywalking-apm-bin | ||
``` | ||
|
||
### windows | ||
|
||
<% | ||
if (false) { | ||
// print(` | ||
//```shell | ||
//curl -# -o agent.zip http://mirrors.tuna.tsinghua.edu.cn/apache/skywalking/${swVersion}/apache-skywalking-apm-${swVersion}.zip | ||
//TODO:: | ||
//``` | ||
// `) | ||
} else { | ||
print(`暂不支持windows系统,请前往http://skywalking.apache.org/downloads/手动下载相关相应版本,并将压缩包agent目录下的内容放至项目agent/skywalking下`) | ||
} | ||
%> | ||
|
||
## Run with IDE | ||
|
||
请在IDE的启动VM参数中加入以下配置 | ||
```text | ||
-javaagent:agent/skywalking/skywalking-agent.jar | ||
-Dskywalking.agent.service_name=${artifactId} | ||
-Dskywalking.collector.backend_service={sw_service_address} | ||
``` | ||
|
||
## Run with *.jar | ||
|
||
请参考[Start via process](quickly_start.md#start-via-process),并加入以下启动参数 | ||
|
||
```text | ||
-javaagent:{project_home}/agent/skywalking/skywalking-agent.jar | ||
-Dskywalking.agent.service_name=${artifactId} | ||
-Dskywalking.collector.backend_service={sw_service_address} | ||
``` | ||
|
||
## Run with Docker | ||
|
||
请参考[Start via container](quickly_start.md#start-via-container),并通过以下环境变量控制skywalking相关配置 | ||
|
||
|**环境变量**|**描述**|**默认值**| | ||
|--|--|--| | ||
|SW_SERVICE_NAME|注册到skywalking时使用的服务名|${artifactId}| | ||
|SW_SERVICE_ADDR|skywalking服务地址|无| | ||
|
||
> 注意:以上环境变量应修改`run.sh`脚本,通过`-e`参数传入 |
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
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 |
---|---|---|
@@ -1,3 +1,13 @@ | ||
#!/bin/bash | ||
|
||
java -jar app.jar $@ | ||
<% | ||
if (apm === 'skywalking') { | ||
print(`java \\ | ||
-javaagent:agent/skywalking/skywalking-agent.jar \\ | ||
-Dskywalking.agent.service_name=\${SW_SERVICE_NAME:-${artifactId}} \\ | ||
-Dskywalking.collector.backend_service=\${SW_SERVICE_ADDR} \\ | ||
-jar app.jar $@`) | ||
} else { | ||
print(`java -jar app.jar $@`) | ||
} | ||
%> |
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 |
---|---|---|
@@ -1,10 +1,18 @@ | ||
#!/bin/bash | ||
|
||
docker run \ | ||
--name $CONTAINER_NAME \ | ||
--restart=on-failure:5 \ | ||
--privileged \ | ||
-p $PORT:8080 \ | ||
-v $PWD/logs:/home/logs \ | ||
-d $IMG_NAME \ | ||
--spring.profiles.active=prod | ||
<% | ||
let script = ` | ||
docker run \\ | ||
--name $CONTAINER_NAME \\ | ||
--restart=on-failure:5 \\ | ||
--privileged \\` | ||
if (apm === 'skywalking') { | ||
script += ` | ||
-e SW_SERVICE_ADDR=127.0.0.1:11800 \\` | ||
} | ||
script += ` | ||
-p $PORT:8080 \\ | ||
-v $PWD/logs:/home/logs \\ | ||
-d $IMG_NAME \\ | ||
--spring.profiles.active=prod` | ||
print(script); | ||
%> |
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