'Extract useful tags from docker or platform APIs. These are collected by default.'

def get_tags(self, state, c_id):

    c_inspect = state.inspect_container(c_id)
    tags = self.dockerutil.extract_container_tags(c_inspect)
    if Platform.is_k8s():
        pod_metadata = state.get_kube_config(c_id, 'metadata')
        if (pod_metadata is None):
            log.warning(('Failed    to    fetch    pod    metadata    for    container    %s.    Kubernetes    tags    may    be    missing.' % c_id[:12]))
            return []
        kube_labels = pod_metadata.get('labels', {})
        for (label, value) in kube_labels.iteritems():
            tags.append(('%s:%s' % (label, value)))
        namespace = pod_metadata.get('namespace')
        tags.append(('kube_namespace:%s' % namespace))
        creator_tags = self.kubeutil.get_pod_creator_tags(pod_metadata)
        tags.extend(creator_tags)
        if self.kubeutil.collect_service_tag:
            services = self.kubeutil.match_services_for_pod(pod_metadata)
            for s in services:
                if (s is not None):
                    tags.append(('kube_service:%s' % s))
    elif Platform.is_swarm():
        c_labels = c_inspect.get('Config', {}).get('Labels', {})
        swarm_svc = c_labels.get(SWARM_SVC_LABEL)
        if swarm_svc:
            tags.append(('swarm_service:%s' % swarm_svc))
    elif Platform.is_rancher():
        service_name = c_inspect.get('Config', {}).get('Labels', {}).get(RANCHER_SVC_NAME)
        stack_name = c_inspect.get('Config', {}).get('Labels', {}).get(RANCHER_STACK_NAME)
        container_name = c_inspect.get('Config', {}).get('Labels', {}).get(RANCHER_CONTAINER_NAME)
        if service_name:
            tags.append(('rancher_service:%s' % service_name))
        if stack_name:
            tags.append(('rancher_stack:%s' % stack_name))
        if container_name:
            tags.append(('rancher_container:%s' % container_name))
    if self.metadata_collector.has_detected():
        orch_tags = self.metadata_collector.get_container_tags(co=c_inspect)
        tags.extend(orch_tags)
    return tags
