alibaba / alibaba/arthas

ArthasBootstrap.getInstance(instrumentation, "") 如何禁止调用/api/latest_version

Open
#2,973 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
37.6k
Forks
7.6k
Avg merge
1d 22h
Merged PRs (30d)
4

Description

- [ ] 我已经在 [issues](https://github.com/alibaba/arthas/issues) 里搜索,没有重复的issue。

### 环境信息

* `arthas-boot.jar` 或者 `as.sh` 的版本: xxx
* Arthas 版本: 4.0.1
* 操作系统版本: centos
* 目标进程的JVM版本: jdk8
* 执行`arthas-boot`的版本: 4.0.1

初始化调用ArthasBootstrap.getInstance(instrumentation, "") 时,会自动调用[/api/latest_version](https://arthas.aliyun.com/api/latest_version接口,就为了打印一行日志?我看代码里没办法关掉这个调用么

public static String welcome(Map infos) {
logger.info("Current arthas version: {}, recommend latest version: {}", version(), latestVersion());
TableElement table = (new TableElement()).rightCellPadding(1).row(new String[]{"wiki", wiki()}).row(new String[]{"tutorials", tutorials()}).row(new String[]{"version", version()}).row(new String[]{"main_class", PidUtils.mainClass()}).row(new String[]{"pid", PidUtils.currentPid()}).row(new String[]{"time", DateUtils.getCurrentDate()});
Iterator var2 = infos.entrySet().iterator();

while(var2.hasNext()) {
Map.Entry entry = (Map.Entry)var2.next();
table.row(new String[]{(String)entry.getKey(), (String)entry.getValue()});
}

return logo() + "\n" + RenderUtil.render(table);
}

static String latestVersion() {
try {
URLConnection urlConnection = openURLConnection("https://arthas.aliyun.com/api/latest_version");
InputStream inputStream = urlConnection.getInputStream();
return IOUtils.toString(inputStream).trim();
} catch (Throwable var2) {
return "";
}
}

```

Contributor guide

Open the contributing guide

Research direction

Start with ArthasBootstrap.getInstance(instrumentation, "") and the welcome() and latestVersion() methods shown in the issue. Trace how the welcome message is assembled and where the /api/latest_version request is triggered. Done means initialization can disable that request while retaining the remaining welcome information; add or update a focused test if the existing test structure covers this path.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
devtools
Issue type
Feature
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.