{"action":"created","issue":{"url":"https://api.github.com/repos/prometheus/client_golang/issues/47","labels_url":"https://api.github.com/repos/prometheus/client_golang/issues/47/labels{/name}","comments_url":"https://api.github.com/repos/prometheus/client_golang/issues/47/comments","events_url":"https://api.github.com/repos/prometheus/client_golang/issues/47/events","html_url":"https://github.com/prometheus/client_golang/issues/47","id":54093240,"number":47,"title":"Allow more flexible metric exposition.","user":{"login":"beorn7","id":5609886,"avatar_url":"https://avatars.githubusercontent.com/u/5609886?v=3","gravatar_id":"","url":"https://api.github.com/users/beorn7","html_url":"https://github.com/beorn7","followers_url":"https://api.github.com/users/beorn7/followers","following_url":"https://api.github.com/users/beorn7/following{/other_user}","gists_url":"https://api.github.com/users/beorn7/gists{/gist_id}","starred_url":"https://api.github.com/users/beorn7/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/beorn7/subscriptions","organizations_url":"https://api.github.com/users/beorn7/orgs","repos_url":"https://api.github.com/users/beorn7/repos","events_url":"https://api.github.com/users/beorn7/events{/privacy}","received_events_url":"https://api.github.com/users/beorn7/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-01-12T19:07:16Z","updated_at":"2015-01-12T19:08:21Z","closed_at":null,"body":"With the current state of affairs, a collector has to know exactly the names of the metrics (including the label names for each) it will expose. The only way around that is the SetMetricFamilyInjectionHook function. However, it requires the user to assemble a dto.MetricFamily protobuf, i.e. it is very low-level.\r\n\r\nTwo approaches come to my mind (which we might want to implement both):\r\n\r\n(1) A \"prefix\" registration: A collector can register a whole namespace (by prefix, could be simply implemented by putting \"prefix*\" as the name in the descriptor). It would still register for a fixed set of label names. That registration would disallow any other registration matching the prefix. With this approach, full consistency can still be guaranteed. The planned scrape of selected metrics would be a bit more expensive as we have to call the collector whenever a metric is requested that matches the prefix, but that's fundamentally unavoidable if we have dynamic metric names.\r\n\r\n(2) An \"unchecked\" registration: A collector is allowed to collect _anything_ (possibly with the restriction on a name prefix aka namespace). Since metrics with any label set could be collected, consistency guarantees are gone. This would be similar to the SetMetricFamilyInjectionHook, but on a higher level, i.e. the user can collect normal Metric implementations and does not have to bother with low-level protobufs."},"comment":{"url":"https://api.github.com/repos/prometheus/client_golang/issues/comments/69626080","html_url":"https://github.com/prometheus/client_golang/issues/47#issuecomment-69626080","issue_url":"https://api.github.com/repos/prometheus/client_golang/issues/47","id":69626080,"user":{"login":"beorn7","id":5609886,"avatar_url":"https://avatars.githubusercontent.com/u/5609886?v=3","gravatar_id":"","url":"https://api.github.com/users/beorn7","html_url":"https://github.com/beorn7","followers_url":"https://api.github.com/users/beorn7/followers","following_url":"https://api.github.com/users/beorn7/following{/other_user}","gists_url":"https://api.github.com/users/beorn7/gists{/gist_id}","starred_url":"https://api.github.com/users/beorn7/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/beorn7/subscriptions","organizations_url":"https://api.github.com/users/beorn7/orgs","repos_url":"https://api.github.com/users/beorn7/repos","events_url":"https://api.github.com/users/beorn7/events{/privacy}","received_events_url":"https://api.github.com/users/beorn7/received_events","type":"User","site_admin":false},"created_at":"2015-01-12T19:08:21Z","updated_at":"2015-01-12T19:08:21Z","body":"@grobie @discordianfish You had a use-case for that in the HAProxy expoter, didn't you?"}}