|
| 1 | +# -*- coding: utf-8 -*- |
| 2 | +# Copyright 2019 The Matrix.org Foundation C.I.C.d |
| 3 | +# |
| 4 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | +# you may not use this file except in compliance with the License. |
| 6 | +# You may obtain a copy of the License at |
| 7 | +# |
| 8 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | +# |
| 10 | +# Unless required by applicable law or agreed to in writing, software |
| 11 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | +# See the License for the specific language governing permissions and |
| 14 | +# limitations under the License. |
| 15 | + |
| 16 | +from ._base import Config, ConfigError |
| 17 | + |
| 18 | + |
| 19 | +class TracerConfig(Config): |
| 20 | + def read_config(self, config, **kwargs): |
| 21 | + self.tracer_config = config.get("opentracing") |
| 22 | + |
| 23 | + self.tracer_config = config.get("opentracing", {"tracer_enabled": False}) |
| 24 | + |
| 25 | + if self.tracer_config.get("tracer_enabled", False): |
| 26 | + # The tracer is enabled so sanitize the config |
| 27 | + # If no whitelists are given |
| 28 | + self.tracer_config.setdefault("homeserver_whitelist", []) |
| 29 | + |
| 30 | + if not isinstance(self.tracer_config.get("homeserver_whitelist"), list): |
| 31 | + raise ConfigError("Tracer homesererver_whitelist config is malformed") |
| 32 | + |
| 33 | + def generate_config_section(cls, **kwargs): |
| 34 | + return """\ |
| 35 | + ## Opentracing ## |
| 36 | + # These settings enable opentracing which implements distributed tracing |
| 37 | + # This allows you to observe the causal chain of events across servers |
| 38 | + # including requests, key lookups etc. across any server running |
| 39 | + # synapse or any other other services which supports opentracing. |
| 40 | + # (specifically those implemented with jaeger) |
| 41 | +
|
| 42 | + #opentracing: |
| 43 | + # # Enable / disable tracer |
| 44 | + # tracer_enabled: false |
| 45 | + # # The list of homeservers we wish to expose our current traces to. |
| 46 | + # # The list is a list of regexes which are matched against the |
| 47 | + # # servername of the homeserver |
| 48 | + # homeserver_whitelist: |
| 49 | + # - ".*" |
| 50 | + """ |
0 commit comments