Skip to content

[issue-2688] Populate Resource schema URL from semantic convention version - #5665

Open
Rajkaran-122 wants to merge 1 commit into
open-telemetry:mainfrom
Rajkaran-122:main
Open

Rajkaran-122 wants to merge 1 commit into
open-telemetry:mainfrom
Rajkaran-122:main

Conversation

@Rajkaran-122

Copy link
Copy Markdown

Summary

  • Populate the Resource schema URL based on the semantic conventions version
  • Add focused regression tests
  • Align the implementation with the current OpenTelemetry specification

Testing

  • All existing tests pass (58 passed, 1 skipped)
  • Added new test class TestResourceDetectorsSchemaURL with focused schema URL tests
  • Ruff linting passes

Fixes #2688

…rsion

Implement the compliance spec from open-telemetry/opentelemetry-specification#2030
by populating the Resource schema URL based on the semantic conventions version.

Resource detectors that populate resource attributes according to OpenTelemetry
semantic conventions now ensure that the resource has a Schema URL set to a value
that matches the semantic conventions (Schemas.V1_44_0.value).

Changes:
- Modified ProcessResourceDetector, OsResourceDetector, _HostResourceDetector,
  and ServiceInstanceIdResourceDetector to include schema URL when creating Resources
- Updated Resource.create() to handle user-provided schema_url parameter to avoid
  conflicts with detector schema URLs
- OTELResourceDetector continues to use empty schema URL as per spec recommendation
  (it doesn't know what attributes it will populate)
- Added focused tests for schema URL functionality in resource detectors and merge behavior

The implementation follows the OpenTelemetry specification requirement that
resource detectors populating semantic convention attributes must set the schema URL.

Fixes open-telemetry#2688
@Rajkaran-122
Rajkaran-122 requested a review from a team as a code owner September 16, 2026 19:46

@herin049 herin049 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm personally a little hesitant on adding support for this to the SDK resource detectors. The primary reason is that it now forces users of the SDK to either have all of their custom resource detectors use version 1.44.0 or have no schema URL at all. This also puts a huge burden on resource detector implementations since they must release a new version of their package for every new version of semantic conventions that is released.

The intention behind the changes outlined in the spec are to prevent the creation of a resource object with an inconsistent state with attributes from different semantic convention versions. However, the big issue that it overlooks is that even if two resources have slightly different schema versions doesn't mean that they're incompatible. For example, if two resource detectors follow semconv versions 1.0.0 and 1.1.0, it could be that the attributes used in the first package haven't changed between version 1.0.0 and 1.1.0 meaning that it is also compatible with version 1.1.0.

resource = get_aggregated_resources(_build_resource_detectors(), _DEFAULT_RESOURCE).merge(
Resource(attributes, "")
)
resource = Resource(resource.attributes, schema_url)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't seem like the correct behavior to me and it mostly defeats the purpose of a user populating schema_url in the first place.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

Populate schema url for Resources based on the semantic conventions version

2 participants