Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

use java library to grab hostname

未关闭
#4,031 3 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
45/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
停滞
技术栈
java

调研方向

从 apm-agent-core/src/main/java/co/elastic/apm/agent/impl/metadata/SystemInfo.java 第 223 行附近开始,这里 agent 会运行 "hostname -f"。验证基于 Java 的主机名查找在 hostname 命令不可用时仍能正常工作,并保持元数据行为不变;完成的标准是无需再使用该命令,且相关检查通过。

由索引模型根据 Issue 内容生成。

描述

agent-java

I ran into this issue due to lack of hostname command on the container.

2025-04-01 11:21:56,560 [elastic-apm-metadata-0] INFO  co.elastic.apm.agent.impl.metadata.SystemInfo - Failed to execute command "hostname -f" with exit code -1
2025-04-01 11:21:56,560 [elastic-apm-metadata-0] DEBUG co.elastic.apm.agent.impl.metadata.SystemInfo - Command execution error
java.io.IOException: Cannot run program "hostname": error=2, No such file or directory

https://github.com/elastic/apm-agent-java/blob/93f28fec583847f53b205307eb00f44c3ef05d5f/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/metadata/SystemInfo.java#L223

It would be beneficial to abandon calling this command and do so in java to avoid such error as well as a small performance improvement.

String hostname = InetAddress.getLocalHost().getHostName();

主要语言
Java
星标
593
派生
338
平均合并
1 天 9 小时
30 天内合并 PR
13

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

elastic/apm-agent-java 的其他 Issue

查看 elastic/apm-agent-java 的全部 Issue

相似的 Issue

更多 Java Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。