nodes: 0, module; 1, function_definition; 2, function_name:_update_pods_metrics; 3, parameters; 4, block; 5, identifier:self; 6, identifier:instance; 7, identifier:pods; 8, expression_statement; 9, expression_statement; 10, for_statement; 11, expression_statement; 12, for_statement; 13, comment:"""
          Reports the number of running pods on this node, tagged by service and creator
  
          We go though all the pods, extract tags then count them by tag list, sorted and
          serialized in a pipe-separated string (it is an illegar character for tags)
          """; 14, assignment; 15, identifier:pod; 16, subscript; 17, block; 18, assignment; 19, pattern_list; 20, call; 21, block; 22, identifier:tags_map; 23, call; 24, identifier:pods; 25, string; 26, expression_statement; 27, expression_statement; 28, expression_statement; 29, if_statement; 30, if_statement; 31, expression_statement; 32, identifier:commmon_tags; 33, call; 34, identifier:pod_tags; 35, identifier:pod_count; 36, attribute; 37, argument_list; 38, expression_statement; 39, expression_statement; 40, expression_statement; 41, identifier:defaultdict; 42, argument_list; 43, string_content:items; 44, assignment; 45, assignment; 46, assignment; 47, call; 48, block; 49, comparison_operator:'namespace' in pod_meta; 50, block; 51, augmented_assignment; 52, attribute; 53, argument_list; 54, identifier:tags_map; 55, identifier:iteritems; 56, assignment; 57, call; 58, call; 59, identifier:int; 60, identifier:pod_meta; 61, call; 62, identifier:pod_tags; 63, call; 64, identifier:services; 65, call; 66, identifier:isinstance; 67, argument_list; 68, for_statement; 69, string; 70, identifier:pod_meta; 71, expression_statement; 72, subscript; 73, integer:1; 74, identifier:instance; 75, identifier:get; 76, string; 77, list; 78, identifier:tags; 79, call; 80, attribute; 81, argument_list; 82, attribute; 83, argument_list; 84, attribute; 85, argument_list; 86, attribute; 87, argument_list; 88, attribute; 89, argument_list; 90, identifier:services; 91, identifier:list; 92, identifier:service; 93, identifier:services; 94, block; 95, string_content:namespace; 96, call; 97, identifier:tags_map; 98, call; 99, string_content:tags; 100, identifier:list; 101, argument_list; 102, identifier:tags; 103, identifier:extend; 104, identifier:commmon_tags; 105, identifier:self; 106, identifier:publish_gauge; 107, identifier:self; 108, binary_operator:NAMESPACE + '.pods.running'; 109, identifier:pod_count; 110, identifier:tags; 111, identifier:pod; 112, identifier:get; 113, string; 114, dictionary; 115, attribute; 116, identifier:get_pod_creator_tags; 117, identifier:pod_meta; 118, keyword_argument; 119, attribute; 120, identifier:match_services_for_pod; 121, identifier:pod_meta; 122, expression_statement; 123, attribute; 124, argument_list; 125, identifier:frozenset; 126, argument_list; 127, identifier:pod_tags; 128, identifier:NAMESPACE; 129, string; 130, string_content:metadata; 131, identifier:self; 132, identifier:kubeutil; 133, identifier:legacy_rep_controller_tag; 134, True; 135, identifier:self; 136, identifier:kubeutil; 137, call; 138, identifier:pod_tags; 139, identifier:append; 140, binary_operator:'kube_namespace:%s' % pod_meta['namespace']; 141, identifier:pod_tags; 142, string_content:.pods.running; 143, attribute; 144, argument_list; 145, string; 146, subscript; 147, identifier:pod_tags; 148, identifier:append; 149, binary_operator:'kube_service:%s' % service; 150, string_content:kube_namespace:%s; 151, identifier:pod_meta; 152, string; 153, string; 154, identifier:service; 155, string_content:namespace; 156, string_content:kube_service:%s
code: def _update_pods_metrics(self, instance, pods):
          """
          Reports the number of running pods on this node, tagged by service and creator
  
          We go though all the pods, extract tags then count them by tag list, sorted and
          serialized in a pipe-separated string (it is an illegar character for tags)
          """
          tags_map = defaultdict(int)
          for pod in pods['items']:
              pod_meta = pod.get('metadata', {})
              pod_tags = self.kubeutil.get_pod_creator_tags(pod_meta, legacy_rep_controller_tag=True)
              services = self.kubeutil.match_services_for_pod(pod_meta)
              if isinstance(services, list):
                  for service in services:
                      pod_tags.append('kube_service:%s' % service)
              if 'namespace' in pod_meta:
                  pod_tags.append('kube_namespace:%s' % pod_meta['namespace'])
  
              tags_map[frozenset(pod_tags)] += 1
  
          commmon_tags = instance.get('tags', [])
          for pod_tags, pod_count in tags_map.iteritems():
              tags = list(pod_tags)
              tags.extend(commmon_tags)
              self.publish_gauge(self, NAMESPACE + '.pods.running', pod_count, tags)