diff --git a/ceilometer/publisher/__init__.py b/ceilometer/publisher/__init__.py index 33995778d..df2b39e17 100644 --- a/ceilometer/publisher/__init__.py +++ b/ceilometer/publisher/__init__.py @@ -44,4 +44,4 @@ class PublisherBase(object): @abc.abstractmethod def publish_samples(self, context, samples): - "Publish counters into final conduit." + "Publish samples into final conduit." diff --git a/ceilometer/publisher/file.py b/ceilometer/publisher/file.py index d59267253..e529ff0e9 100644 --- a/ceilometer/publisher/file.py +++ b/ceilometer/publisher/file.py @@ -86,11 +86,11 @@ class FilePublisher(publisher.PublisherBase): rfh.setLevel(logging.INFO) self.publisher_logger.addHandler(rfh) - def publish_samples(self, context, counters): + def publish_samples(self, context, samples): """Send a metering message for publishing :param context: Execution context from the service or RPC call - :param counter: Counter from pipeline after transformation + :param samples: Samples from pipeline after transformation """ if self.publisher_logger: - self.publisher_logger.info(counters) + self.publisher_logger.info(samples) diff --git a/ceilometer/publisher/rpc.py b/ceilometer/publisher/rpc.py index 441dbef87..99f22a859 100644 --- a/ceilometer/publisher/rpc.py +++ b/ceilometer/publisher/rpc.py @@ -15,7 +15,7 @@ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. -"""Publish a counter using the preferred RPC mechanism. +"""Publish a sample using the preferred RPC mechanism. """ import hashlib @@ -84,23 +84,23 @@ def verify_signature(message, secret): return new_sig == old_sig -def meter_message_from_counter(counter, secret): +def meter_message_from_counter(sample, secret): """Make a metering message ready to be published or stored. Returns a dictionary containing a metering message - for a notification message and a Counter instance. + for a notification message and a Sample instance. """ - msg = {'source': counter.source, - 'counter_name': counter.name, - 'counter_type': counter.type, - 'counter_unit': counter.unit, - 'counter_volume': counter.volume, - 'user_id': counter.user_id, - 'project_id': counter.project_id, - 'resource_id': counter.resource_id, - 'timestamp': counter.timestamp, - 'resource_metadata': counter.resource_metadata, - 'message_id': counter.id, + msg = {'source': sample.source, + 'counter_name': sample.name, + 'counter_type': sample.type, + 'counter_unit': sample.unit, + 'counter_volume': sample.volume, + 'user_id': sample.user_id, + 'project_id': sample.project_id, + 'resource_id': sample.resource_id, + 'timestamp': sample.timestamp, + 'resource_metadata': sample.resource_metadata, + 'message_id': sample.id, } msg['message_signature'] = compute_signature(msg, secret) return msg @@ -136,19 +136,19 @@ class RPCPublisher(publisher.PublisherBase): % self.policy) self.policy = 'default' - def publish_samples(self, context, counters): - """Publish counters on RPC. + def publish_samples(self, context, samples): + """Publish samples on RPC. :param context: Execution context from the service or RPC call. - :param counters: Counters from pipeline after transformation. + :param samples: Samples from pipeline after transformation. """ meters = [ meter_message_from_counter( - counter, + sample, cfg.CONF.publisher_rpc.metering_secret) - for counter in counters + for sample in samples ] topic = cfg.CONF.publisher_rpc.metering_topic @@ -157,7 +157,7 @@ class RPCPublisher(publisher.PublisherBase): 'version': '1.0', 'args': {'data': meters}, } - LOG.audit('Publishing %d counters on %s', + LOG.audit('Publishing %d samples on %s', len(msg['args']['data']), topic) self.local_queue.append((context, topic, msg)) @@ -171,7 +171,7 @@ class RPCPublisher(publisher.PublisherBase): 'args': {'data': list(meter_list)}, } topic_name = topic + '.' + meter_name - LOG.audit('Publishing %d counters on %s', + LOG.audit('Publishing %d samples on %s', len(msg['args']['data']), topic_name) self.local_queue.append((context, topic_name, msg)) @@ -197,7 +197,7 @@ class RPCPublisher(publisher.PublisherBase): count = queue_length - self.max_queue_length self.local_queue = self.local_queue[count:] LOG.warn("Publisher max local_queue length is exceeded, " - "dropping %d oldest counters", count) + "dropping %d oldest samples", count) @staticmethod def _process_queue(queue, policy): @@ -220,14 +220,14 @@ class RPCPublisher(publisher.PublisherBase): try: rpc.cast(context, topic, msg) except (SystemExit, rpc.common.RPCException): - counters = sum([len(m['args']['data']) for _, _, m in queue]) + samples = sum([len(m['args']['data']) for _, _, m in queue]) if policy == 'queue': - LOG.warn("Failed to publish %s counters, queue them", - counters) + LOG.warn("Failed to publish %s samples, queue them", + samples) return queue elif policy == 'drop': - LOG.warn("Failed to publish %d counters, dropping them", - counters) + LOG.warn("Failed to publish %d samples, dropping them", + samples) return [] # default, occur only if rabbit_max_retries > 0 raise diff --git a/ceilometer/publisher/udp.py b/ceilometer/publisher/udp.py index 0ee651407..cceecf48b 100644 --- a/ceilometer/publisher/udp.py +++ b/ceilometer/publisher/udp.py @@ -15,7 +15,7 @@ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. -"""Publish a counter using an UDP mechanism +"""Publish a sample using an UDP mechanism """ from ceilometer import publisher @@ -41,23 +41,23 @@ class UDPPublisher(publisher.PublisherBase): self.socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) - def publish_samples(self, context, counters): + def publish_samples(self, context, samples): """Send a metering message for publishing :param context: Execution context from the service or RPC call - :param counter: Counter from pipeline after transformation + :param samples: Samples from pipeline after transformation """ - for counter in counters: - msg = counter.as_dict() + for sample in samples: + msg = sample.as_dict() host = self.host port = self.port - LOG.debug(_("Publishing counter %(msg)s over UDP to " + LOG.debug(_("Publishing sample %(msg)s over UDP to " "%(host)s:%(port)d") % {'msg': msg, 'host': host, 'port': port}) try: self.socket.sendto(msgpack.dumps(msg), (self.host, self.port)) except Exception as e: - LOG.warn(_("Unable to send counter over UDP")) + LOG.warn(_("Unable to send sample over UDP")) LOG.exception(e)