def METHOD_NAME(self, samples: Samples, last_samples: Samples):
    data: List[Union[float, List[Optional[Union[float, bool]]]]] = []
    timestamp = time.time()
    self.next_timestamp = timestamp
    for metricinfo in self.metrics:
        value = samples[metricinfo.desc.name]
        if metricinfo.desc.instanced:
            old_value = last_samples[metricinfo.desc.name]
            assert isinstance(value, dict)
            assert isinstance(old_value, dict)
            # If we have less or more keys the data changed, send a meta message.
            if value.keys() != old_value.keys():
                self.need_meta = True
            if metricinfo.derive == 'rate':
                instances: List[Optional[Union[float, bool]]] = []
                for key, val in value.items():
                    instances.append(self.calculate_sample_rate(val, old_value.get(key)))
                data.append(instances)
            else:
                data.append(list(value.values()))
        else:
            old_value = last_samples.get(metricinfo.desc.name)
            assert not isinstance(value, dict)
            assert not isinstance(old_value, dict)
            if metricinfo.derive == 'rate':
                data.append(self.calculate_sample_rate(value, old_value))
            else:
                data.append(value)
    if self.need_meta:
        self.send_meta(samples, timestamp)
    self.last_timestamp = self.next_timestamp
    self.send_data(json.dumps([data]).encode())