Skip to content

Allow to reuse more code from existing SDK, for example resource host detector #1489

Description

@GrzegorzDrozd

service.instance.id should be used to create a unique combination of service.namespace, service.name,service.instance.id. I could use host.id for this purpose as it is detected in \OpenTelemetry\SDK\Resource\Detectors\Host::getMachineId. However, that method is private and accessible only via getResource, which performs additional tasks beyond what I need. Furthermore, getResource uses static methods across different objects, and I cannot guarantee that these implementations won't change in the future, potentially affecting data collection.

I have noticed similar patterns in other places. While I understand that adding methods like getAttribute directly on a span is discouraged, limiting access to system information in such a restrictive way seems problematic.

Is your feature request related to a problem?
Yes, the lack of a standardized way to retrieve host.id for use in attributes (either directly or as part of a hash, for example).

Describe the solution you'd like

  1. Make the getMachineId method publicly accessible and static.
  2. Review the SDK to identify and address other areas where increased openness could be beneficial.

Describe alternatives you've considered
Re-implementing the logic from getMachineId independently.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions