Skip to content

Make it impossible to remove mandatory resource attributes that the SDK has defaults for #5595

@jonatan-ivanov

Description

@jonatan-ivanov

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions