def gather_sample(self):
        """Invoked once per sample interval to gather a statistic.
        """
        
        def get_value_as_str(value):
            if type(value) is int:
                return "%d" % value
            elif type(value) is float:
                return "%f" % value
            elif type(value) is str:
                return "%r" % value
            else:
                return "%r" % value

        status = self._get_status(self._monitor_url)
        if status != None:
            stats = self._parse_general_status(status)
            heap = self._parse_heap_status(status)
            
            if stats != None:
                for key in stats.keys():
                    extra = None
                    if len(stats[key]) == 4:
                        extra = { stats[key][2] : stats[key][3] }
                    self._logger.emit_value("tomcat.runtime.%s" % stats[key][0], stats[key][1], extra)              
            if heap != None:
                for key in heap.keys():
                    extra = { heap[key][2] : heap[key][3] }
                    self._logger.emit_value("tomcat.memory_pools.%s" % heap[key][0], heap[key][1], extra)
dataset/ETHPy150Open scalyr/scalyr-agent-2/scalyr_agent/builtin_monitors/tomcat_monitor.py/TomcatMonitor.gather_sample/original