Add an option to expose the metric timestamps from the Prometheus format
Ninguém assumiu esta issue ainda.
Avaliação
- Dificuldade
- 4/5
- Tempo estimado
- 3-5 dias
- Facilidade para iniciantes
- 42/100
- Tipo de issue
- Funcionalidade
- Clareza
- Razoavelmente clara
- Status de atividade
- Estagnada
- Stack de tecnologia
- prometheus, python
- Domínio
- observability
Direção de pesquisa
Comece por prometheus_client/samples.py e exposition.py para rastrear como os timestamps das amostras são representados e formatados. Em seguida, inspecione metrics.py::_child_samples e multiprocess.py em torno da lógica de agregação citada, incluindo o pull request e o issue relacionados. Considera-se concluído quando uma opção expõe timestamps na saída do Prometheus e os preserva nos modos multiprocessing e não-multiprocessing.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
Spin off from https://github.com/prometheus/client_python/pull/967 and https://github.com/prometheus/client_python/issues/847
Background
The Prometheus exposition format (https://github.com/prometheus/docs/blob/main/content/docs/instrumenting/exposition_formats.md#comments-help-text-and-type-information) allows exporters to specify an optional timestamp for each sample. If this is unset, the collector uses the timestamp that the sample is collected.
This timestamp is useful in a certain situation. My concrete use case is to expose GitHub API rate limit as a metric. This API rate limit is a value that decreases over time, and periodically it resets to the maximum value. We can get this API rate limit value as a HTTP response header when calling GitHub API.
Imagine a situation where there are two (physical) servers making this GitHub API call, and for the sake of illustration, let's assume that one server issues more requests and the other one does less.
| Server1 (frequently issue requests) | Server2 (somehow less requests) | |
|---|---|---|
| Observed API limit | 100 | 4900 |
| (Last time a server made a GH API call) | 3 minutes ago | 50 minutes ago |
From human's point of view, because server1 made an API call more recently than server2, we can tell that server1's observed API limit is the current value. However, without exposing the sample timestamp, Prometheus cannot distinguish which one is the most recent value. This is because when Prometheus collects sample from these two servers, when there's no timestamp specified, it treats these samples as "the samples collected now".
By exposing the sample timestamp, Prometheus should be able to treat these two samples correctly, and it can tell that server1' s value is the most recent value.
Request
With https://github.com/prometheus/client_python/pull/967, client_python should learn timestamps for Gauge metrics in the multiprocessing mode. This issue is asking for an option to expose those timestamps via Prometheus format.
Code pointers
Sample already can take a timestamp (https://github.com/prometheus/client_python/blob/249490e4ed30d4266182cfce50fe7046a484affd/prometheus_client/samples.py#L49), and so as the Prometheus exposition formatter (https://github.com/prometheus/client_python/blob/249490e4ed30d4266182cfce50fe7046a484affd/prometheus_client/exposition.py#L191-L194).
For the multiprocessing mode, changing the metrics aggregation logic to propagate the timestamps (https://github.com/prometheus/client_python/blob/249490e4ed30d4266182cfce50fe7046a484affd/prometheus_client/multiprocess.py#L146) would suffice (based on a flag or something).
For the non-multiprocessing mode, need to change this _child_samples (https://github.com/prometheus/client_python/blob/249490e4ed30d4266182cfce50fe7046a484affd/prometheus_client/metrics.py#L433-L434) to take a timestamp.
- Linguagem predominante
- Python
- Estrelas
- 4.4k
- Forks
- 876
- Merge médio
- 8d 4h
- PRs com merge (30d)
- 1
Guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de prometheus/client_python
-
bug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 70/100
prometheus/client_python#1177 · 1 comentário ·
-
Dificuldade 4/5 3-5 dias Facilidade para iniciantes 45/100
prometheus/client_python#1210 ·
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 58/100
prometheus/client_python#1199 · 1 reação ·
-
Dificuldade 5/5 Mais de uma semana Facilidade para iniciantes 35/100
prometheus/client_python#1176 ·
-
Dificuldade 1/5 1-3 horas Facilidade para iniciantes 52/100
prometheus/client_python#1126 · 2 comentários ·
Todas as issues de prometheus/client_python
Issues semelhantes
-
essnmx good first issue
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 95/100
-
[Feature] 奇物选择添加优先级 Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 65/100
syfoud/Simulated_Scepter#174 ·
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 75/100
Giskard-AI/giskard-oss#2840 · 1 comentário ·
-
A claim comment carrying the issue number is silently declined while the workflow reports success Abertaarea: repo bug perceived difficulty: 2
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 70/100
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 75/100
yeti-platform/yeti#1380 ·