From ff2ef1401c2657e1ef63b2743ba4d6e7cbe05837 Mon Sep 17 00:00:00 2001 From: HadhemiDD Date: Thu, 25 May 2023 17:14:02 +0200 Subject: [PATCH] if collect_server_info is set to false disable server info and version collection --- envoy/datadog_checks/envoy/check.py | 8 ++++++-- envoy/datadog_checks/envoy/envoy.py | 6 ++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/envoy/datadog_checks/envoy/check.py b/envoy/datadog_checks/envoy/check.py index 6dc782892525ca..ec3e6306822ce8 100644 --- a/envoy/datadog_checks/envoy/check.py +++ b/envoy/datadog_checks/envoy/check.py @@ -101,6 +101,8 @@ def __init__(self, name, init_config, instances): super().__init__(name, init_config, instances) self.check_initializations.append(self.configure_additional_transformers) openmetrics_endpoint = self.instance.get('openmetrics_endpoint') + self.collect_server_info = self.instance.get('collect_server_info', True) + self.base_url = None try: parts = urlparse(openmetrics_endpoint) @@ -148,9 +150,11 @@ def _collect_metadata(self): if not self.base_url: self.log.debug("Skipping server info collection due to malformed url: %s", self.base_url) return + raw_version = None # From http://domain/thing/stats to http://domain/thing/server_info - server_info_url = urljoin(self.base_url, 'server_info') - raw_version = _get_server_info(server_info_url, self.log, self.http) + if self.collect_server_info: + server_info_url = urljoin(self.base_url, 'server_info') + raw_version = _get_server_info(server_info_url, self.log, self.http) if raw_version: self.set_metadata('version', raw_version) diff --git a/envoy/datadog_checks/envoy/envoy.py b/envoy/datadog_checks/envoy/envoy.py index 03488f2159821b..3537eae782b4fe 100644 --- a/envoy/datadog_checks/envoy/envoy.py +++ b/envoy/datadog_checks/envoy/envoy.py @@ -192,9 +192,11 @@ def _collect_metadata(self): if not self.collect_server_info: self.log.debug("Skipping server info collection because collect_server_info was disabled") return + raw_version = None # From http://domain/thing/stats to http://domain/thing/server_info - server_info_url = urljoin(self.stats_url, 'server_info') - raw_version = _get_server_info(server_info_url, self.log, self.http) + if self.collect_server_info: + server_info_url = urljoin(self.stats_url, 'server_info') + raw_version = _get_server_info(server_info_url, self.log, self.http) if raw_version: self.set_metadata('version', raw_version)