opentelemetry-go-contrib icon indicating copy to clipboard operation
opentelemetry-go-contrib copied to clipboard

Add a host resource detector

Open pyohannes opened this issue 1 year ago • 9 comments
trafficstars

Fixes #5398

This PR adds a resource detector for physical hosts which sets values according to semantic conventions for host resources:

  • host.arch
  • host.id
  • host.name
  • host.ip
  • host.mac

pyohannes avatar Apr 16 '24 16:04 pyohannes

Codecov Report

Attention: Patch coverage is 93.84615% with 4 lines in your changes are missing coverage. Please review.

Project coverage is 62.5%. Comparing base (30ed923) to head (f585990).

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##            main   #5399     +/-   ##
=======================================
+ Coverage   62.3%   62.5%   +0.1%     
=======================================
  Files        189     191      +2     
  Lines      11575   11640     +65     
=======================================
+ Hits        7221    7282     +61     
- Misses      4145    4147      +2     
- Partials     209     211      +2     
Files Coverage Δ
detectors/host/host.go 96.6% <96.6%> (ø)
detectors/host/host_id_linux.go 60.0% <60.0%> (ø)

codecov[bot] avatar Apr 16 '24 16:04 codecov[bot]

This seems duplicative of WithHost. Why not update that option?

MrAlias avatar Apr 16 '24 18:04 MrAlias

This seems duplicative of WithHost. Why not update that option?

Indeed it is duplicative.

@MrAlias Do you think it a feasible option to populate host.arch via WithHost, and add additional WithHostIP and WithHostMAC to opt into host.ip and host.mac (all implemented in the SDK)?

pyohannes avatar Apr 17 '24 09:04 pyohannes

Taking a look at the host semantic conventions, it looks like they are all experimental (even host.name :grimacing:).

I think in the long term we want to make the WithHost option include all the recommended/required stable semantic conventions for a host. But in the interim, having a detector here is probably the correct approach.

I think this PR is the correct approach. I'll plan to review.

MrAlias avatar Apr 17 '24 20:04 MrAlias

Missing support for BSD: https://github.com/open-telemetry/opentelemetry-go/blob/main/sdk/resource/host_id_bsd.go Missing fallback when the host system is not supported for the host ID: https://github.com/open-telemetry/opentelemetry-go/blob/main/sdk/resource/host_id_unsupported.go

Thanks @MrAlias, this should be ready for another review.

pyohannes avatar Apr 22 '24 12:04 pyohannes

But in the interim, having a detector here is probably the correct approach.

@MrAlias Should we use feature environment variables instead of a new detector module?

dashpole avatar Apr 29 '24 13:04 dashpole

But in the interim, having a detector here is probably the correct approach.

@MrAlias Should we use feature environment variables instead of a new detector module?

That's a good idea.

MrAlias avatar May 01 '24 14:05 MrAlias

But in the interim, having a detector here is probably the correct approach.

@MrAlias Should we use feature environment variables instead of a new detector module?

That's a good idea.

I've added this to the SIG meeting agenda to discuss.

MrAlias avatar May 01 '24 14:05 MrAlias

@pyohannes can this be closed? We plan to move this into this (behind the experimental envar), right?

MrAlias avatar Jun 26 '24 16:06 MrAlias