

def submit_metric(self, name, value, mtype, tags=None, hostname=None, device_name=None, timestamp=None, sample_rate=1):
    hostname = (hostname if (hostname is not None) else self.hostname)
    if (tags is None):
        context = (name, tuple(), hostname, device_name)
    else:
        context = (name, tuple(sorted(set(tags))), hostname, device_name)
    cur_time = time()
    if ((timestamp is not None) and ((cur_time - int(timestamp)) > self.recent_point_threshold)):
        log.debug(('Discarding %s - ts = %s , current ts = %s ' % (name, timestamp, cur_time)))
        self.num_discarded_old_points += 1
    else:
        timestamp = (timestamp or cur_time)
        bucket_start_timestamp = self.calculate_bucket_start(timestamp)
        if (bucket_start_timestamp == self.current_bucket):
            metric_by_context = self.current_mbc
        else:
            if (bucket_start_timestamp not in self.metric_by_bucket):
                self.metric_by_bucket[bucket_start_timestamp] = {
                    
                }
            metric_by_context = self.metric_by_bucket[bucket_start_timestamp]
            self.current_bucket = bucket_start_timestamp
            self.current_mbc = metric_by_context
        if (context not in metric_by_context):
            metric_class = self.metric_type_to_class[mtype]
            metric_by_context[context] = metric_class(self.formatter, name, tags, hostname, device_name, self.metric_config.get(metric_class))
        metric_by_context[context].sample(value, sample_rate, timestamp)

dataset/ETHPy150Open serverdensity/sd-agent/aggregator.py MetricsBucketAggregator.submit_metric/original