Unify the timestamp of samples generated by polling agents

https://blueprints.launchpad.net/ceilometer/+spec/unify-timestamp-of-polled-data

Problem description

Many of the pollsters define the timestamp individually for each generated sample, which should really be timestamping based on when the data was polled and not when each sample is generated. We need to set the timestamp of the polled data to the timestamp when the polling starts for unity.

This should save overhead of calculating timestamp each sample and also allow for easier grouping of polled data.

Proposed change

Modify ceilometer.agent.manager.PollingTask.poll_and_notify method to set the timestamp of samples to the time when the data was polled:

# Get the timestamp when pollster starts to work
polling_timestamp = self._get_current_timestamp()

samples = pollster.obj.get_samples(
    manager=self.manager,
    cache=cache,
    resources=polling_resources
)

for sample in samples:
# Unify the timestamp of polled samples
sample.set_timestamp(polling_timestamp)

Drop all the timestamp generations when we build samples via pollsters, like: https://github.com/openstack/ceilometer/blob/6.0.0.0b2/ceilometer/image/glance.py#L113

Alternatives

None

Data model impact

None

REST API impact

None

Security impact

None

Pipeline impact

None

Other end user impact

None

Performance/Scalability Impacts

Save overhead of calculating timestamp each sample.

Other deployer impact

None

Developer impact

None

Implementation

Assignee(s)

Primary assignee:

<yuywz>

Work Items

Update ceilometer.agent.manager.PollingTask.poll_and_notify method.

Drop all the timestamp generations when we build samples via pollsters.

Future lifecycle

None

Dependencies

None

Testing

Add unit test to test: The timestamp of samples generated during a polling cycle is unified.

Documentation Impact

None

References

Originally reported as a bug: https://bugs.launchpad.net/ceilometer/+bug/1491509 Blueprint: https://blueprints.launchpad.net/ceilometer/+spec/unify-timestamp-of-polled-data