def ImportDicts(self, dicts):
     for d in dicts:
         if d.get('type') in all_diagnostics.GetDiagnosticTypenames():
             diag = diagnostic.Diagnostic.FromDict(d)
             self._shared_diagnostics_by_guid[d['guid']] = diag
         else:
             hist = histogram_module.Histogram.FromDict(d)
             hist.diagnostics.ResolveSharedDiagnostics(self)
             self.AddHistogram(hist)
Beispiel #2
0
 def ImportDicts(self, dicts):
     for d in dicts:
         if 'type' in d:
             assert d['type'] in all_diagnostics.GetDiagnosticTypenames(), (
                 'Unrecognized shared diagnostic type ' + d['type'])
             diag = diagnostic.Diagnostic.FromDict(d)
             self._shared_diagnostics_by_guid[d['guid']] = diag
         else:
             hist = histogram_module.Histogram.FromDict(d)
             hist.diagnostics.ResolveSharedDiagnostics(self)
             self.AddHistogram(hist)
Beispiel #3
0
    def ImportLegacyDict(self, d):
        if 'type' in d:
            # TODO(benjhayden): Forget about TagMaps in 2019Q2.
            if d['type'] == 'TagMap':
                return

            assert d['type'] in all_diagnostics.GetDiagnosticTypenames(), (
                'Unrecognized shared diagnostic type ' + d['type'])
            diag = diagnostic.Diagnostic.FromDict(d)
            self._shared_diagnostics_by_guid[d['guid']] = diag
        else:
            hist = histogram.Histogram.FromDict(d)
            hist.diagnostics.ResolveSharedDiagnostics(self)
            self.AddHistogram(hist)
Beispiel #4
0
    def FromProto(d):
        # Here we figure out which field is set and downcast to the right diagnostic
        # type. The diagnostic names in the proto must be the same as the class
        # names in the python code, for instance Breakdown.
        attr_name = d.WhichOneof('diagnostic_oneof')
        assert attr_name, 'The diagnostic oneof cannot be empty.'

        d = getattr(d, attr_name)
        assert type(d).__name__ in all_diagnostics.GetDiagnosticTypenames(), (
            'Unrecognized diagnostic type ' + type(d).__name__)

        diag_type = type(d).__name__
        cls = all_diagnostics.GetDiagnosticClassForName(diag_type)

        return cls.FromProto(d)
 def testEqualityForSmoke(self):
     for name in all_diagnostics.GetDiagnosticTypenames():
         ctor = all_diagnostics.GetDiagnosticClassForName(name)
         self.assertTrue(hasattr(ctor, '__eq__'))