Skip to content

Strip domain suffix from auto hostname#13

Merged
Ryan Zhu (underthestars-zhy) merged 1 commit into
mainfrom
cursor/strip-auto-hostname-suffix-1897
Apr 18, 2026
Merged

Strip domain suffix from auto hostname#13
Ryan Zhu (underthestars-zhy) merged 1 commit into
mainfrom
cursor/strip-auto-hostname-suffix-1897

Conversation

@underthestars-zhy
Copy link
Copy Markdown
Member

@underthestars-zhy Ryan Zhu (underthestars-zhy) commented Apr 11, 2026

Summary

When hostName is set to .auto, the system hostname returned by ProcessInfo.processInfo.hostName can include domain suffixes like .local, .localdomain, etc. (e.g. myhost.local instead of myhost).

This PR strips everything after the first . so that host.name contains only the short hostname.

Changes

  • Signoz.swift: In the .auto case, split the raw hostname on . and use only the first component.
  • Configuration.swift: Updated doc comments for .auto and the HostName enum to reflect the new stripping behavior.
  • README.md: Updated inline comments and the configuration reference table to document the domain suffix stripping.

Example

Before After
myhost.local myhost
myhost.localdomain myhost
server-01.internal.corp server-01
myhost (no suffix) myhost
Open in Web Open in Cursor 

Summary by CodeRabbit

  • Documentation

    • Clarified hostname configuration behavior for .auto setting
  • Bug Fixes

    • Fixed .auto hostname handling to properly strip domain suffixes (e.g., .local, .localdomain)

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>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 11, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 9b6c8d46-b42b-4dd6-80d0-7543738ce313

📥 Commits

Reviewing files that changed from the base of the PR and between c318035 and 33903dc.

📒 Files selected for processing (3)
  • README.md
  • Sources/SignozSwift/Configuration.swift
  • Sources/SignozSwift/Signoz.swift

Disabled knowledge base sources:

  • Linear integration is disabled

You can enable these sources in your CodeRabbit configuration.


📝 Walkthrough

Walkthrough

Documentation clarified and implementation updated for the .auto hostname configuration to use the short system hostname (first segment before the first dot) instead of the full hostname string. Changes span configuration documentation, API documentation comments, and initialization logic.

Changes

Cohort / File(s) Summary
Hostname Configuration Documentation
README.md, Sources/SignozSwift/Configuration.swift
Updated documentation to clarify that .auto uses the short system hostname with domain suffixes (.local, .localdomain) stripped.
Hostname Initialization Logic
Sources/SignozSwift/Signoz.swift
Modified .auto host-name handling in resource attribute construction to truncate hostname to first segment before the first dot; includes fallback to full value if no delimiter exists.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 The hostname hops shorter now,
First dot decides the bow,
Domain suffix stripped away clean,
Local whispers now serene,
Auto finds the truest name! 🌟

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch cursor/strip-auto-hostname-suffix-1897

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link
Copy Markdown

📄 README may need an update

This PR introduces changes that might not be reflected in README.md.

Reason: The README does not fully match the current public API because it omits the instrumentationName configuration option and describes localPersistencePath as persisting only spans and logs even though the code now also persists metrics.

This is an automated check powered by AI. If the README is intentionally unchanged, feel free to ignore this.

@underthestars-zhy Ryan Zhu (underthestars-zhy) marked this pull request as ready for review April 18, 2026 03:55
Copilot AI review requested due to automatic review settings April 18, 2026 03:55
@underthestars-zhy Ryan Zhu (underthestars-zhy) merged commit 1294f2b into main Apr 18, 2026
5 of 6 checks passed
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

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.hostName when hostName = .auto.
  • Update configuration doc comments to describe the new .auto behavior.
  • 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.

Comment on lines +168 to +170
let raw = ProcessInfo.processInfo.hostName
let short = raw.split(separator: ".", maxSplits: 1).first.map(String.init) ?? raw
attrs["host.name"] = .string(short)
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants