Skip to content

docs: add API reference for all metric types #1159

Open
k1chik wants to merge 3 commits intoprometheus:masterfrom
k1chik:fix/1021-api-reference-docs
Open

docs: add API reference for all metric types #1159
k1chik wants to merge 3 commits intoprometheus:masterfrom
k1chik:fix/1021-api-reference-docs

Conversation

@k1chik
Copy link
Copy Markdown

@k1chik k1chik commented Apr 1, 2026

Closes #1021

Adds constructor parameter tables, method documentation, and runnable real world examples for Counter, Gauge, Histogram, Summary, Info, and Enum. The _index.md quick-pick table now covers all six types. Also fixes labels.md, which was missing remove(), remove_by_labels(), and clear(). The metric pages were already linking to them.

cc @csmarchbanks

Copy link
Copy Markdown
Member

@csmarchbanks csmarchbanks left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Generally this looks great, just a couple of small comments.

```python
from prometheus_client import Counter
c = Counter('my_failures', 'Description of counter')
c = Counter('my_failures_total', 'Description of counter')
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The library should add _total automatically so this is not necessary to change.

See the documentation on [metric types](http://prometheus.io/docs/concepts/metric_types/)
Six metric types are available. Pick based on what your value does:

| Type | Value goes | Use for |
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Value goes" is a bit awkward for non counter/gauges. Maybe instead something like how a value is set?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for the review!

  • reverted the quick example in counter.md back to my_failures (without _total)
  • renamed the Value goes column to Update model (does this work?)

k1chik added 3 commits April 7, 2026 16:01
Adds constructor parameter tables, method documentation, and runnable
real-world examples for Counter, Gauge, Histogram, Summary, Info, and
Enum. The _index.md quick-pick table now covers all six types. Also
fixes labels.md which was missing remove(), remove_by_labels(), and
clear() -- the metric pages were already linking to it for those methods.

Closes prometheus#1021

Signed-off-by: k1chik <[email protected]>
Revert quick-start counter example to use 'my_failures' (no _total suffix)
since the library appends it automatically. Rename 'Value goes' column to
'Behavior' in the metric type overview table for clarity across all six types.

Signed-off-by: k1chik <[email protected]>
@k1chik k1chik force-pushed the fix/1021-api-reference-docs branch from 95921c5 to 8d924c5 Compare April 7, 2026 20:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

real reference for API

2 participants