Strip domain suffix from auto hostname#13
Conversation
When hostName is .auto, strip everything after the first dot from the system hostname. This removes suffixes like .local, .localdomain, etc. so that host.name contains only the short hostname (e.g. 'myhost' instead of 'myhost.local'). Co-authored-by: Ryan Zhu <zhuhaoyu0909@icloud.com>
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
Disabled knowledge base sources:
📝 WalkthroughWalkthroughDocumentation clarified and implementation updated for the Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
📄 README may need an updateThis PR introduces changes that might not be reflected in Reason: The README does not fully match the current public API because it omits the
|
There was a problem hiding this comment.
Pull request overview
Updates the .auto hostname strategy to store a short hostname (without domain suffix) in the host.name resource attribute.
Changes:
- Strip any domain suffix from
ProcessInfo.processInfo.hostNamewhenhostName = .auto. - Update configuration doc comments to describe the new
.autobehavior. - Update README examples/table to document domain-suffix stripping.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| Sources/SignozSwift/Signoz.swift | Normalizes .auto hostname by taking the substring before the first .. |
| Sources/SignozSwift/Configuration.swift | Updates .auto/HostName documentation to reflect short-hostname behavior. |
| README.md | Documents the updated .auto hostname behavior in examples and config reference. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| let raw = ProcessInfo.processInfo.hostName | ||
| let short = raw.split(separator: ".", maxSplits: 1).first.map(String.init) ?? raw | ||
| attrs["host.name"] = .string(short) |
There was a problem hiding this comment.
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.
Summary
When
hostNameis set to.auto, the system hostname returned byProcessInfo.processInfo.hostNamecan include domain suffixes like.local,.localdomain, etc. (e.g.myhost.localinstead ofmyhost).This PR strips everything after the first
.so thathost.namecontains only the short hostname.Changes
Signoz.swift: In the.autocase, split the raw hostname on.and use only the first component.Configuration.swift: Updated doc comments for.autoand theHostNameenum to reflect the new stripping behavior.README.md: Updated inline comments and the configuration reference table to document the domain suffix stripping.Example
myhost.localmyhostmyhost.localdomainmyhostserver-01.internal.corpserver-01myhost(no suffix)myhostSummary by CodeRabbit
Documentation
.autosettingBug Fixes
.autohostname handling to properly strip domain suffixes (e.g.,.local,.localdomain)