Skip to content

use java library to grab hostname #4031

@TomonoriSoejima

Description

@TomonoriSoejima

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

logger.info("Failed to execute command {} with exit code {}", cmdAsString(cmd), commandOutput.getExitCode());

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions