skywalking/client/__init__.py [53:95]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    @staticmethod
    def get_instance_properties() -> List[dict]:
        """
        Get current running Python interpreter's system properties.
        Returns: [{'key': str, 'value': str}, ...]
        """
        try:
            properties = [
                {'key': 'language', 'value': 'python'},
                {'key': 'OS Name', 'value': os.name},
                {'key': 'Process No.', 'value': str(os.getpid())},
                {'key': 'hostname', 'value': socket.gethostname()},
                {'key': 'ipv4', 'value': '; '.join(socket.gethostbyname_ex(socket.gethostname())[2])},
                {'key': 'python_implementation', 'value': platform.python_implementation()},
                {'key': 'python_version', 'value': platform.python_version()},
            ]

        except Exception as e:  # noqa
            logger.exception('Failed to get OS info, fallback to basic properties.')
            properties = [
                {'key': 'language', 'value': 'python'},
                {'key': 'Process No.', 'value': str(os.getpid())},
            ]

        namespace = config.agent_namespace
        if namespace:
            properties.append({'key': 'namespace', 'value': namespace})

        instance_properties_json = config.agent_instance_properties_json
        if instance_properties_json:
            # load instance properties from json string
            json_properties = json.loads(instance_properties_json)
            for key, value in json_properties.items():
                properties.append({'key': key, 'value': value})

        return properties

    def get_instance_properties_proto(self) -> List[KeyStringValuePair]:
        """
        Converts to protobuf format.
        Returns: [KeyStringValuePair, ...]
        """
        return [KeyStringValuePair(key=prop['key'], value=prop['value']) for prop in self.get_instance_properties()]
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



skywalking/client/__init__.py [164:206]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    @staticmethod
    def get_instance_properties() -> List[dict]:
        """
        Get current running Python interpreter's system properties.
        Returns: [{'key': str, 'value': str}, ...]
        """
        try:
            properties = [
                {'key': 'language', 'value': 'python'},
                {'key': 'OS Name', 'value': os.name},
                {'key': 'Process No.', 'value': str(os.getpid())},
                {'key': 'hostname', 'value': socket.gethostname()},
                {'key': 'ipv4', 'value': '; '.join(socket.gethostbyname_ex(socket.gethostname())[2])},
                {'key': 'python_implementation', 'value': platform.python_implementation()},
                {'key': 'python_version', 'value': platform.python_version()},
            ]

        except Exception as e:  # noqa
            logger.exception('Failed to get OS info, fallback to basic properties.')
            properties = [
                {'key': 'language', 'value': 'python'},
                {'key': 'Process No.', 'value': str(os.getpid())},
            ]

        namespace = config.agent_namespace
        if namespace:
            properties.append({'key': 'namespace', 'value': namespace})

        instance_properties_json = config.agent_instance_properties_json
        if instance_properties_json:
            # load instance properties from json string
            json_properties = json.loads(instance_properties_json)
            for key, value in json_properties.items():
                properties.append({'key': key, 'value': value})

        return properties

    def get_instance_properties_proto(self) -> List[KeyStringValuePair]:
        """
        Converts to protobuf format.
        Returns: [KeyStringValuePair, ...]
        """
        return [KeyStringValuePair(key=prop['key'], value=prop['value']) for prop in self.get_instance_properties()]
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



