discourse / prometheus_exporter

A framework for collecting and aggregating prometheus metrics
MIT License
537 stars 155 forks source link

Feature: allow finding registered metric by metric name, type, or help #86

Closed FunnyHector closed 5 years ago

FunnyHector commented 5 years ago

When reusing the same client in different places to export the same metric, there is no external interface to retrieve this metric after it's registered. Using instance_variable_get to reach into the instance variable @metrics is less preferable. Re-registering the metric will lead to an ever-growing array of @metrics.

This commit provides a way to get the metric by name, and optionally by type and help, so that we can reuse it.

SamSaffron commented 5 years ago

This looks good to me, mind adding a test for it?

FunnyHector commented 5 years ago

This looks good to me, mind adding a test for it?

Yep, happy to :)

EDIT: OK, added some test for this method. This is the first time that I write MiniTest. I'm more familiar with RSpec. If I'm doing anything wrong, just let me know, happy to update 😬

SamSaffron commented 5 years ago

Looks good to me! thanks!