Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove disutils in Logstash #2533

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions logstash/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# CHANGELOG - Logstash

##

**Fixed**:

* Removed `disutils` and remove six references.

## 1.1.0

***Added***:
Expand Down
2 changes: 1 addition & 1 deletion logstash/datadog_checks/logstash/__about__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '1.1.0'
__version__ = '1.2.0'
18 changes: 9 additions & 9 deletions logstash/datadog_checks/logstash/logstash.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# stdlib
from collections import namedtuple
from distutils.version import LooseVersion

# 3rd party
from six import iteritems
from six.moves.urllib.parse import urljoin, urlparse
from urllib.parse import urljoin, urlparse

from packaging.version import Version

# project
from datadog_checks.base import AgentCheck
Expand Down Expand Up @@ -182,7 +182,7 @@ def _get_logstash_version(self, config):

def _is_multi_pipeline(self, version):
"""Reusable version checker"""
return version and LooseVersion(version) >= LooseVersion("6.0.0")
return version and Version(version) >= Version("6.0.0")

def check(self, instance):
config = self.get_instance_config(instance)
Expand All @@ -192,13 +192,13 @@ def check(self, instance):
stats_url = urljoin(config.url, '/_node/stats')
stats_data = self._get_data(stats_url, config)

for metric, desc in iteritems(self.STATS_METRICS):
for metric, desc in self.STATS_METRICS.items():
self._process_metric(stats_data, metric, *desc, tags=config.tags)

if not self._is_multi_pipeline(logstash_version):
self._process_pipeline_data(stats_data['pipeline'], config.tags, logstash_version)
elif 'pipelines' in stats_data:
for pipeline_name, pipeline_data in iteritems(stats_data['pipelines']):
for pipeline_name, pipeline_data in stats_data['pipelines'].items():
if pipeline_name.startswith('.'):
# skip internal pipelines like '.monitoring_logstash'
continue
Expand All @@ -209,7 +209,7 @@ def check(self, instance):
self.service_check(self.SERVICE_CHECK_CONNECT_NAME, AgentCheck.OK, tags=config.service_check_tags)

def _process_stats_data(self, data, stats_metrics, config):
for metric, desc in iteritems(stats_metrics):
for metric, desc in stats_metrics.items():
self._process_metric(data, metric, *desc, tags=config.tags)

def _process_pipeline_data(self, pipeline_data, tags, logstash_version):
Expand All @@ -235,7 +235,7 @@ def _process_top_level_pipeline_data(self, pipeline_data, tags, logstash_version
pipeline_metrics = self.PIPELINE_METRICS
if self._is_multi_pipeline(logstash_version):
pipeline_metrics.update(self.PIPELINE_QUEUE_METRICS)
for metric, metric_desc in iteritems(pipeline_metrics):
for metric, metric_desc in pipeline_metrics.items():
self._process_metric(pipeline_data, metric, *metric_desc, tags=tags)

def _process_pipeline_plugins_data(
Expand All @@ -256,7 +256,7 @@ def _process_pipeline_plugins_data(
if plugin_conf_id:
metrics_tags.append(u"plugin_conf_id:{}".format(plugin_conf_id))

for metric, desc in iteritems(pipeline_plugins_metrics):
for metric, desc in pipeline_plugins_metrics.items():
self._process_metric(plugin_data, metric, *desc, tags=metrics_tags)

def _process_metric(self, data, metric, xtype, path, tags=None, hostname=None):
Expand Down
Loading