Skip to content

What is the cost of calling the metrics endpoint? #1086

Answered by bwplotka
rodoufu asked this question in Q&A
Discussion options

You must be logged in to vote

It heavily depends on the collector implementation. HTTP handler calls Gather() ([]*dto.MetricFamily, error) on your prometheus.Registry, which calls Collect(ch chan<- Metric) on all your registered collectors. You can register many types of collectors, which might have different characteristics:

  • The values are saved in memory for native metrics (const metrics, gauges, counters summary, histogram). Collect will then mostly just copy the value to new protobuf object. You update those metrics in separate goroutines using Inc(), Add(), observe and so on.
  • The ...Func family of metrics e.g NewGaugeFunc are invoking providing function to on every call. Users can provide expensive computation …

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by rodoufu
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
3 participants
Converted from issue

This discussion was converted from issue #1071 on July 12, 2022 07:37.