-
Notifications
You must be signed in to change notification settings - Fork 797
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
Collector vs MultiCollector #902
Comments
The benefit of the current registry.register(() -> CounterSnapshot.builder()
.name("my_count")
.dataPoint(CounterDataPointSnapshot.builder()
.labels(Labels.of("key", "value"))
.value(3.0)
.build())
.build()); The tradeoff is: We need two separate functional interfaces: I agree that the internal implementation of These trade-offs are always hard to get right, but I figured making it easy to register a Lambda is worth the increased internal complexity in |
But MultiCollector is also functional interface, yet more powerful. It has one method: collect(filter, scrapeRequest): MetricsSnapshots and code you provided should simply be calling
But note the builder does that. You can make Gauge.builder().build() return MultiCollector without any other changes - noone will notice - client code will not change at all... |
Hi
I'm just upgrading my project to new version of client, and have feeling separation between
Collector
andMultiCollector
interfaces brings unnecessary complexity to the code. If you look into registry implementation, amount of code actually doubles unnecessarily due to separate handling paths.I see it that
Collector
is just a special case of more genericMultiCollector
. Moreover - its existence is only for convenience of implementers, it has no additional logic over MultiCollector.Shouldn't it be that:
Collector
interface that returns multiple metrics (actually just renameMultiCollector
)abstract class SingleCollector extends Collector
that just makes implementation simpler by allowing to implementMetricSnapshot collectSingle()
, and wraps result as one-rowMetricSnapshots
marcin
The text was updated successfully, but these errors were encountered: