def start(self): """Start the scheduler.""" self._periodic = _periodic.PeriodicThread( self.interval, self.flush, name="%s:%s" % (__name__, self.__class__.__name__)) LOG.debug("Starting scheduler") self._last_export = compat.time_ns() self._periodic.start() LOG.debug("Scheduler started")
def flush(self): """Flush events from recorder to exporters.""" LOG.debug("Flushing events") events = self.recorder.reset() start = self._last_export self._last_export = compat.time_ns() total_events = sum(len(v) for v in events.values()) for exp in self.exporters: try: exp.export(events, start, self._last_export) except exporter.ExportError as e: LOG.error("Unable to export %d events: %s", total_events, _traceback.format_exception(e)) except Exception: LOG.exception("Error while exporting %d events", total_events)
def flush(self): """Flush events from recorder to exporters.""" LOG.debug("Flushing events") if self.exporters: events = self.recorder.reset() start = self._last_export self._last_export = compat.time_ns() for exp in self.exporters: try: exp.export(events, start, self._last_export) except exporter.ExportError as e: LOG.error("Unable to export profile: %s. Ignoring.", _traceback.format_exception(e)) except Exception: LOG.exception( "Unexpected error while exporting events. " "Please report this bug to https://github.com/DataDog/dd-trace-py/issues" )
def test_export(endpoint_test_server): exp = http.PprofHTTPExporter(_ENDPOINT, _API_KEY) exp.export(test_pprof.TEST_EVENTS, 0, compat.time_ns())
def start(self): """Start the scheduler.""" LOG.debug("Starting scheduler") super(Scheduler, self).start() self._last_export = compat.time_ns() LOG.debug("Scheduler started")