Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ struct MyApp: App {
Signoz.start(serviceName: "my-app") { config in
config.endpoint = "localhost:4317" // default
config.environment = "production" // deployment.environment
config.hostName = .auto // host.name (system hostname)
config.hostName = .auto // host.name (short system hostname, domain suffix stripped)
config.hostName = .custom("web-01") // host.name (explicit value)
// config.hostName = .none // omit host.name (default)
config.serviceVersion = "1.0.0"
Expand Down Expand Up @@ -274,7 +274,7 @@ let attrs: [String: AttributeValue] = [
| `serviceName` | `String` | *required* | Service name (`service.name`) |
| `serviceVersion` | `String` | `""` | Service version (`service.version`) |
| `environment` | `String` | `""` | Deployment environment (`deployment.environment`) |
| `hostName` | `.none` \| `.auto` \| `.custom(String)` | `.none` | Host name (`host.name`). `.none` omits the attribute, `.auto` uses the system hostname, `.custom("...")` uses an explicit value. |
| `hostName` | `.none` \| `.auto` \| `.custom(String)` | `.none` | Host name (`host.name`). `.none` omits the attribute, `.auto` uses the short system hostname (strips domain suffixes like `.local`), `.custom("...")` uses an explicit value. |
| `resourceAttributes` | `[String: AttributeValue]` | `[:]` | Extra resource attributes |
| `headers` | `[String: String]` | `[:]` | gRPC metadata headers |
| `transportSecurity` | `.plaintext` \| `.tls` | `.plaintext` | Transport security mode |
Expand Down
4 changes: 2 additions & 2 deletions Sources/SignozSwift/Configuration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public struct Configuration: Sendable {

/// Host name strategy for the `host.name` resource attribute.
/// - `.none` — attribute is omitted (default).
/// - `.auto` — uses the system hostname at runtime.
/// - `.auto` — uses the short system hostname at runtime (strips domain suffixes like `.local`, `.localdomain`).
/// - `.custom("value")` — uses the provided string.
public var hostName: HostName = .none

Expand Down Expand Up @@ -67,7 +67,7 @@ public struct Configuration: Sendable {
public enum HostName: Sendable, Equatable, ExpressibleByStringLiteral {
/// Do not include the `host.name` resource attribute.
case none
/// Use the system hostname (`ProcessInfo.processInfo.hostName`).
/// Use the short system hostname (domain suffixes like `.local` stripped).
case auto
/// Use a custom hostname value.
case custom(String)
Expand Down
4 changes: 3 additions & 1 deletion Sources/SignozSwift/Signoz.swift
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,9 @@ public enum Signoz {
case .none:
break
case .auto:
attrs["host.name"] = .string(ProcessInfo.processInfo.hostName)
let raw = ProcessInfo.processInfo.hostName
let short = raw.split(separator: ".", maxSplits: 1).first.map(String.init) ?? raw
attrs["host.name"] = .string(short)
Comment on lines +168 to +170
Copy link

Copilot AI Apr 18, 2026

Choose a reason for hiding this comment

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

The new domain-suffix stripping behavior for .auto isn’t covered by tests. Consider adding a deterministic unit test (e.g., by extracting the “short hostname” normalization into a small internal helper that takes a String and can be tested with inputs like myhost.localdomain and server-01.internal.corp). This will help prevent regressions in how host.name is derived.

Copilot uses AI. Check for mistakes.
case .custom(let value):
attrs["host.name"] = .string(value)
}
Expand Down
Loading