opentelemetry-sdk: add ServiceInstanceIdResourceDetector for populating service.instance.id#5259
opentelemetry-sdk: add ServiceInstanceIdResourceDetector for populating service.instance.id#5259herin049 wants to merge 7 commits into
Conversation
|
Let's give a short chance for anyone else to comment, otherwise please move to "Ready to Merge" |
There was a problem hiding this comment.
Pull request overview
Adds an opt-in SDK resource detector to populate the OpenTelemetry service.instance.id resource attribute (via resource detector entry points), plus tests and a changelog entry.
Changes:
- Introduce
ServiceInstanceIdResourceDetectorthat setsservice.instance.idto a UUID. - Register the detector under the
opentelemetry_resource_detectorentry point asservice_instance(opt-in viaOTEL_EXPERIMENTAL_RESOURCE_DETECTORS). - Add unit tests covering UUID format and detector enablement, and add a changelog note.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
opentelemetry-sdk/src/opentelemetry/sdk/resources/__init__.py |
Adds the new ServiceInstanceIdResourceDetector implementation. |
opentelemetry-sdk/pyproject.toml |
Registers the detector as an entry point (service_instance). |
opentelemetry-sdk/tests/resources/test_resources.py |
Adds tests for UUID validity and opt-in activation via env var. |
.changelog/5259.added |
Records the new feature in the changelog. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
emdneto
left a comment
There was a problem hiding this comment.
I'm fine with it, but I would prefer to be enabled by default in the Otel detector. Any thoughts?
@aabmass Good thing I looked over this again... I realized I made a very silly mistake 🤣 As implemented the |
@emdneto I can enable this by default, but I wanted to keep it separate from |
Description
Creates a new
ServiceInstanceIdResourceDetectorfor populating theservice.instance.idresource attribute with a unique v4 UUID per the OTel spec:In order to provide maximal flexibility, I have implemented these additions by creating an additional resource detector which must be enabled manually. If the SIG is ok with adding this resource attribute by default, I am open to instead adding this attribute directly in the existing
OTELResourceDetectorresource detector.Fixes #5257
Type of change
Please delete options that are not relevant.
How Has This Been Tested?
Does This PR Require a Contrib Repo Change?
Checklist: