def __check_mapping()

in scripts/generators/otel.py [0:0]


    def __check_mapping(self, details):
        field_details = details['field_details']
        if 'flat_name' in field_details and (not 'intermediate' in field_details or not field_details['intermediate']):
            ecs_field_name = field_details['flat_name']
            if 'otel' in field_details:
                for otel in field_details['otel']:
                    if not 'relation' in otel:
                        raise ValueError(
                            f"On field '{field_details['flat_name']}': OTel mapping must specify the 'relation' property!")

                    if otel['relation'] == 'metric':
                        must_have(ecs_field_name, otel, otel['relation'], 'metric')
                        must_not_have(ecs_field_name, otel, otel['relation'], 'attribute')
                        must_not_have(ecs_field_name, otel, otel['relation'], 'otlp_field')
                        must_not_have(ecs_field_name, otel, otel['relation'], 'stability')
                        self.__check_metric_name(ecs_field_name, otel['metric'])
                    elif otel['relation'] == 'otlp':
                        must_have(ecs_field_name, otel, otel['relation'], 'otlp_field')
                        must_have(ecs_field_name, otel, otel['relation'], 'stability')
                        must_not_have(ecs_field_name, otel, otel['relation'], 'attribute')
                        must_not_have(ecs_field_name, otel, otel['relation'], 'metric')
                    elif otel['relation'] == 'na':
                        must_not_have(ecs_field_name, otel, otel['relation'], 'otlp_field')
                        must_not_have(ecs_field_name, otel, otel['relation'], 'attribute')
                        must_not_have(ecs_field_name, otel, otel['relation'], 'metric')
                        must_not_have(ecs_field_name, otel, otel['relation'], 'stability')
                    elif otel['relation'] == 'match':
                        must_not_have(ecs_field_name, otel, otel['relation'], 'otlp_field')
                        must_not_have(ecs_field_name, otel, otel['relation'], 'attribute')
                        must_not_have(ecs_field_name, otel, otel['relation'], 'metric')
                        must_not_have(ecs_field_name, otel, otel['relation'], 'stability')
                    elif otel['relation'] == 'equivalent' or otel['relation'] == 'related' or otel['relation'] == 'conflict':
                        must_have(ecs_field_name, otel, otel['relation'], 'attribute')
                        must_not_have(ecs_field_name, otel, otel['relation'], 'otlp_field')
                        must_not_have(ecs_field_name, otel, otel['relation'], 'metric')
                        must_not_have(ecs_field_name, otel, otel['relation'], 'stability')
                        self.__check_attribute_name(field_details, otel)
                    else:
                        raise ValueError(
                            f"On field '{field_details['flat_name']}': Invalid relation type '{otel['relation']}'")

            elif ecs_field_name in self.otel_attribute_names:
                print(
                    f'WARNING: Field "{ecs_field_name}" exists in OTel Semantic Conventions with exactly the same name but is not mapped in ECS!')