Skip to content

Commit

Permalink
if collect_server_info is set to false disable server info and versio…
Browse files Browse the repository at this point in the history
…n collection
  • Loading branch information
HadhemiDD committed Jun 13, 2023
1 parent d45f39e commit ff2ef14
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
8 changes: 6 additions & 2 deletions envoy/datadog_checks/envoy/check.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
6 changes: 4 additions & 2 deletions envoy/datadog_checks/envoy/envoy.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

0 comments on commit ff2ef14

Please sign in to comment.