예제 #1
0
    def recorditer(self, inputstr):
        jparams = JSONParamsParser(PARAMS_TAG)
        assert jparams.count(inputstr) == 1, "Cannot process logs with more than one record"

        for pdict in itertools.izip(jparams.idict_from_json(inputstr)):

            piperesults = {}

            # process the total times
            for m in re.finditer(self._time_pat, inputstr):
                num = m.group('num')
                time = m.group('time')
                d = piperesults.get(num, {})
                d['pipeline_time'] = time

            # process the starts
            for m in re.finditer(self._start_pat, inputstr):
                num = m.group('num')
                time = m.group('time')
                d = piperesults.get(num, {})
                d['pipeline_start'] = time

            # process the ends
            for m in re.finditer(self._end_pat, inputstr):
                num = m.group('num')
                time = m.group('time')
                d = piperesults.get(num, {})
                d['pipeline_end'] = time

            # combine into records
            for num, d in piperesults.iteritems():
                d['pipeline_id'] = num
                cr = pdict.copy()
                cr.update(d)
                yield cr
예제 #2
0
    def recorditer(self, inputstr):
        jparams = JSONParamsParser(PARAMS_TAG)
        sparams = JSONParamsParser('STATS')

        if self.includes_params:
            assert jparams.count(inputstr) == sparams.count(inputstr), \
                "different numbers of STATS and PARAMS; " \
                "check your log file for errors"
            # concurrently search for adjacent pairs of PARAMS and STATS
            for pdict, sdict in itertools.izip(
                jparams.idict_from_json(inputstr),
                    sparams.idict_from_json(inputstr)):

                result = {}
                result.update(pdict)
                result.update(sdict)
                yield result
        else:
            for sdict in itertools.izip(
                    jparams.idict_from_json(inputstr)):

                result = {}
                result.update(sdict)
                yield result