feat: exporter toolkit bootstrap#394
Conversation
eec061a to
89732e0
Compare
Signed-off-by: Nicolas Takashi <nicolas.tcs@hotmail.com>
89732e0 to
6263465
Compare
|
I think this is a continuation of #147 |
6263465 to
45e6db8
Compare
ArthurSens
left a comment
There was a problem hiding this comment.
Really cool! This can be so easily applied to a lot of exporters :)
Signed-off-by: Nicolas Takashi <nicolas.tcs@hotmail.com>
45e6db8 to
9138d4c
Compare
ArthurSens
left a comment
There was a problem hiding this comment.
LGTM, but let's see what exporter-toolkit maintainers have to say :)
|
why is MetricsHandlerFactory: func(b *bootstrap.Bootstrap) (http.Handler, error) { |
Good question @roidelapluie and I realized this is not so clear on the PR description. The reason behind this is because the final handler might depend on values that are only available after bootstrap has parsed the common flags and initialized logging. In the node_exporter integration, the handler is built from So the factory is the exporter-specific assembly point once the shared bootstrap state is resolved. Without it, callers would either have to duplicate bootstrap parsing/setup outside this package, or bootstrap itself would need to know how to construct exporter-specific handlers. |
|
One thing that I just thought about! If all CLI flags are registered through this bootstrapping package, we could create a hidden kingpin command to print them all. I believe almost all exporters in prometheus and prometheus-community have their CLI flags in the README, but they are updated manually. We could easily build the automation needed to keep the README and the real world in sync |
Summary
This adds a new optional bootstrap package to exporter-toolkit for exporters that want a shared startup path for common process wiring. Today, many exporters duplicate the same startup concerns around:
This PR introduces an additive package that can own those shared pieces without changing the existing web package API or forcing any current exporter to migrate.
Why
The goal is to reduce repeated startup code across exporters while keeping boundaries clear:
This is intentionally additive:
A key design choice in this PR is keeping web.telemetry-path ownership in bootstrap, not in web.FlagConfig, so transport concerns and exporter routing concerns do not get mixed together. It also keeps the existing web startup path intact.
Startup Example
Without bootstrap:
With bootstrap:
Notes