opentelemetry-js icon indicating copy to clipboard operation
opentelemetry-js copied to clipboard

feat(opentelemetry-resources): add schema url

Open c-ehrlich opened this issue 5 months ago • 1 comments
trafficstars

Which problem is this PR solving?

Resolves https://github.com/open-telemetry/opentelemetry-js/issues/4182

Short description of the changes

The JavaScript SDK, unlike most others, currently does not give the ability to provide a Schema URL to a resource. See: https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/resource/sdk.md#resource-creation

This PR implements the ability to provide it.

There was a previous attempt at this by another contributor, which was closed: https://github.com/open-telemetry/opentelemetry-js/pull/5070

Type of change

  • [x] New feature (non-breaking change which adds functionality)
  • [x] This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

npm run test

  • [x] should create resource with schema URL
  • [x] should create resource without schema URL
  • [x] should merge resources with schema URL priority given to other resource
  • [x] should retain schema URL from base resource when other has no schema URL
  • [x] should retain schema URL from the resource that has it when merging
  • [x] should have empty schema URL when merging resources with no schema URL
  • [x] should handle merging with empty string schema URLs
  • [x] should maintain backward compatibility - getSchemaUrl is optional
  • [x] should work with async attributes and schema URLs

Checklist:

  • [x] Followed the style guidelines of this project
  • [x] Unit tests have been added
  • [ ] Documentation has been updated

c-ehrlich avatar Jun 12 '25 14:06 c-ehrlich