diff --git a/semantic-conventions/src/opentelemetry/semconv/model/semantic_convention.py b/semantic-conventions/src/opentelemetry/semconv/model/semantic_convention.py index afe7b36c..f0a0dce0 100644 --- a/semantic-conventions/src/opentelemetry/semconv/model/semantic_convention.py +++ b/semantic-conventions/src/opentelemetry/semconv/model/semantic_convention.py @@ -431,33 +431,14 @@ def _populate_extends_single(self, semconv, unprocessed): parent_attributes = {} for ext_attr in extended.attributes: parent_attributes[ext_attr.fqn] = ext_attr.inherit_attribute() - parent_attributes.update(semconv.attrs_by_name) - # By induction, parent semconv is already correctly sorted - # but the combination of parent and current attributes is not - if parent_attributes or semconv.attributes: - semconv.attrs_by_name = SemanticConventionSet._sort_attributes_dict( - parent_attributes - ) + semconv.attrs_by_name.update(parent_attributes) + + semconv.attrs_by_name = dict(sorted((semconv.attrs_by_name.items()))) - elif semconv.attributes: # No parent, sort of current attributes - semconv.attrs_by_name = SemanticConventionSet._sort_attributes_dict( - semconv.attrs_by_name - ) # delete from remaining semantic conventions to process del unprocessed[semconv.semconv_id] - @staticmethod - def _sort_attributes_dict( - attributes: typing.Dict[str, SemanticAttribute] - ) -> typing.Dict[str, SemanticAttribute]: - """ - First imported, and then defined attributes. - :param attributes: Dictionary of attributes to sort - :return: A sorted dictionary of attributes - """ - return dict(sorted(attributes.items())) - def _populate_anyof_attributes(self): any_of: AnyOf for semconv in self.models.values():