client_python icon indicating copy to clipboard operation
client_python copied to clipboard

API reference for pushgateway, textfile, and multiprocess

Open kkukadia opened this issue 7 months ago • 1 comments

Title: docs: add API reference for pushgateway, textfile, and multiprocess

Following the API reference work in #1021 (metric types) and the existing HTTP exporting docs, the pushgateway, textfile, and multiprocess docs have the same gap — examples without formal parameter documentation.

What's missing

Pushgateway (docs/content/exporting/pushgateway.md)

Currently 88 lines with good examples but no formal parameter tables for:

  • push_to_gateway(gateway, job, registry, grouping_key, timeout, handler, compression) — full signature with types and defaults undocumented
  • pushadd_to_gateway() — same params, registry is Optional[Collector] here (unlike push_to_gateway)
  • delete_from_gateway(gateway, job, grouping_key, timeout, handler) — no registry or compression params (differs from the other two)
  • Handler functions (default_handler) — the handler protocol (accepts url, method, timeout, headers, content) is only in the source docstring, not in the docs site
  • compression parameter ('gzip' or 'snappy') — not mentioned in the docs at all

Textfile (docs/content/exporting/textfile.md)

Only 23 lines. write_to_textfile() has undocumented parameters:

write_to_textfile(path: str, registry: Collector, escaping: str = ALLOWUTF8, tmpdir: Optional[str] = None) -> None
  • escaping — OpenMetrics escaping mode (not mentioned at all)
  • tmpdir — temp directory for atomic writes (not mentioned at all)

Multiprocess (docs/content/multiprocess/_index.md)

Best-documented section (99 lines), but still missing formal API reference for:

  • MultiProcessCollector(registry, path) — the path parameter (alternative to the PROMETHEUS_MULTIPROC_DIR env var) is undocumented
  • mark_process_dead(pid, path) — path parameter undocumented, function only shown in a Gunicorn config snippet

Proposed approach

Add "## API Reference" sections to each existing page with:

  • Function parameter tables (name, type, default, description)
  • Return values
  • Error conditions
  • A validation script confirming every claim against the source

Source files to reference

  • prometheus_client/exposition.py — pushgateway and textfile functions
  • prometheus_client/multiprocess.py — MultiProcessCollector, mark_process_dead

kkukadia avatar Apr 10 '26 17:04 kkukadia

Hi @csmarchbanks , I'd like to work on this! I'll follow the same pattern established in PR #1159 - API Reference sections with parameter tables and a validation script.

kkukadia avatar Apr 10 '26 17:04 kkukadia