Merge "storage/carbonara: add timestamp as measure suffix"
This commit is contained in:
commit
e1eb923115
|
@ -16,6 +16,7 @@
|
|||
|
||||
import contextlib
|
||||
import ctypes
|
||||
import datetime
|
||||
import errno
|
||||
import time
|
||||
import uuid
|
||||
|
@ -113,9 +114,12 @@ class CephStorage(_carbonara.CarbonaraBasedStorage):
|
|||
# and enforce us to iterrate over all objects
|
||||
# So we create an object MEASURE_PREFIX, that have as
|
||||
# xattr the list of objects to process
|
||||
name = "_".join((
|
||||
self.MEASURE_PREFIX,
|
||||
str(metric.id),
|
||||
str(uuid.uuid4()),
|
||||
datetime.datetime.utcnow().strftime("%Y%M%d_%H:%M:%S")))
|
||||
with self._get_ioctx() as ioctx:
|
||||
name = "_".join((self.MEASURE_PREFIX, str(metric.id),
|
||||
str(uuid.uuid4())))
|
||||
ioctx.write_full(name, data)
|
||||
ioctx.set_xattr(self.MEASURE_PREFIX, name, "")
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
import contextlib
|
||||
import datetime
|
||||
import errno
|
||||
import os
|
||||
import shutil
|
||||
|
@ -59,9 +60,8 @@ class FileStorage(_carbonara.CarbonaraBasedStorage):
|
|||
path = os.path.join(self.measure_path, six.text_type(metric_id))
|
||||
if random_id:
|
||||
if random_id is True:
|
||||
# TODO(jd) include a timestamp in the filename
|
||||
return os.path.join(path,
|
||||
six.text_type(uuid.uuid4()))
|
||||
now = datetime.datetime.utcnow().strftime("_%Y%M%d_%H:%M:%S")
|
||||
random_id = six.text_type(uuid.uuid4()) + now
|
||||
return os.path.join(path, random_id)
|
||||
return path
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
import contextlib
|
||||
import datetime
|
||||
import uuid
|
||||
|
||||
from oslo_config import cfg
|
||||
|
@ -89,9 +90,10 @@ class SwiftStorage(_carbonara.CarbonaraBasedStorage):
|
|||
raise storage.MetricAlreadyExists(metric)
|
||||
|
||||
def _store_measures(self, metric, data):
|
||||
now = datetime.datetime.utcnow().strftime("_%Y%M%d_%H:%M:%S")
|
||||
self.swift.put_object(
|
||||
self.MEASURE_PREFIX,
|
||||
six.text_type(metric.id) + "/" + six.text_type(uuid.uuid4()),
|
||||
six.text_type(metric.id) + "/" + six.text_type(uuid.uuid4()) + now,
|
||||
data)
|
||||
|
||||
def _list_metric_with_measures_to_process(self):
|
||||
|
|
Loading…
Reference in New Issue