docstr: Store new measurements to the database.
  
  Take measurements and store them into
  the metrics collection in the database.
  Additionally, reference the metrics
  in the info["metrics"] dictionary.
docstr_tok: ["Store","new","measurements","to","the","database",".","Take","measurements","and","store","them","into","the","metrics","collection","in","the","database",".","Additionally",",","reference","the","metrics","in","the","info","[","``","metrics","''","]","dictionary","."]
code: def log_metrics(self, metrics_by_name, info):
      """Store new measurements to the database.
  
      Take measurements and store them into
      the metrics collection in the database.
      Additionally, reference the metrics
      in the info["metrics"] dictionary.
      """
      if self.metrics is None:
          # If, for whatever reason, the metrics collection has not been set
          # do not try to save anything there.
          return
      for key in metrics_by_name:
          query = {"run_id": self.run_entry["_id"], "name": key}
          push = {
              "steps": {"$each": metrics_by_name[key]["steps"]},
              "values": {"$each": metrics_by_name[key]["values"]},
              "timestamps": {
                  "$each": metrics_by_name[key]["timestamps"]
              },
          }
          update = {"$push": push}
          result = self.metrics.update_one(query, update, upsert=True)
          if result.upserted_id is not None:
              # This is the first time we are storing this metric
              info.setdefault("metrics", []).append(
                  {"name": key, "id": str(result.upserted_id)}
              )
  
imports: from typing import Optional, Union
  import mimetypes
  import os.path
  import pickle
  import re
  import sys
  import time
  from tempfile import NamedTemporaryFile
  import warnings
  import sacred.optional
  from sacred.commandline_options import cli_option
  from sacred.dependencies import get_digest
  from sacred.observers.base import RunObserver
  from sacred.observers.queue import QueueObserver
  from sacred.serializer import flatten
  from sacred.utils import ObserverError, PathType
  import pkg_resources
label_desc: Use image node_id 14 for calling the MongoObserver obj's underlying member method code with example usage: obj.log_metrics(metrics_by_name, info) without return types