elastic / elastic/apm-agent-java

use java library to grab hostname

Open
#4,031 3 comments 0 reactions 0 assignees View on GitHub
agent-java
Dominant language
Java
Stars
594
Forks
338
Avg merge
1d 13h
Merged PRs (30d)
25

Description

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();`

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.