Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Logging hostname at startup can take a prohibitively long time #32908

Closed
wilkinsona opened this issue Oct 27, 2022 · 6 comments
Closed

Logging hostname at startup can take a prohibitively long time #32908

wilkinsona opened this issue Oct 27, 2022 · 6 comments
Labels
type: bug A general bug
Milestone

Comments

@wilkinsona
Copy link
Member

wilkinsona commented Oct 27, 2022

StartupInfoLogger logs the result of calling InetAddress.getLocalHost().getHostName(). This call can take a long time as we've discussed in the past. That discussion concluded with us logging a warning when resolving the host name takes too long.

With a new major release we have another option available to us: remove the hostname from the log message. I am in favour of doing so as I don't think it adds much value at the moment. If you're viewing the logs locally, knowing the hostname isn't useful. If you're viewing them remotely you presumably now where the logs came from. If you're viewing aggregated logs, having an identifier per log entry would be far more useful than mentioning the hostname in one entry which may have been lost long ago via a rollover.

@wilkinsona wilkinsona added status: waiting-for-triage An issue we've not yet triaged for: team-meeting An issue we'd like to discuss as a team to make progress labels Oct 27, 2022
@sdeleuze
Copy link
Contributor

sdeleuze commented Oct 27, 2022

I would love to see this change in Spring Boot 3, I mean really! On Mac or some Cloud platforms resolving localhost DNS at startup can take a huge amount of time (including for native), so it seems to be much safer to avoid this friction point on both DevXP and Cloud deployments by default, and let people add the hostname or any other differentiator via the log aggregation system or via Logback configuration.

That would be a much safer default, would make Spring Boot startup time more robust and predictive, while still allowing much more useful per lines differentiator use case via explicit configuration.

@mhalbritter
Copy link
Contributor

I totally agree with your line of reasoning, Andy.

@philwebb
Copy link
Member

Fine by me.

@philwebb philwebb added this to the 3.0.x milestone Oct 27, 2022
@philwebb philwebb added type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged labels Oct 27, 2022
@philwebb
Copy link
Member

Another option might be to look for COMPUTERNAME, HOSTNAME or HOST environment variables. That should be quick. According to stackoverflow the HOSTNAME is the pod in Kubernetes which might be useful.

@sdeleuze
Copy link
Contributor

sdeleuze commented Oct 28, 2022

A significant limitation is that on most Unix systems, HOSTNAME is not exported, hence not visible from Java by default, see https://stackoverflow.com/a/17956000.

So I guess the 2 options would be either:

  • Remove the hostname from the log message as suggested by @wilkinsona in the description to have a consistent behavior on all platforms.
  • Use COMPUTERNAME on Windows or HOSTNAME when exported so visible from Java in Unix-like platforms (not sure about HOST) when available.

@wilkinsona
Copy link
Member Author

We've decided to remove the hostname from the log message.

@wilkinsona wilkinsona removed the for: team-meeting An issue we'd like to discuss as a team to make progress label Oct 31, 2022
@philwebb philwebb modified the milestones: 3.0.x, 3.0.0-RC2 Oct 31, 2022
@wilkinsona wilkinsona added type: bug A general bug and removed type: enhancement A general enhancement labels Oct 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug A general bug
Projects
None yet
Development

No branches or pull requests

4 participants