Add public, read-only access to label names, label values of any metric
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 38/100
- Tipo de issue
- Nueva funcionalidad
- Claridad
- Bastante claro
- Estado de actividad
- Estancado
- Stack tecnológico
- prometheus, python
- Área
- observability
Línea de trabajo
Comienza con MetricWrapperBase e inspecciona el comportamiento existente de _metric, _labelnames, _lock, collect() y remove() descrito en el issue. Define el acceso público de solo lectura a los nombres de las etiquetas y a las tuplas de etiqueta-valor; después, añade pruebas que confirmen los valores expuestos y el comportamiento de lectura seguro para subprocesos.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Hi,
I am currently working on Prometheus metrics for Celery workers in Flower project and we use this wonderful library :) - thx for your work on it!
One issue I came across is lack of direct access to metric's labelnames and labelvalues.
I think easiest is to give you an example how it is used/why it is needed.
We have multiple celery workers in a kubernetes cluster, they are monitored by Flower which generates Prometheus metrics.
Now the pods in k8s can die or be replaced if a new release of our software is deployed.
The problem with that then is that the final reading for each metric for that pod is retained forever and it shows in grafana forever.
We want to remove any tuples of label values which contain a celery worker name that is deemed offline/dead.
I used a semi-hack (https://github.com/mher/flower/pull/1135) and get those label values through metric.collect(), and from that iterate over samples and the labels in them and then if they contain an offline worker I remove the whole tuple from a given metric by calling metric.remove(*labelvalues_containg_dead_worker)
There could be a better way - access metric._metric.keys() in a thread safe and read-only way.
So I propose to add to MetricWrapperBase a read only property, say all_label_values (name to be improved, suggestions welcome :))
@property
def all_label_values(self) -> List[Tuple[str, ...]]:
with self._lock:
all_label_values = list(self._metric.keys().copy())
return all_label_values
I think I am also badly missing access to actual labelnames set for the given metric to know at which position a label with a given name will be in the labelvalues.
Could kill 2 birds with one stone then and add:
@property
def labelnames(self) -> Tuple[str, ...]:
return self._labelnames
Please let me know if such a change is acceptable and if I am missing any nuances.
If you think you would be ok merging it I will make a PR with tests soon.
Cheers,
Tom
- Lenguaje dominante
- Python
- Estrellas
- 4.4k
- Forks
- 876
- Merge medio
- 8 d 4 h
- PR fusionados (30 d)
- 1
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de prometheus/client_python
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
prometheus/client_python#1177 · 1 comentario ·
-
Dificultad 4/5 3-5 días Aptitud para principiantes 45/100
prometheus/client_python#1210 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 58/100
prometheus/client_python#1199 · 1 reacción ·
-
Dificultad 5/5 Más de una semana Aptitud para principiantes 35/100
prometheus/client_python#1176 ·
-
WSL and MultiProcessCollector Abierto
Dificultad 1/5 1-3 horas Aptitud para principiantes 52/100
prometheus/client_python#1126 · 2 comentarios ·
Todos los issues de prometheus/client_python
Issues similares
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
stephrobert/dsoxlab#238 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
sublimehq/package_control#1780 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
nwg-piotr/nwg-displays#145 ·