def METHOD_NAME(self) -> "Resource":
    try:
        if not os.environ.get(
            "ECS_CONTAINER_METADATA_URI"
        ) and not os.environ.get("ECS_CONTAINER_METADATA_URI_V4"):
            raise RuntimeError(
                "Missing ECS_CONTAINER_METADATA_URI therefore process is not on ECS."
            )
        container_id = ""
        try:
            with open(
                "/proc/self/cgroup", encoding="utf8"
            ) as container_info_file:
                for raw_line in container_info_file.readlines():
                    line = raw_line.strip()
                    # Subsequent IDs should be the same, exit if found one
                    if len(line) > _CONTAINER_ID_LENGTH:
                        container_id = line[-_CONTAINER_ID_LENGTH:]
                        break
        except FileNotFoundError as exception:
            logger.warning(
                "Failed to get container ID on ECS: %s.", exception
            )
        base_resource = Resource(
            {
                ResourceAttributes.CLOUD_PROVIDER: CloudProviderValues.AWS.value,
                ResourceAttributes.CLOUD_PLATFORM: CloudPlatformValues.AWS_ECS.value,
                ResourceAttributes.CONTAINER_NAME: socket.gethostname(),
                ResourceAttributes.CONTAINER_ID: container_id,
            }
        )
        metadata_v4_endpoint = os.environ.get(
            "ECS_CONTAINER_METADATA_URI_V4"
        )
        if not metadata_v4_endpoint:
            return base_resource
        # Returns https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task-metadata-endpoint-v4.html#task-metadata-endpoint-v4-response
        metadata_container = json.loads(_http_get(metadata_v4_endpoint))
        metadata_task = json.loads(
            _http_get(f"{metadata_v4_endpoint}/task")
        )
        task_arn = metadata_task["TaskARN"]
        base_arn = task_arn[0 : task_arn.rindex(":")]  # noqa
        cluster: str = metadata_task["Cluster"]
        cluster_arn = (
            cluster
            if cluster.startswith("arn:")
            else f"{base_arn}:cluster/{cluster}"
        )
        logs_resource = _get_logs_resource(metadata_container)
        return base_resource.merge(logs_resource).merge(
            Resource(
                {
                    ResourceAttributes.AWS_ECS_CONTAINER_ARN: metadata_container[
                        "ContainerARN"
                    ],
                    ResourceAttributes.AWS_ECS_CLUSTER_ARN: cluster_arn,
                    ResourceAttributes.AWS_ECS_LAUNCHTYPE: metadata_task[
                        "LaunchType"
                    ].lower(),
                    ResourceAttributes.AWS_ECS_TASK_ARN: task_arn,
                    ResourceAttributes.AWS_ECS_TASK_FAMILY: metadata_task[
                        "Family"
                    ],
                    ResourceAttributes.AWS_ECS_TASK_REVISION: metadata_task[
                        "Revision"
                    ],
                }
            )
        )
    # pylint: disable=broad-except
    except Exception as exception:
        if self.raise_on_error:
            raise exception
        logger.warning("%s failed: %s", self.__class__.__name__, exception)
        return Resource.get_empty()