[issue-2688] Populate Resource schema URL from semantic convention version - #5665
Rajkaran-122 wants to merge 1 commit into
Conversation
…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
herin049
left a comment
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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.
Summary
Testing
Fixes #2688