in esrally/metrics.py [0:0]
def put_doc(self, doc, level=None, node_name=None, meta_data=None, absolute_time=None, relative_time=None):
"""
Adds a new document to the metrics store. It will merge additional properties into the doc such as timestamps or track info.
:param doc: The raw document as a ``dict``. Ownership is transferred to the metrics store (i.e. don't reuse that object).
:param level: Whether these are cluster or node-level metrics. May be ``None`` if not applicable.
:param node_name: The name of the node in case metrics are on node level.
:param meta_data: A dict, containing additional key-value pairs. Defaults to None.
:param absolute_time: The absolute timestamp in seconds since epoch when this metric record is stored. Defaults to None. The metrics
store will derive the timestamp automatically.
:param relative_time: The relative timestamp in seconds since the start of the benchmark when this metric record is stored.
Defaults to None. The metrics store will derive the timestamp automatically.
"""
if level == MetaInfoScope.cluster:
meta = self._meta_info[MetaInfoScope.cluster].copy()
elif level == MetaInfoScope.node:
meta = self._meta_info[MetaInfoScope.cluster].copy()
if node_name in self._meta_info[MetaInfoScope.node]:
meta.update(self._meta_info[MetaInfoScope.node][node_name])
elif level is None:
meta = None
else:
raise exceptions.SystemSetupError(f"Unknown meta info level [{level}]")
if meta and meta_data:
meta.update(meta_data)
if absolute_time is None:
absolute_time = self._clock.now()
if relative_time is None:
relative_time = self._stop_watch.split_time()
doc.update(
{
"@timestamp": time.to_epoch_millis(absolute_time),
"relative-time": convert.seconds_to_ms(relative_time),
"race-id": self._race_id,
"race-timestamp": self._race_timestamp,
"environment": self._environment_name,
"track": self._track,
"challenge": self._challenge,
"car": self._car_name,
}
)
if meta:
doc["meta"] = meta
if self._track_params:
doc["track-params"] = self._track_params
self._add(doc)