Refactor Postgres exporter to make it re-usable as a Go library#1330
Open
ArthurSens wants to merge 2 commits into
Open
Refactor Postgres exporter to make it re-usable as a Go library#1330ArthurSens wants to merge 2 commits into
ArthurSens wants to merge 2 commits into
Conversation
This was referenced Jun 11, 2026
Signed-off-by: Arthur Silva Sens <arthursens2005@gmail.com>
Signed-off-by: Arthur Silva Sens <arthursens2005@gmail.com>
858709f to
e802612
Compare
kgeckhart
reviewed
Jun 17, 2026
Comment on lines
+37
to
+39
| if !cfg.Validated() { | ||
| return nil, errors.New("config has not been validated; call cfg.Validate before NewRuntime") | ||
| } |
There was a problem hiding this comment.
I kinda like what you did here, https://github.com/prometheus/prometheus-opentelemetry-collector/pull/11/changes#diff-e855075d0398417658889b1c58d1abee6934a122028a324919d2549250e16e72R60-R64, to have it call validate. We might want to log a warning since we would hope it would be done ahead of time but avoiding the error seems nice.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Superseeds #1297 and #1299
This PR refactors the Postgres exporter codebase so it can be easily embedded as a Go library in downstream projects. The architecture I'm aiming for in this PR is documented here.
To summarize:
Runtime. ThisRuntimecontains all Prometheus collectors in isolation.Configpackage that holds all possible user-facing configuration, with the exception ofAuthModules. That includes all CLI flags, including the enabled collectors.cmd/postgres/main.gostitches CLI flags, config, Runtime, and http handler togethercmd/postgres/probes.gouses the Runtime abstraction to handle multiple postgres targets.For more details on the architecture, I recommend reading the docs we wrote or the Stackdriver exporter codebase, which already follows this architecture!