Thanks for contributing to prometheus-postgres-adapter. This guide covers the workflow and the conventions the codebase follows. For what the adapter does see the README; for how it is built and why see DESIGN.md.
You need Go 1.26+ and golangci-lint v2 on your
PATH (the CI pins the exact version). A reachable PostgreSQL instance is
required to run the adapter, but not to build it or run the unit tests.
The everyday commands are listed in the README's Development section.
The project uses a layered architecture with an inward-only dependency rule
(cmd → infrastructure → presentation → usecase → domain). Before adding a
type, read DESIGN.md and place it in the layer that
owns its responsibility:
- entities go in
domain(it depends on no other layer); - application logic is a use case in
usecase; it depends only on small port interfaces it declares itself, never on a concrete adapter; - inbound/outbound edges — the HTTP handlers, the gRPC StoreAPI server, the
PostgreSQL client, the message queue — live in
presentation; - the metric-writer pipeline, the SQL query builder, and the DI container live
in
infrastructure.
- Logging: standard-library
log/slog. Use the*Contextmethods (InfoContext,ErrorContext, …) wherever acontext.Contextis in scope; structured key/value attributes, neverfmt-style logging. - Errors:
github.com/scality/go-errors, imported unaliased aserrors. Define package-levelErrXxxsentinels and wrap at the failure site witherrors.Wrap(ErrXxx, errors.WithProperty(...), errors.CausedBy(rawErr))soerrors.Iskeeps matching the category through the chain. Do not usefmt.Errorf/%w. - Tests: testify (
assert/require), table-driven witht.Runsubtests; fakes and mocks are written by hand (no codegen) and live next to the code they exercise. - Linting & formatting:
golangci-lint runmust pass; format withgolangci-lint fmt.
- Conventional-commit subjects with an explicit action verb, e.g.
feat(storeapi): add …,fix(metricwriter): …,chore: …,refactor: …. - Keep each commit a single coherent change, and keep PRs focused.
- When the change is tied to a Jira ticket, add a trailing
Issue: <TICKET>footer. Chores and refactors that are not tied to a ticket omit it. - Make sure
go test ./...andgolangci-lint runpass before opening a PR.
Treat the docs as part of the change, not an afterthought. In the same PR:
- a change to behavior, configuration, or deployment → update the README;
- a change to architecture or a design decision → update DESIGN.md;
- a change to conventions or workflow → update this file.
By contributing you agree your contribution is licensed under the repository's LICENSE.