Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

Labels on function decorator that are defined at runtime

Abierto
#693 0 comentarios 1 reacción 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
35/100
Tipo de issue
Nueva funcionalidad
Claridad
Bastante claro
Estado de actividad
Estancado
Stack tecnológico
python

Línea de trabajo

En el issue no se identifica ningún archivo fuente ni ninguna prueba. Empieza siguiendo la llamada Gauge.labels y el punto de entrada .time() del decorador utilizado en el ejemplo; done debería permitir proporcionar los valores de las etiquetas más adelante sin exponer la métrica EMPTY_SCOPE inicial.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

Referring back to this thread: https://github.com/prometheus/client_python/issues/157
I wanted to know if there's a way to use the function decorator syntax with labels that will be instantiated at a later point? I need to fetch the label values from another service first. I am currently filling in some dummy values which will give me duplicated metrics:

inference_time_created{edge="EMPTY_SCOPE",line="EMPTY_SCOPE",module="EMPTY_SCOPE",plant="EMPTY_SCOPE",workload="EMPTY_SCOPE"} 1.6311126626366935e+09
inference_time_created{edge="ACTUAL_VALUE",line="ACTUAL_VALUE",module="ACTUAL_VALUE",plant="ACTUAL_VALUE",workload="ACTUAL_VALUE"} 1.6311126626709173e+09

So my question is if there's a way to not have the EMPTY_SCOPE metric on the endpoint.

This is the basic idea of what I'm doing:

scope_keys = ["plant", "edge", "line", "workload", "module"]
scope_values = ["EMPTY_SCOPE"] * 5
inference_time_created= Gauge('inference_time', 'How long (in seconds) does it take for an inference', scope_keys)
inference_time_created_labeled = inference_time_created.labels(*scope_values)

def set_metrics_scope(scope): # this function gets called later in the main code
    scope_values = scope
    inference_time_created_labeled = inference_time_created.labels(*scope_values)

@inference_time_created_labeled.time()
def inference():
    # do some calculations
Lenguaje dominante
Python
Estrellas
4.4k
Forks
876
Merge medio
8 d 4 h
PR fusionados (30 d)
1

Guía de contribución

Abrir la guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de prometheus/client_python

Todos los issues de prometheus/client_python

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.