Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove scrape() from getPrometheusName() default implementation #875

Merged
merged 1 commit into from Oct 15, 2023

Conversation

fstab
Copy link
Member

@fstab fstab commented Oct 15, 2023

The Collector (and MultiCollector) interface defines a method getPrometheusName() (or getPrometheusNames()) to get the list of metric names produced by the collector.

This method is optional. It is used during registration to check for duplicate metrics, and it is used during scrape if a name filter is present to check if this collector can be skipped because the name(s) are excluded.

The default implementation was to call collect() to learn the Prometheus names. However, this leads to two collect() calls when scraping: The first to check the name filter, the second for the actual scrape.

With this PR we change this to returning null (or empty list) indicating that the names are unknown.

This does not affect the metrics in prometheus-metrics-core, because all metrics in prometheus-metrics-core override this.

Signed-off-by: Fabian Stäber <fabian@fstab.de>
@fstab fstab merged commit 5817253 into main Oct 15, 2023
2 checks passed
@fstab fstab deleted the fix-empty-prometheus-names branch October 15, 2023 20:17
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.

None yet

1 participant