-
Notifications
You must be signed in to change notification settings - Fork 229
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
Fix incorrect hostname detection on Windows #3899
Conversation
@mpoc Thanks!
Do you happen to know what cases? For example, has the default behaviour of powershell.exe on whether to show a logo changed over time? Or perhaps it depends on some system configuration? Anyway, these changes look good to me. (Note to self: https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_powershell_exe?view=powershell-5.1 for notes on the powershell CLI options.) |
Not sure, I couldn't find a definitive answer. I just wanted to clarify that I wasn't suggesting the banner shows up inconsistently. What I meant was that log messages in profile scripts will break the hostname detection. Likewise, anything printed before the hostname, like the logo banner, will break it for the same reason. |
run docs-build |
Understood. Thanks. |
This passes "test-windows" before and after. And our tests do include a test of the "system.detected_hostname": apm-agent-nodejs/test/agent.test.js Lines 76 to 81 in a1b1f6f
So I think this is good. I'll follow up with a PR on our specs for this: |
…d logo that could break detection If a Windows system has a powershell profile that emits output, then it could pollute the output used to read the hostname value. Likewise with the powershell logo output, though I don't know if/when that logo appears -- it does not in apm-agent-nodejs' CI tests. Refs: elastic/apm-agent-nodejs#3899
elastic/apm#851 for that. |
…d logo that could break detection (#851) If a Windows system has a powershell profile that emits output, then it could pollute the output used to read the hostname value. Likewise with the powershell logo output, though I don't know if/when that logo appears -- it does not in apm-agent-nodejs' CI tests. Refs: elastic/apm-agent-nodejs#3899
In some cases, the PowerShell command that is used to detect the hostname will contain extra output before the hostname, e.g. the Microsoft copyright banner or any output that is printed in the PowerShell profiles. This causes invalid hostnames to be sent to the APM server.
This change ensures that the PowerShell output is limited only to the hostname.