-
Notifications
You must be signed in to change notification settings - Fork 957
Make it impossible to remove mandatory resource attributes that the SDK has defaults for #5595
Description
Describe the bug
OTel semantic conventions mandate certain resource attributes to present, see telemetry sdk semantic conventions. I'm not sure why it is possible to remove the mandatory defaults but looking at the docs/examples, it seems it is intentional. I think it should be impossible to remove these attributes.
Steps to reproduce
This will erase the mandatory defaults:
SdkTracerProviderBuilder builder = SdkTracerProvider.builder()
.setResource(Resource.create(Attributes.of(...)));Users need to run extra circles to add them back:
SdkTracerProviderBuilder builder = SdkTracerProvider.builder()
.setResource(Resource.getDefault().merge(Resource.create(Attributes.of(...))));What did you expect to see?
Mandatory resource attributes should be always there even if the users call setResource on SdkTracerProviderBuilder.
What did you see instead?
Mandatory resource attributes are missing.
What version and what artifacts are you using?
Artifacts: opentelemetry-sdk
Version: 1.27.0
How did you reference these artifacts? implementation 'io.opentelemetry:opentelemetry-sdk:1.27.0'
Environment
Compiler: liberica-20.0.1+10
OS: MacOS 13.4.1
Additional context
N/A