Skip to content

Add AttachServerName and stop gating the server name on SendDefaultPii #5957

In review

Description

@jamescrosswell

The core SDK sends Environment.MachineName as the server name only when SendDefaultPii is on. #5428 listed these sites for migration to DataCollection.UserInfo, but #5932 leaves them out, because userInfo doesn't cover server name in the spec. This issue tracks them instead.

Sites:

  • MainSentryEventProcessor: @event.ServerName = Environment.MachineName when SendDefaultPii is on and ServerName isn't set.
  • SentryLog.SetDefaultAttributes: the server.address attribute, under the same conditions.
  • AspNetCoreEventProcessor and SystemWebRequestEventProcessor always set it, with no gate. A comment in the first says the core gate exists "since the SDK can be used in desktop apps".

The spec doesn't cover it

Data collection spec 0.17.0 has no option for server name or hostname, and userInfo "does not affect any other data category". The nearest category is technical context ("Device and environment context (OS, runtime, non-PII identifiers)"), which SDKs SHOULD collect and which no dataCollection option gates. The one open spec PR, getsentry/sentry-docs#20856, doesn't touch it either.

Other SDKs

SDK Default Switch
Java hostname, not gated by sendDefaultPii or userInfo SentryOptions.attachServerName, default true; SentryAndroidOptions sets it to false
JavaScript (Node) SENTRY_NAME or os.hostname(), not gated includeServerName on ServerRuntimeOptions, documented for CLI and Electron apps where the hostname may be PII
Python, Go, Ruby, PHP hostname, not gated override server_name
Cocoa never set —
Dart never set as server_name; the hostname goes in device.name only with sendDefaultPii —

Java's and Node's switches both predate dataCollection, and neither moved into it when those SDKs adopted it.

The pattern is server versus client, not a data category. On a server the hostname names a machine you run. On a phone, laptop or CLI it names the user's device, and often includes their name.

Proposal

  • Add a top-level SentryOptions.AttachServerName (with its BindableSentryOptions counterpart). It defaults to true, and to false on .NET for Android and .NET for iOS, which covers MAUI on those platforms.
  • An explicitly set ServerName always wins.
  • Respect it in all four sites above, including ASP.NET Core and ASP.NET.
  • Keep the legacy behaviour while DataCollection isn't configured, per the spec's migration rules. Once it is, AttachServerName decides instead of SendDefaultPii.

Open questions:

  • Mac Catalyst: desktop hardware, but shares the iOS code paths.
  • Mobile behaviour change: .NET for Android and iOS apps with SendDefaultPii = true send the machine name today. Defaulting AttachServerName to false there changes that, so it needs a changelog note or a place in DataCollection phase 3: deprecate SendDefaultPii #5437 / DataCollection phase 4: spec defaults for explicit DataCollection users #5438. On Android, .NET already sets the native SDK's AttachServerName = false (Platforms/Android/SentrySdk.cs), so only the managed layer sends it.
  • Spec: we could instead propose a dataCollection key in the spec. We went with top-level to match Java and Node.

Related: #5956 (MAUI sends the device name with no gate) may want the same switch.

Part of #5420.

Activity

  1. linear-code commented on Nov 18, 2026

    @linear-code
  2. jamescrosswell commented on Nov 18, 2026

    @jamescrosswell
    CollaboratorAuthor

    @ric-oliv an alternative would be not to have any option and simply never to send this information on mobile platforms (and always send it on Desktop platforms).

  3. ric-oliv commented on Dec 4, 2026

    @ric-oliv
    Member

    For the record, I agree with keeping the option, as you did in #6086.
    Without it, desktop apps have no way to stop sending the hostname, because an empty ServerName falls back to the machine name.
    Bottom line as internally agreed: top-level, true for servers, false on mobile.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions