def register_metric_descriptor(self, oc_md):
        """Register a metric descriptor with stackdriver."""
        metric_type = self.get_metric_type(oc_md)
        with self._md_lock:
            if metric_type in self._md_cache:
                return self._md_cache[metric_type]

        descriptor = self.get_metric_descriptor(oc_md)
        project_name = self.client.project_path(self.options.project_id)
        sd_md = self.client.create_metric_descriptor(project_name, descriptor)
        with self._md_lock:
            self._md_cache[metric_type] = sd_md
        return sd_md
def register_metric_descriptor ( self , oc_md ) : metric_type = self . get_metric_type ( oc_md ) with self . _md_lock : if metric_type in self . _md_cache : return self . _md_cache [ metric_type ] descriptor = self . get_metric_descriptor ( oc_md ) project_name = self . client . project_path ( self . options . project_id ) sd_md = self . client . create_metric_descriptor ( project_name , descriptor ) with self . _md_lock : self . _md_cache [ metric_type ] = sd_md return sd_md
Register a metric descriptor with stackdriver.