grafana/pkg
Ben Patterson 9904e14f8e Alerting: Fix dates stored in local time when pausing alerts (#19525)
* Make tests more sensitive to timezone.

* Time stamps should use UTC for consistency.

* Test: Assert state is paused after pauseAllAlerts call.
2019-10-08 17:25:15 +03:00
..
api API: Add createdAt and updatedAt to api/users/lookup (#19496) 2019-09-30 20:54:09 +01:00
bus Codestyle: Fix govet issues (#17178) 2019-06-04 22:00:05 +02:00
cmd CLI: Fix version selection for plugin install (#19498) 2019-09-30 15:34:09 +02:00
components backend: null.Float NaN -> null for json marshal (#18284) 2019-08-06 12:28:48 -04:00
events feat(signup): progress on new sign up and email verification flow, #2353 2015-08-28 15:14:24 +02:00
extensions Enterprise: add dependencies for upcoming features (#18793) 2019-08-30 18:14:32 +02:00
infra Metrics: Adds setting for turning off total stats metrics (#19142) 2019-09-17 09:32:24 +02:00
login LDAP: Allow an user to be synchronised against LDAP (#18976) 2019-09-13 16:26:25 +01:00
middleware LDAP: Add API endpoint to debug user mapping from LDAP (#18833) 2019-09-03 18:34:44 +01:00
models API: Add createdAt field to /api/users/:id (#19475) 2019-09-28 12:12:33 +01:00
plugins Plugins: Skips existence of module.js for renderer plugins (#19318) 2019-09-23 22:54:28 -07:00
registry add functionality to override service in registry 2018-10-30 13:37:30 +01:00
services Alerting: Fix dates stored in local time when pausing alerts (#19525) 2019-10-08 17:25:15 +03:00
setting Upgrade grafana-plugin-model (#19438) 2019-09-30 15:16:04 +02:00
tsdb CloudWatch: Changes incorrect dimension wmlid to wlmid (#19679) 2019-10-07 23:47:07 +02:00
util AzureMonitor: Alerting for Azure Application Insights (#19381) 2019-10-07 14:18:14 +02:00
ARCHITECTURE.md Docs: Minor edits to the README and several md files (#19238) 2019-09-20 00:04:56 +02:00
README.md Docs: Improve guides for contributing (#19575) 2019-10-03 14:13:58 +02:00

Grafana backend codebase

The code styleguide and brief description of the architecture

Ongoing 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 preferred approach is to do this in batches. Not only is it easier to review, but it also reduces the risk of conflicts when cherry-picking fixes from master to release branches. Please try to submit changes that span multiple locations at the end of the release cycle. We prefer waiting until the end because we make fewer patch releases at the end of the release cycle, so there are fewer opportunities for complications.

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.