Skip to content

Commit

Permalink
Add section about lint
Browse files Browse the repository at this point in the history
  • Loading branch information
hugoShaka committed Jan 16, 2025
1 parent 164e16e commit 92a08ed
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion rfd/0197-prometheus-metrics.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ This poses several challenges:
- The same Teleport component cannot be started multiple times without causing metric conflicts, or inaccurate metrics.
For example, integration tests starting several Teleport instances will merge their metrics together.

## Details
## Guidelines

### Metrics Registry

Expand Down Expand Up @@ -224,3 +224,14 @@ func newMetrics(reg prometheus.Registerer) (*metrics, error) {

- Put user input directly in the labels
- Create large (1k+) metric combinations

## Enforcing the guidelines

Some guidelines can be enforced by setting up linters:
- [promlinter](https://golangci-lint.run/usage/linters/#promlinter) to ensure that metric naming and labeling follows
the Prometheus guidelines.
- [forbidigo](https://golangci-lint.run/usage/linters/#forbidigo) to reject usages of `prometheus.DefaultRegisterer`,
`prometheus.(Must)Register`. `reg.MustRegister` conflicts with `backend.MustRegister`, we might not be able to detect
it (`fobidigo.analyze-types` might not be sufficient)

Existing non-compliant metrics and edge case usages will be allowed via `//nolint` comments.

0 comments on commit 92a08ed

Please sign in to comment.