code: def collect(self):
          
          samples = {}
          if self._counters:
              samples.update(
                  {label: {"value": c.val} for label, c in compat.iteritems(self._counters) if c is not noop_metric}
              )
          if self._gauges:
              samples.update(
                  {label: {"value": g.val} for label, g in compat.iteritems(self._gauges) if g is not noop_metric}
              )
          if samples:
              return {"samples": samples, "timestamp": int(time.time() * 1000000)}
docs: Collects all metrics attached to this metricset, and returns it as a list, together with a timestamp
          in microsecond precision.
  
          The format of the return value should be
  
              {
                  "samples": {"metric.name": {"value": some_float}, ...},
                  "timestamp": unix epoch in microsecond precision
              }