-
Notifications
You must be signed in to change notification settings - Fork 36
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
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
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. |
/// | ||
/// [`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>, | ||
} |
There was a problem hiding this comment.
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 :)
There was a problem hiding this comment.
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 👀
There was a problem hiding this 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 :)
Changes
Adds the "host.arch" resource attribute to the Host detector.
Merge requirement checklist
CHANGELOG.md
files updated for non-trivial, user-facing changes