Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add host.arch resource attribute #59

Merged
merged 2 commits into from
Apr 5, 2024

Conversation

rogercoll
Copy link
Contributor

Changes

Adds the "host.arch" resource attribute to the Host detector.

Merge requirement checklist

  • CONTRIBUTING guidelines followed
  • Unit tests added/updated (if applicable)
  • Appropriate CHANGELOG.md files updated for non-trivial, user-facing changes
  • Changes in public API reviewed (if applicable)

@rogercoll rogercoll requested a review from a team April 4, 2024 07:46
Copy link

codecov bot commented Apr 4, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 52.5%. Comparing base (56a6f45) to head (35b7860).

Additional details and impacted files
@@           Coverage Diff           @@
##            main     #59     +/-   ##
=======================================
+ Coverage   52.3%   52.5%   +0.2%     
=======================================
  Files         38      38             
  Lines       4967    4997     +30     
=======================================
+ Hits        2598    2628     +30     
  Misses      2369    2369             

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

///
/// [`host.id from non-containerized systems`]: https://opentelemetry.io/docs/specs/semconv/resource/host/#collecting-hostid-from-non-containerized-systems
/// - [`host.id from non-containerized systems`]: https://opentelemetry.io/docs/specs/semconv/resource/host/#collecting-hostid-from-non-containerized-systems
/// - Host architecture (host.arch).
pub struct HostResourceDetector {
host_id_detect: fn() -> Option<String>,
}
Copy link
Member

Choose a reason for hiding this comment

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

I understand it is not related to this PR, but using a function pointer is bit unconventional for Rust. Closure or trait object could be more idiomatic. Something like (not tested):

pub struct HostResourceDetector {
    host_id_detect: Box<dyn HostIdDetector>,
}

trait HostIdDetector {
    fn detect(&self) -> Option<String>;
}
#[cfg(target_os = "linux")]
struct LinuxHostIdDetector;

#[cfg(target_os = "linux")]
impl HostIdDetector for LinuxHostIdDetector {
    fn detect(&self) -> Option<String> {
       Some("my_host_id")
   }
}
#[cfg(not(target_os = "linux"))]
struct NonLinuxHostIdDetector;

#[cfg(not(target_os = "linux"))]
impl HostIdDetector for NonLinuxHostIdDetector {
    fn detect(&self) -> Option<String> {
        None
    }
}

But not for this PR. Commented just that we know it can be improved :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the feedback, I will look into it 👀

Copy link
Member

@lalitb lalitb left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks for the PR :)

@hdost hdost merged commit b92a850 into open-telemetry:main Apr 5, 2024
9 checks passed
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