2019-05-21 18:36:50 +02:00
|
|
|
# Copyright 2018 New Vector Ltd
|
|
|
|
#
|
|
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
# you may not use this file except in compliance with the License.
|
|
|
|
# You may obtain a copy of the License at
|
|
|
|
#
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
#
|
|
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
# See the License for the specific language governing permissions and
|
|
|
|
# limitations under the License.
|
|
|
|
|
2021-03-16 11:57:54 +01:00
|
|
|
import logging
|
2022-04-11 18:07:23 +02:00
|
|
|
from typing import Any
|
|
|
|
|
|
|
|
from synapse.types import JsonDict
|
2019-05-21 18:36:50 +02:00
|
|
|
|
|
|
|
from ._base import Config
|
|
|
|
|
2021-03-16 11:57:54 +01:00
|
|
|
ROOM_STATS_DISABLED_WARN = """\
|
|
|
|
WARNING: room/user statistics have been disabled via the stats.enabled
|
|
|
|
configuration setting. This means that certain features (such as the room
|
|
|
|
directory) will not operate correctly. Future versions of Synapse may ignore
|
|
|
|
this setting.
|
|
|
|
|
|
|
|
To fix this warning, remove the stats.enabled setting from your configuration
|
|
|
|
file.
|
|
|
|
--------------------------------------------------------------------------------"""
|
|
|
|
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
2019-05-21 18:36:50 +02:00
|
|
|
|
|
|
|
class StatsConfig(Config):
|
|
|
|
"""Stats Configuration
|
|
|
|
Configuration for the behaviour of synapse's stats engine
|
|
|
|
"""
|
|
|
|
|
2019-10-10 10:39:35 +02:00
|
|
|
section = "stats"
|
|
|
|
|
2022-04-11 18:07:23 +02:00
|
|
|
def read_config(self, config: JsonDict, **kwargs: Any) -> None:
|
2019-05-21 18:36:50 +02:00
|
|
|
self.stats_enabled = True
|
|
|
|
stats_config = config.get("stats", None)
|
|
|
|
if stats_config:
|
|
|
|
self.stats_enabled = stats_config.get("enabled", self.stats_enabled)
|
2021-03-16 11:57:54 +01:00
|
|
|
if not self.stats_enabled:
|
|
|
|
logger.warning(ROOM_STATS_DISABLED_WARN)
|
2019-05-21 18:36:50 +02:00
|
|
|
|
2022-04-11 18:07:23 +02:00
|
|
|
def generate_config_section(self, **kwargs: Any) -> str:
|
2019-05-21 18:36:50 +02:00
|
|
|
return """
|
2021-03-16 11:57:54 +01:00
|
|
|
# Settings for local room and user statistics collection. See
|
2021-07-07 13:35:45 +02:00
|
|
|
# https://matrix-org.github.io/synapse/latest/room_and_user_statistics.html.
|
2019-05-21 18:36:50 +02:00
|
|
|
#
|
2021-03-16 11:57:54 +01:00
|
|
|
stats:
|
|
|
|
# Uncomment the following to disable room and user statistics. Note that doing
|
|
|
|
# so may cause certain features (such as the room directory) not to work
|
|
|
|
# correctly.
|
|
|
|
#
|
|
|
|
#enabled: false
|
2019-05-21 18:36:50 +02:00
|
|
|
"""
|