Skip to content

Comments

chore: Set device.name to OS hostname on Windows/Linux dedicated servers#391

Merged
limbonaut merged 12 commits intomainfrom
fix/native-device-name
Sep 30, 2025
Merged

chore: Set device.name to OS hostname on Windows/Linux dedicated servers#391
limbonaut merged 12 commits intomainfrom
fix/native-device-name

Conversation

@limbonaut
Copy link
Collaborator

@limbonaut limbonaut commented Sep 26, 2025

This PR sets device.name to OS hostname on Windows and Linux servers, and leaves it unset otherwise.


Note

On dedicated servers, set device.name to the OS hostname (Windows/Linux) when send_default_pii is enabled, and update the changelog.

  • Device context (src/sentry/contexts.cpp):
    • On dedicated_server, set device.name to OS hostname when send_default_pii is enabled.
    • Add platform-specific hostname retrieval (gethostname on Linux, GetComputerNameW on Windows).
  • Docs:
    • Update CHANGELOG.md under Improvements to note setting device.name to OS hostname for Windows/Linux dedicated servers.

Written by Cursor Bugbot for commit 8494fba. This will update automatically on new commits. Configure here.

@limbonaut limbonaut changed the title fix: Add proper device name on Windows and Linux fix: Device name is not reported correctly on Windows and Linux Sep 26, 2025
@limbonaut limbonaut added the Bug Something isn't working label Sep 26, 2025
@limbonaut limbonaut marked this pull request as ready for review September 26, 2025 17:11
Copy link
Contributor

@vaind vaind left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In context of game engines, I don't think we should be setting device.name at all - user computer hostname is not relevant to the error. https://develop.sentry.dev/sdk/data-model/event-payloads/contexts/#device-context is generic so hostname there is meant for server-side sdks AFAIK. On consoles, device.name is the console name, e.g. PS5 (as set by the console-specific SDK). On Android, as another example, it's a device model identifier.

Do we do that for Unity or Unreal @bitsandfoxes, @tustanivsky ?

@tustanivsky
Copy link
Collaborator

Do we do that for Unity or Unreal @bitsandfoxes, @tustanivsky ?

No, we don’t retrieve the device name in Unreal to include it in the event’s context - only hardware info such as CPU/GPU model, amount of RAM, etc.

@limbonaut
Copy link
Collaborator Author

The hostname can be helpful for some games that offer dedicated server binaries (small number of games really). In those cases, it's actually quite useful information. However, most games don't find it useful. If a game does use it, they could add it themselves perhaps. The question is really, should we add something that is useful for small number of cases, but mostly noise for others?

@vaind
Copy link
Contributor

vaind commented Sep 29, 2025

The question is really, should we add something that is useful for small number of cases, but mostly noise for others?

If you can recognize the game is running as a server, yes, it's OK to include. Otherwise probably not worth all the noise.

@bitsandfoxes
Copy link

bitsandfoxes commented Sep 29, 2025

I took a look at how the SDK for Unity is handling it and found some inconsistency: On Android the SDK reports the actual device's name, i.e. Pixel 6. On macOS the device name, which is not great.

If you can recognize the game is running as a server, yes, it's OK to include. Otherwise probably not worth all the noise.

I second that. The Sentry SDK for .NET even has a ServerName on the options that the SDK for Unity is not using right now, but it should. I'll update this.

@limbonaut limbonaut requested a review from vaind September 30, 2025 09:27
@limbonaut limbonaut changed the title fix: Device name is not reported correctly on Windows and Linux chore: Set device.name to OS hostname on Windows/Linux dedicated servers Sep 30, 2025
cursor[bot]

This comment was marked as outdated.

@limbonaut
Copy link
Collaborator Author

Thanks for the feedback! Now it's only set in dedicated_server exports.

@limbonaut limbonaut merged commit c9dd66c into main Sep 30, 2025
86 of 87 checks passed
@limbonaut limbonaut deleted the fix/native-device-name branch September 30, 2025 11:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix device.name is not reported correctly (device context)

4 participants