[Seems that is doable, Ive ended up doing something like this
```
class MyRegistry(CollectorRegistry)
def collect(self):
"""Yields metrics from the collectors in the registry."""
for metric in super().collect():
metric.samples = [
Sample(
name=
sample.name,
labels=dict(**sample.labels,
service_name=self._service_name),
value=sample.value,
timestamp=sample.timestamp,
exemplar=sample.exemplar
) for sample in metric.samples ]
yield metric
```
But this implementation have some sort of coupling with the current
implementation, first needs to know what attributes the `Sample`
object has, which it's not clear to me if this object is a public
object or not, and second also relays on the fact that the creation of
a new list of samples would not have any downside effect behind the
scenes, so in any case, this would mutate the original metric. Seems
that nowadays this can be guaranteed, but who knows what could happen
in the future.
Would it make sense to move this feature within the Python client in some way?
> --
> You received this message because you are subscribed to the Google Groups "Prometheus Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to
prometheus-use...@googlegroups.com.
> To view this discussion on the web visit
https://groups.google.com/d/msgid/prometheus-users/6f760079-348b-44d6-a98e-1f4329d52bf7o%40googlegroups.com.
--
--pau