Design patterns and Code conventions
Cortex adopts some design patterns and code conventions that we ask you to follow when contributing to the project. These conventions have been adopted based on the experience gained over the time and aim to enforce good coding practices and keep a consistent UX (ie. config).
Go coding style
No global variables
- Do not use global variables
When registering a metric:
- Do not use a global variable for the metric
- Create and register the metric with
- In any internal Cortex component, do not register the metric to the default prometheus registerer, but pick the registerer in input (ie.
- When writing using tests, test exported metrics using
Config file and CLI flags conventions
- Config file options should be lowercase with words
_(underscore) separated (ie.
- CLI flags should be lowercase with words
-(dash) separated (ie.
- When adding a new config option, look if a similar one already exists within the config and keep the same naming (ie.
addressesfor a list of network endpoints)
- A CLI flag mentioned in the documentation or changelog should be always prefixed with a single