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.
 
 
 
 
 
 

68 lines
2.4 KiB

  1. # Copyright 2018 New Vector Ltd
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License at
  6. #
  7. # http://www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing, software
  10. # distributed under the License is distributed on an "AS IS" BASIS,
  11. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. # See the License for the specific language governing permissions and
  13. # limitations under the License.
  14. import logging
  15. from ._base import Config
  16. ROOM_STATS_DISABLED_WARN = """\
  17. WARNING: room/user statistics have been disabled via the stats.enabled
  18. configuration setting. This means that certain features (such as the room
  19. directory) will not operate correctly. Future versions of Synapse may ignore
  20. this setting.
  21. To fix this warning, remove the stats.enabled setting from your configuration
  22. file.
  23. --------------------------------------------------------------------------------"""
  24. logger = logging.getLogger(__name__)
  25. class StatsConfig(Config):
  26. """Stats Configuration
  27. Configuration for the behaviour of synapse's stats engine
  28. """
  29. section = "stats"
  30. def read_config(self, config, **kwargs):
  31. self.stats_enabled = True
  32. self.stats_bucket_size = 86400 * 1000
  33. stats_config = config.get("stats", None)
  34. if stats_config:
  35. self.stats_enabled = stats_config.get("enabled", self.stats_enabled)
  36. self.stats_bucket_size = self.parse_duration(
  37. stats_config.get("bucket_size", "1d")
  38. )
  39. if not self.stats_enabled:
  40. logger.warning(ROOM_STATS_DISABLED_WARN)
  41. def generate_config_section(self, config_dir_path, server_name, **kwargs):
  42. return """
  43. # Settings for local room and user statistics collection. See
  44. # docs/room_and_user_statistics.md.
  45. #
  46. stats:
  47. # Uncomment the following to disable room and user statistics. Note that doing
  48. # so may cause certain features (such as the room directory) not to work
  49. # correctly.
  50. #
  51. #enabled: false
  52. # The size of each timeslice in the room_stats_historical and
  53. # user_stats_historical tables, as a time period. Defaults to "1d".
  54. #
  55. #bucket_size: 1h
  56. """