Skip to content

Latest commit

 

History

History
141 lines (86 loc) · 6.75 KB

007-disable-usage-stats.md

File metadata and controls

141 lines (86 loc) · 6.75 KB

Ability to Disable Usage Stats

  • Implementation Owner: @lohanidamodar
  • Start Date: 12-01-2021
  • Target Date: Unknown
  • Appwrite Issue: appwrite/appwrite#547

Summary

Due to difficulty in deployment of influxdb and telegraf in services like Heroku, in the Appwrite lite version, usage stats has to be disabled. So, want to introduce a environment variable that will allow disabling usage stats completely there by influxdb, telegraf and appwrite usage worker dependencies will no longer be required.

Problem Statement (Step 1)

What problem are you trying to solve?

Making Appwrite lite version easily deployable to 1 click deployment platforms like Heroku, where there is no easy way to support influxdb and telegraf that are used to record and display usage stats. So, allowing to disable this and disabling this in the Appwrite lite version will enable easy deployment to platforms like Heroku.

What is the context or background in which this problem exists?

Supporting one click deployments to free tiers of platforms like Heroku, will help a lot in Appwrite adoption. This will allow any beginners to easily instiantiate an Appwrite paltform and see it in action, even use it in production in an envorinment with less resources.

Once the proposal is implemented, how will the system change?

Users will be able to disable the usage stats feature completely. This will disable the display of usage statistics graph in dashboard. But this will not change any other parts of Appwrite or it's API.

Design proposal (Step 2)

Introduce new environment variable

Introduce a new environment variable to allow disabling usage stats. - _APP_USAGE_STATS = enabled | disabled

Use the environment variable

Use the environment variable to disable collection and display of usage stats. Once disabled, the usage stats end points (project and functions) will only return other stats if any apart from those from influxdb/telegraf. Also, console dashboard will hide the usage stats graph.

Changes to be made

Following changes will be required in order to support disabling usage stats

  1. functions usage endpoint : https://github.com/appwrite/appwrite/blob/d6df6b9fdc9e05b72fe0fb391e787a7dce9fc5b9/app/controllers/api/functions.php#L134

Here, after making sure the function exists. Check if stats is disabled. If disabled skip calculations from line declaring $period - sending the response. Instead just send a dummy response in the same format with dummy data.

  1. projects usage endpoint : https://github.com/appwrite/appwrite/blob/055a7ef8eb56067484ec27c03e6210afc84c7244/app/controllers/api/projects.php#L155

Here, after making sure the project exists. Check if stats is disabled. If disabled skip calculations from line declaring $period - before getting users collection data. In the response if the stats is disabled send dummy data for requests, network, functions keys.

  1. Console home controller: https://github.com/appwrite/appwrite/blob/7fc7e0b93d8b0ae9bcbf5f775c73c59db5910af5/app/controllers/web/console.php#L116

Here, just pass the value of environment variable to the view.

  1. Home view : https://github.com/appwrite/appwrite/blob/881b1e71a3244b11d3e1eb064727791676636bc3/app/views/console/home/index.phtml#L64

Here, based on the value of environment variable, show / hide the charts inside project stats div.

  1. Functions controller : https://github.com/appwrite/appwrite/blob/7fc7e0b93d8b0ae9bcbf5f775c73c59db5910af5/app/controllers/web/console.php#L379

Here, pass the value of environment variable to the view.

  1. Functions view : https://github.com/appwrite/appwrite/blob/881b1e71a3244b11d3e1eb064727791676636bc3/app/views/console/functions/function.phtml#L243

Here based on the value of environment variable, show/hide the usage, monitor graph below line 243.

  1. App shutdown function : https://github.com/appwrite/appwrite/blob/9c421e2dfc64cc7c929f26e5a9193735e1b1c9c6/app/controllers/general.php#L320

Here, if stats disabled, stop sending the data to redis.

Prior art

Unresolved questions

Future possibilities

This will allow easily deployment of Appwrite to various platforms like Heroku, which will help a lot in increasing adoption. This will also favor easy deployment to servers with less resources.