Add a collector to the registry.
(self, collector: Collector)
| 35 | self.set_target_info(target_info) |
| 36 | |
| 37 | def register(self, collector: Collector) -> None: |
| 38 | """Add a collector to the registry.""" |
| 39 | with self._lock: |
| 40 | names = self._get_names(collector) |
| 41 | duplicates = set(self._names_to_collectors).intersection(names) |
| 42 | if duplicates: |
| 43 | raise ValueError( |
| 44 | 'Duplicated timeseries in CollectorRegistry: {}'.format( |
| 45 | duplicates)) |
| 46 | for name in names: |
| 47 | self._names_to_collectors[name] = collector |
| 48 | self._collector_to_names[collector] = names |
| 49 | if self._support_collectors_without_names and not names: |
| 50 | self._collectors_without_names.append(collector) |
| 51 | |
| 52 | def unregister(self, collector: Collector) -> None: |
| 53 | """Remove a collector from the registry.""" |