def detect()

in opentelemetry-resourcedetector-gcp/src/opentelemetry/resourcedetector/gcp_resource_detector/__init__.py [0:0]


    def detect(self) -> "Resource":
        if not self.cached:
            self.cached = True
            for resource_type, resource_finder in _RESOURCE_FINDERS:
                try:
                    found_resources = resource_finder()
                # pylint: disable=broad-except
                except Exception as ex:
                    logger.warning(
                        "Exception %s occured attempting %s resource detection",
                        ex,
                        resource_type,
                    )
                    found_resources = None
                if found_resources:
                    self.gcp_resources = found_resources
                    break
        if self.raise_on_error and not self.gcp_resources:
            raise NoGoogleResourcesFound()
        return Resource(self.gcp_resources)