prometheus / prometheus/client_python
Timing generator function
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Python
- Sterne
- 4.4k
- Forks
- 876
- Ø Merge
- 8 T. 4 Std.
- Gemergte PRs (30 T.)
- 1
Beschreibung
Is there any way to time how long it takes to execute a generator function in python with Histogram.time? Right now, it only seems to measure the time to get the generator object. But since generators do lazy computation while actually iterating over it, we don't get full time.
Example:
def generate_n(n):
for i in range(n):
yield i
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Start by reading the Histogram.time entry point and tracing how it handles the generator example in the issue. Define what timing the full lazy iteration should mean, then add coverage showing that the measured duration includes generator execution rather than only creation.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- python
- Bereich
- observability
- Issue-Typ
- Feature
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 35/100