The open and composable observability and data visualization platform. Visualize metrics, logs, and traces from multiple sources like Prometheus, Loki, Elasticsearch, InfluxDB, Postgres and many more.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
grafana/pkg
Alexander Zobnin 3d848d0fdf
Teams: show proper label for each auth provider (#17860)
6 years ago
..
api Teams: show proper label for each auth provider (#17860) 6 years ago
bus Codestyle: Fix govet issues (#17178) 6 years ago
cmd Grafana-CLI: Wrapper for `grafana-cli` within RPM/DEB packages and config/homepath are now global flags (#17695) 6 years ago
components Build: use golangci-lint as a make command (#17739) 6 years ago
events
extensions Enterprise: remove gofakeit dep (#17344) 6 years ago
infra RemoteCache: redis connection string parsing test (#17702) 6 years ago
login Build: use golangci-lint as a make command (#17739) 6 years ago
middleware Build: use golangci-lint as a make command (#17739) 6 years ago
models Teams: show proper label for each auth provider (#17860) 6 years ago
plugins Explore: Queries the datasource once per run query and uses DataStreamObserver (#17263) 6 years ago
registry add functionality to override service in registry 7 years ago
services Teams: show proper label for each auth provider (#17860) 6 years ago
setting Auth: Allow expiration of API keys (#17678) 6 years ago
tsdb Build: use golangci-lint as a make command (#17739) 6 years ago
util CLI: Add command to migrate all datasources to use encrypted password fields (#17118) 6 years ago
ARCHITECTURE.md Codestyle: add guidelines for removing the m alias for models (#17890) 6 years ago
README.md Docs upgrading deps (#17657) 6 years ago
STYLEGUIDE.md Build: use golangci-lint as a make command (#17739) 6 years ago

README.md

Grafana backend codebase

The code styleguide and brief description of the architecture

On going refactorings.

These issues are not something we want to address all at once but something we will improve over time. Since Grafana is released at a regular schedule the prefer approuch is to do this in batches. Not only is it easier to review, it also reduces the risk of conflicts when cherry-picking fixes from master to release branches. Changes that spawn multiple locations are therefore prefered in the end of the release cycle since we make fewer patch releases in the end of the cycle.

Global state

Global state makes testing and debugging software harder and its something we want to avoid when possible. Unfortunately, there is quite a lot of global state in Grafana. The way we want to migrate away from this is to use the inject package to wire up all dependencies either in pkg/cmd/grafana-server/main.go or self registering using registry.RegisterService ex https://github.com/grafana/grafana/blob/master/pkg/services/cleanup/cleanup.go#L25

Reduce the use of the init() function

Should only be used to register services/implementations.

Settings refactoring

The plan is to move all settings to from package level vars in settings package to the setting.Cfg struct. To access the settings services/components can inject this setting.Cfg struct.

Cfg struct Injection example

Reduce the use of Goconvey

We want to migrated away from using Goconvey and use stdlib testing as its the most common approuch in the GO community and we think it will make it easier for new contributors. Read more about how we want to write tests in the ARCHITECTURE.MD docs.

Sqlstore refactoring

The sqlstore handlers all use a global xorm engine variable. This should be refactored to use the Sqlstore instance.

Avoid global HTTP Handler functions

HTTP handlers should be refactored to so the handler methods are on the HttpServer instance or a more detailed handler struct. E.g (AuthHandler). This way they get access to HttpServer service dependencies (& Cfg object) and can avoid global state

Date comparison

Newly introduced date columns in the database should be stored as epochs if date comparison is required. This permits to have a unifed approach for comparing dates against all the supported databases instead of handling seperately each one of them. In addition to this, by comparing epochs error pruning transformations from/to other time zones are no more needed.

Dependency management

Documented in UPDRAGING_DEPENDENCIES.md.