stats.py 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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 typing import Any
  16. from synapse.types import JsonDict
  17. from ._base import Config
  18. ROOM_STATS_DISABLED_WARN = """\
  19. WARNING: room/user statistics have been disabled via the stats.enabled
  20. configuration setting. This means that certain features (such as the room
  21. directory) will not operate correctly. Future versions of Synapse may ignore
  22. this setting.
  23. To fix this warning, remove the stats.enabled setting from your configuration
  24. file.
  25. --------------------------------------------------------------------------------"""
  26. logger = logging.getLogger(__name__)
  27. class StatsConfig(Config):
  28. """Stats Configuration
  29. Configuration for the behaviour of synapse's stats engine
  30. """
  31. section = "stats"
  32. def read_config(self, config: JsonDict, **kwargs: Any) -> None:
  33. self.stats_enabled = True
  34. stats_config = config.get("stats", None)
  35. if stats_config:
  36. self.stats_enabled = stats_config.get("enabled", self.stats_enabled)
  37. if not self.stats_enabled:
  38. logger.warning(ROOM_STATS_DISABLED_WARN)