Skip to content

docs: add API reference for all metric types - #1159

Merged
csmarchbanks merged 3 commits into
prometheus:masterfrom
kkukadia:fix/1021-api-reference-docs
Apr 9, 2026
Merged

docs: add API reference for all metric types #1159
csmarchbanks merged 3 commits into
prometheus:masterfrom
kkukadia:fix/1021-api-reference-docs

Conversation

@kkukadia

@kkukadiakkukadia commented Apr 1, 2026

Copy link
Copy Markdown
Contributor

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

@csmarchbankscsmarchbanks left a comment

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.

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.

Comment threaddocs/content/instrumenting/_index.md Outdated
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
ContributorAuthor

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?)

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.
Closesprometheus#1021
Signed-off-by: k1chik <107162115+k1chik@users.noreply.github.com>
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 <107162115+k1chik@users.noreply.github.com>
Signed-off-by: k1chik <107162115+k1chik@users.noreply.github.com>
@kkukadia
kkukadiaforce-pushed the fix/1021-api-reference-docs branch from 95921c5 to 8d924c5CompareApril 7, 2026 20:01

@csmarchbankscsmarchbanks left a comment

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.

I think that works, thank you!

@csmarchbanks
csmarchbanks merged commit daa1626 into prometheus:masterApr 9, 2026
1 check passed
Sign up for freeto 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

@kkukadia@csmarchbanks