datadog-checks-base 37.0.0__py2.py3-none-any.whl → 37.1.1__py2.py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. datadog_checks/base/__about__.py +1 -1
  2. datadog_checks/base/__init__.py +6 -14
  3. datadog_checks/base/checks/base.py +13 -21
  4. datadog_checks/base/checks/libs/prometheus.py +0 -1
  5. datadog_checks/base/checks/libs/thread_pool.py +1 -2
  6. datadog_checks/base/checks/openmetrics/base_check.py +1 -3
  7. datadog_checks/base/checks/openmetrics/mixins.py +11 -15
  8. datadog_checks/base/checks/openmetrics/v2/base.py +1 -4
  9. datadog_checks/base/checks/openmetrics/v2/transform.py +1 -3
  10. datadog_checks/base/checks/openmetrics/v2/transformers/service_check.py +1 -3
  11. datadog_checks/base/checks/prometheus/base_check.py +1 -3
  12. datadog_checks/base/checks/prometheus/mixins.py +8 -12
  13. datadog_checks/base/checks/win/winpdh.py +4 -5
  14. datadog_checks/base/checks/win/winpdh_base.py +2 -3
  15. datadog_checks/base/checks/win/wmi/__init__.py +1 -3
  16. datadog_checks/base/checks/win/wmi/sampler.py +7 -11
  17. datadog_checks/base/checks/windows/perf_counters/base.py +6 -8
  18. datadog_checks/base/ddyaml.py +1 -2
  19. datadog_checks/base/log.py +0 -16
  20. datadog_checks/base/stubs/aggregator.py +6 -8
  21. datadog_checks/base/stubs/datadog_agent.py +12 -4
  22. datadog_checks/base/stubs/similar.py +1 -3
  23. datadog_checks/base/utils/common.py +4 -6
  24. datadog_checks/base/utils/containers.py +1 -2
  25. datadog_checks/base/utils/db/query.py +2 -4
  26. datadog_checks/base/utils/db/utils.py +4 -4
  27. datadog_checks/base/utils/headers.py +12 -24
  28. datadog_checks/base/utils/http.py +14 -16
  29. datadog_checks/base/utils/metadata/core.py +2 -4
  30. datadog_checks/base/utils/metadata/utils.py +1 -2
  31. datadog_checks/base/utils/network.py +0 -12
  32. datadog_checks/base/utils/prometheus/metrics_pb2.py +46 -877
  33. datadog_checks/base/utils/subprocess_output.py +1 -3
  34. datadog_checks/base/utils/time.py +2 -18
  35. datadog_checks/base/utils/tls.py +3 -5
  36. datadog_checks/base/utils/tracing.py +1 -3
  37. {datadog_checks_base-37.0.0.dist-info → datadog_checks_base-37.1.1.dist-info}/METADATA +3 -4
  38. {datadog_checks_base-37.0.0.dist-info → datadog_checks_base-37.1.1.dist-info}/RECORD +39 -39
  39. {datadog_checks_base-37.0.0.dist-info → datadog_checks_base-37.1.1.dist-info}/WHEEL +1 -1
@@ -1,4 +1,4 @@
1
1
  # (C) Datadog, Inc. 2018-present
2
2
  # All rights reserved
3
3
  # Licensed under a 3-clause BSD style license (see LICENSE)
4
- __version__ = "37.0.0"
4
+ __version__ = "37.1.1"
@@ -1,28 +1,20 @@
1
1
  # (C) Datadog, Inc. 2018-present
2
2
  # All rights reserved
3
3
  # Licensed under a 3-clause BSD style license (see LICENSE)
4
- from six import PY3
5
-
6
- if PY3:
7
- from datadog_checks.base.agent import datadog_agent
8
-
9
- if datadog_agent.get_config('use_boringssl'):
10
- import urllib3.contrib.pyopenssl
11
-
12
- urllib3.contrib.pyopenssl.inject_into_urllib3()
4
+ from datadog_checks.base.agent import datadog_agent
13
5
 
14
6
  from .__about__ import __version__
15
7
  from .checks import AgentCheck
16
8
  from .checks.openmetrics import OpenMetricsBaseCheck
9
+ from .checks.openmetrics.v2.base import OpenMetricsBaseCheckV2
17
10
  from .config import is_affirmative
18
11
  from .errors import ConfigurationError
19
12
  from .utils.common import ensure_bytes, ensure_unicode, to_native_string, to_string
20
13
 
21
- # Python 3+
22
- try:
23
- from .checks.openmetrics.v2.base import OpenMetricsBaseCheckV2
24
- except ImportError:
25
- OpenMetricsBaseCheckV2 = None
14
+ if datadog_agent.get_config('use_boringssl'):
15
+ import urllib3.contrib.pyopenssl
16
+
17
+ urllib3.contrib.pyopenssl.inject_into_urllib3()
26
18
 
27
19
  # Windows-only
28
20
  try:
@@ -27,7 +27,7 @@ from typing import ( # noqa: F401
27
27
  )
28
28
 
29
29
  import yaml
30
- from six import PY2, binary_type, iteritems, raise_from, text_type
30
+ from pydantic import BaseModel, ValidationError
31
31
 
32
32
  from datadog_checks.base.agent import AGENT_RUNNING, aggregator, datadog_agent
33
33
 
@@ -84,9 +84,6 @@ if is_affirmative(datadog_agent.get_config('integration_profiling')):
84
84
  prof = Profiler(service='datadog-agent-integrations')
85
85
  prof.start()
86
86
 
87
- if not PY2:
88
- from pydantic import BaseModel, ValidationError
89
-
90
87
  if TYPE_CHECKING:
91
88
  import ssl # noqa: F401
92
89
 
@@ -305,8 +302,7 @@ class AgentCheck(object):
305
302
  # Functions that will be called exactly once (if successful) before the first check run
306
303
  self.check_initializations = deque() # type: Deque[Callable[[], None]]
307
304
 
308
- if not PY2:
309
- self.check_initializations.append(self.load_configuration_models)
305
+ self.check_initializations.append(self.load_configuration_models)
310
306
 
311
307
  self.__formatted_tags = None
312
308
  self.__logs_enabled = None
@@ -506,11 +502,9 @@ class AgentCheck(object):
506
502
 
507
503
  known_options = {k for k, _ in models_config} # type: Set[str]
508
504
 
509
- if not PY2:
510
-
511
- if isinstance(models_config, BaseModel):
512
- # Also add aliases, if any
513
- known_options.update(set(models_config.model_dump(by_alias=True)))
505
+ if isinstance(models_config, BaseModel):
506
+ # Also add aliases, if any
507
+ known_options.update(set(models_config.model_dump(by_alias=True)))
514
508
 
515
509
  unknown_options = [option for option in user_configs.keys() if option not in known_options] # type: List[str]
516
510
 
@@ -562,8 +556,7 @@ class AgentCheck(object):
562
556
  def load_configuration_model(import_path, model_name, config, context):
563
557
  try:
564
558
  package = importlib.import_module(import_path)
565
- # TODO: remove the type ignore when we drop Python 2
566
- except ModuleNotFoundError as e: # type: ignore
559
+ except ModuleNotFoundError as e:
567
560
  # Don't fail if there are no models
568
561
  if str(e).startswith('No module named '):
569
562
  return
@@ -574,8 +567,7 @@ class AgentCheck(object):
574
567
  if model is not None:
575
568
  try:
576
569
  config_model = model.model_validate(config, context=context)
577
- # TODO: remove the type ignore when we drop Python 2
578
- except ValidationError as e: # type: ignore
570
+ except ValidationError as e:
579
571
  errors = e.errors()
580
572
  num_errors = len(errors)
581
573
  message_lines = [
@@ -594,7 +586,7 @@ class AgentCheck(object):
594
586
  )
595
587
  message_lines.append(' {}'.format(error['msg']))
596
588
 
597
- raise_from(ConfigurationError('\n'.join(message_lines)), None)
589
+ raise ConfigurationError('\n'.join(message_lines)) from None
598
590
  else:
599
591
  return config_model
600
592
 
@@ -1123,7 +1115,7 @@ class AgentCheck(object):
1123
1115
  new_tags = []
1124
1116
  for hostname, source_map in external_tags:
1125
1117
  new_tags.append((to_native_string(hostname), source_map))
1126
- for src_name, tags in iteritems(source_map):
1118
+ for src_name, tags in source_map.items():
1127
1119
  source_map[src_name] = self._normalize_tags_type(tags)
1128
1120
  datadog_agent.set_external_tags(new_tags)
1129
1121
  except IndexError:
@@ -1222,7 +1214,7 @@ class AgentCheck(object):
1222
1214
  prefix: A prefix to to add to the normalized name, default None
1223
1215
  fix_case: A boolean, indicating whether to make sure that the metric name returned is in "snake_case"
1224
1216
  """
1225
- if isinstance(metric, text_type):
1217
+ if isinstance(metric, str):
1226
1218
  metric = unicodedata.normalize('NFKD', metric).encode('ascii', 'ignore')
1227
1219
 
1228
1220
  if fix_case:
@@ -1247,7 +1239,7 @@ class AgentCheck(object):
1247
1239
  This happens for legacy reasons, when we cleaned up some characters (like '-')
1248
1240
  which are allowed in tags.
1249
1241
  """
1250
- if isinstance(tag, text_type):
1242
+ if isinstance(tag, str):
1251
1243
  tag = tag.encode('utf-8', 'ignore')
1252
1244
  tag = self.TAG_REPLACEMENT.sub(br'_', tag)
1253
1245
  tag = self.MULTIPLE_UNDERSCORE_CLEANUP.sub(br'_', tag)
@@ -1345,8 +1337,8 @@ class AgentCheck(object):
1345
1337
  the event to be sent
1346
1338
  """
1347
1339
  # Enforce types of some fields, considerably facilitates handling in go bindings downstream
1348
- for key, value in iteritems(event):
1349
- if not isinstance(value, (text_type, binary_type)):
1340
+ for key, value in event.items():
1341
+ if not isinstance(value, (str, bytes)):
1350
1342
  continue
1351
1343
 
1352
1344
  try:
@@ -6,7 +6,6 @@ from itertools import tee
6
6
 
7
7
  from prometheus_client.metrics_core import Metric
8
8
  from prometheus_client.parser import _parse_sample, _replace_help_escaping
9
- from six.moves import zip
10
9
 
11
10
 
12
11
  def text_fd_to_metric_families(fd):
@@ -25,8 +25,7 @@
25
25
  import sys
26
26
  import threading
27
27
  import traceback
28
-
29
- from six.moves import queue, range
28
+ import queue
30
29
 
31
30
  # Item pushed on the work queue to tell the worker threads to terminate
32
31
  SENTINEL = "QUIT"
@@ -4,7 +4,6 @@
4
4
  from copy import deepcopy
5
5
 
6
6
  import requests
7
- from six import PY2
8
7
 
9
8
  from ...errors import CheckException
10
9
  from ...utils.tracing import traced_class
@@ -183,5 +182,4 @@ class StandardFields(object):
183
182
  pass
184
183
 
185
184
 
186
- if not PY2:
187
- StandardFields.__doc__ = '\n'.join('- `{}`'.format(field) for field in STANDARD_FIELDS)
185
+ StandardFields.__doc__ = '\n'.join('- `{}`'.format(field) for field in STANDARD_FIELDS)
@@ -12,7 +12,6 @@ from re import compile
12
12
 
13
13
  import requests
14
14
  from prometheus_client.samples import Sample
15
- from six import PY3, iteritems, string_types
16
15
 
17
16
  from datadog_checks.base.agent import datadog_agent
18
17
 
@@ -23,9 +22,6 @@ from ...utils.http import RequestsWrapper
23
22
  from .. import AgentCheck
24
23
  from ..libs.prometheus import text_fd_to_metric_families
25
24
 
26
- if PY3:
27
- long = int
28
-
29
25
 
30
26
  class OpenMetricsScraperMixin(object):
31
27
  # pylint: disable=E1101
@@ -110,7 +106,7 @@ class OpenMetricsScraperMixin(object):
110
106
  # We merge list and dictionaries from optional defaults & instance settings
111
107
  metrics = default_instance.get('metrics', []) + instance.get('metrics', [])
112
108
  for metric in metrics:
113
- if isinstance(metric, string_types):
109
+ if isinstance(metric, str):
114
110
  metrics_mapper[metric] = metric
115
111
  else:
116
112
  metrics_mapper.update(metric)
@@ -273,7 +269,7 @@ class OpenMetricsScraperMixin(object):
273
269
  config['_type_override_patterns'] = {}
274
270
 
275
271
  with_wildcards = set()
276
- for metric, type in iteritems(config['type_overrides']):
272
+ for metric, type in config['type_overrides'].items():
277
273
  if '*' in metric:
278
274
  config['_type_override_patterns'][compile(translate(metric))] = type
279
275
  with_wildcards.add(metric)
@@ -468,7 +464,7 @@ class OpenMetricsScraperMixin(object):
468
464
  if type_override:
469
465
  metric.type = type_override
470
466
  elif scraper_config['_type_override_patterns']:
471
- for pattern, new_type in iteritems(scraper_config['_type_override_patterns']):
467
+ for pattern, new_type in scraper_config['_type_override_patterns'].items():
472
468
  if pattern.search(metric.name):
473
469
  metric.type = new_type
474
470
  break
@@ -518,7 +514,7 @@ class OpenMetricsScraperMixin(object):
518
514
  watched['sets'] = {}
519
515
  watched['keys'] = {}
520
516
  watched['singles'] = set()
521
- for key, val in iteritems(scraper_config['label_joins']):
517
+ for key, val in scraper_config['label_joins'].items():
522
518
  labels = []
523
519
  if 'labels_to_match' in val:
524
520
  labels = val['labels_to_match']
@@ -542,7 +538,7 @@ class OpenMetricsScraperMixin(object):
542
538
  # Set dry run off
543
539
  scraper_config['_dry_run'] = False
544
540
  # Garbage collect unused mapping and reset active labels
545
- for metric, mapping in list(iteritems(scraper_config['_label_mapping'])):
541
+ for metric, mapping in scraper_config['_label_mapping'].items():
546
542
  for key in list(mapping):
547
543
  if (
548
544
  metric in scraper_config['_active_label_mapping']
@@ -599,7 +595,7 @@ class OpenMetricsScraperMixin(object):
599
595
 
600
596
  def transform_metadata(self, metric, scraper_config):
601
597
  labels = metric.samples[0][self.SAMPLE_LABELS]
602
- for metadata_name, label_name in iteritems(scraper_config['metadata_label_map']):
598
+ for metadata_name, label_name in scraper_config['metadata_label_map'].items():
603
599
  if label_name in labels:
604
600
  self.set_metadata(metadata_name, labels[label_name])
605
601
 
@@ -662,7 +658,7 @@ class OpenMetricsScraperMixin(object):
662
658
  label_dict = {}
663
659
 
664
660
  if get_all:
665
- for label_name, label_value in iteritems(sample_labels):
661
+ for label_name, label_value in sample_labels.items():
666
662
  if label_name in matching_labels:
667
663
  continue
668
664
  label_dict[label_name] = label_value
@@ -717,7 +713,7 @@ class OpenMetricsScraperMixin(object):
717
713
  sample_labels.update(label_mapping[mapping_key][mapping_value])
718
714
 
719
715
  # Match with tuples of labels
720
- for key, mapping_key in iteritems(keys):
716
+ for key, mapping_key in keys.items():
721
717
  if mapping_key in matching_single_labels:
722
718
  continue
723
719
 
@@ -806,7 +802,7 @@ class OpenMetricsScraperMixin(object):
806
802
 
807
803
  return
808
804
  # check for wildcards in transformers
809
- for transformer_name, transformer in iteritems(metric_transformers):
805
+ for transformer_name, transformer in metric_transformers.items():
810
806
  if transformer_name.endswith('*') and metric.name.startswith(transformer_name[:-1]):
811
807
  transformer(metric, scraper_config, transformer_name)
812
808
 
@@ -1058,7 +1054,7 @@ class OpenMetricsScraperMixin(object):
1058
1054
  def _compute_bucket_hash(self, tags):
1059
1055
  # we need the unique context for all the buckets
1060
1056
  # hence we remove the "le" tag
1061
- return hash(frozenset(sorted((k, v) for k, v in iteritems(tags) if k != 'le')))
1057
+ return hash(frozenset(sorted((k, v) for k, v in tags.items() if k != 'le')))
1062
1058
 
1063
1059
  def _decumulate_histogram_buckets(self, metric):
1064
1060
  """
@@ -1174,7 +1170,7 @@ class OpenMetricsScraperMixin(object):
1174
1170
  custom_tags = scraper_config['custom_tags']
1175
1171
  _tags = list(custom_tags)
1176
1172
  _tags.extend(scraper_config['_metric_tags'])
1177
- for label_name, label_value in iteritems(sample[self.SAMPLE_LABELS]):
1173
+ for label_name, label_value in sample[self.SAMPLE_LABELS].items():
1178
1174
  if label_name not in scraper_config['exclude_labels']:
1179
1175
  if label_name in scraper_config['include_labels'] or len(scraper_config['include_labels']) == 0:
1180
1176
  tag_name = scraper_config['labels_mapper'].get(label_name, label_name)
@@ -1,13 +1,10 @@
1
1
  # (C) Datadog, Inc. 2020-present
2
2
  # All rights reserved
3
3
  # Licensed under a 3-clause BSD style license (see LICENSE)
4
- # TODO: remove ignore when we stop invoking Mypy with --py2
5
- # type: ignore
6
4
  from collections import ChainMap
7
5
  from contextlib import contextmanager
8
6
 
9
7
  from requests.exceptions import RequestException
10
- from six import raise_from
11
8
 
12
9
  from ....errors import ConfigurationError
13
10
  from ....utils.tracing import traced_class
@@ -75,7 +72,7 @@ class OpenMetricsBaseCheckV2(AgentCheck):
75
72
  scraper.scrape()
76
73
  except (ConnectionError, RequestException) as e:
77
74
  self.log.error("There was an error scraping endpoint %s: %s", endpoint, str(e))
78
- raise_from(type(e)("There was an error scraping endpoint {}: {}".format(endpoint, e)), None)
75
+ raise type(e)("There was an error scraping endpoint {}: {}".format(endpoint, e)) from None
79
76
 
80
77
  def configure_scrapers(self):
81
78
  """
@@ -4,8 +4,6 @@
4
4
  import re
5
5
  from copy import deepcopy
6
6
 
7
- from six import raise_from
8
-
9
7
  from ....config import is_affirmative
10
8
  from . import transformers
11
9
 
@@ -53,7 +51,7 @@ class MetricTransformer:
53
51
  self.transformer_data[raw_metric_name] = self.compile_transformer(config)
54
52
  except Exception as e:
55
53
  error = f'Error compiling transformer for metric `{raw_metric_name}`: {e}'
56
- raise_from(type(e)(error), None)
54
+ raise type(e)(error) from None
57
55
 
58
56
  def get(self, metric):
59
57
  metric_name = metric.name
@@ -1,8 +1,6 @@
1
1
  # (C) Datadog, Inc. 2020-present
2
2
  # All rights reserved
3
3
  # Licensed under a 3-clause BSD style license (see LICENSE)
4
- from six import raise_from
5
-
6
4
  from .....constants import ServiceCheck
7
5
 
8
6
 
@@ -56,7 +54,7 @@ def compile_service_check_statuses(modifiers):
56
54
  try:
57
55
  value = int(value)
58
56
  except Exception:
59
- raise_from(TypeError(f'value `{value}` of parameter `status_map` does not represent an integer'), None)
57
+ raise TypeError(f'value `{value}` of parameter `status_map` does not represent an integer') from None
60
58
 
61
59
  if not isinstance(status_string, str):
62
60
  raise ValueError(f'status `{status_string}` for value `{value}` of parameter `status_map` is not a string')
@@ -1,8 +1,6 @@
1
1
  # (C) Datadog, Inc. 2018-present
2
2
  # All rights reserved
3
3
  # Licensed under a 3-clause BSD style license (see LICENSE)
4
- from six import string_types
5
-
6
4
  from ...errors import CheckException
7
5
  from ...utils.common import to_native_string
8
6
  from .. import AgentCheck
@@ -145,7 +143,7 @@ class GenericPrometheusCheck(AgentCheck):
145
143
  # We merge list and dictionaries from optional defaults & instance settings
146
144
  metrics = default_instance.get("metrics", []) + instance.get("metrics", [])
147
145
  for metric in metrics:
148
- if isinstance(metric, string_types):
146
+ if isinstance(metric, str):
149
147
  metrics_mapper[metric] = metric
150
148
  else:
151
149
  metrics_mapper.update(metric)
@@ -10,7 +10,6 @@ from math import isinf, isnan
10
10
 
11
11
  import requests
12
12
  from google.protobuf.internal.decoder import _DecodeVarint32 # pylint: disable=E0611,E0401
13
- from six import PY3, iteritems, itervalues
14
13
 
15
14
  from ...config import is_affirmative
16
15
  from ...utils.http import RequestsWrapper
@@ -18,9 +17,6 @@ from ...utils.prometheus import metrics_pb2
18
17
  from .. import AgentCheck
19
18
  from ..libs.prometheus import text_fd_to_metric_families
20
19
 
21
- if PY3:
22
- long = int
23
-
24
20
 
25
21
  class PrometheusFormat:
26
22
  """
@@ -276,11 +272,11 @@ class PrometheusScraperMixin(object):
276
272
  """
277
273
  metric_name = '{}_{}'.format(_m, metric_suffix)
278
274
  expected_labels = {
279
- (k, v) for k, v in iteritems(_metric["labels"]) if k not in PrometheusScraperMixin.UNWANTED_LABELS
275
+ (k, v) for k, v in _metric["labels"].items() if k not in PrometheusScraperMixin.UNWANTED_LABELS
280
276
  }
281
277
  for elt in messages[metric_name]:
282
278
  current_labels = {
283
- (k, v) for k, v in iteritems(elt["labels"]) if k not in PrometheusScraperMixin.UNWANTED_LABELS
279
+ (k, v) for k, v in elt["labels"].items() if k not in PrometheusScraperMixin.UNWANTED_LABELS
284
280
  }
285
281
  # As we have two hashable objects we can compare them without any side effects
286
282
  if current_labels == expected_labels:
@@ -307,7 +303,7 @@ class PrometheusScraperMixin(object):
307
303
  # in the case of quantiles and buckets, they need to be grouped by labels
308
304
  if obj_map[_m] in ['summary', 'histogram'] and len(_obj.metric) > 0:
309
305
  _label_exists = False
310
- _metric_minus = {k: v for k, v in list(iteritems(_metric['labels'])) if k not in ['quantile', 'le']}
306
+ _metric_minus = {k: v for k, v in _metric['labels'].items() if k not in ['quantile', 'le']}
311
307
  _metric_idx = 0
312
308
  for mls in _obj.metric:
313
309
  _tmp_lbl = {idx.name: idx.value for idx in mls.label}
@@ -327,13 +323,13 @@ class PrometheusScraperMixin(object):
327
323
  _g.gauge.value = float(_metric['value'])
328
324
  elif obj_map[_m] == 'summary':
329
325
  if '{}_count'.format(_m) in messages:
330
- _g.summary.sample_count = long(self.get_metric_value_by_labels(messages, _metric, _m, 'count'))
326
+ _g.summary.sample_count = int(self.get_metric_value_by_labels(messages, _metric, _m, 'count'))
331
327
  if '{}_sum'.format(_m) in messages:
332
328
  _g.summary.sample_sum = self.get_metric_value_by_labels(messages, _metric, _m, 'sum')
333
329
  # TODO: see what can be done with the untyped metrics
334
330
  elif obj_map[_m] == 'histogram':
335
331
  if '{}_count'.format(_m) in messages:
336
- _g.histogram.sample_count = long(self.get_metric_value_by_labels(messages, _metric, _m, 'count'))
332
+ _g.histogram.sample_count = int(self.get_metric_value_by_labels(messages, _metric, _m, 'count'))
337
333
  if '{}_sum'.format(_m) in messages:
338
334
  _g.histogram.sample_sum = self.get_metric_value_by_labels(messages, _metric, _m, 'sum')
339
335
  # last_metric = len(_obj.metric) - 1
@@ -350,7 +346,7 @@ class PrometheusScraperMixin(object):
350
346
  # _q = _obj.metric[last_metric].histogram.bucket.add()
351
347
  _q = _g.histogram.bucket.add()
352
348
  _q.upper_bound = float(_metric['labels'][lbl])
353
- _q.cumulative_count = long(float(_metric['value']))
349
+ _q.cumulative_count = int(float(_metric['value']))
354
350
  else:
355
351
  # labels deduplication
356
352
  is_in_labels = False
@@ -374,7 +370,7 @@ class PrometheusScraperMixin(object):
374
370
  self._dry_run = False
375
371
  elif not self._watched_labels:
376
372
  # build the _watched_labels set
377
- for val in itervalues(self.label_joins):
373
+ for val in self.label_joins.values():
378
374
  self._watched_labels.add(val['label_to_match'])
379
375
 
380
376
  for metric in self.parse_metric_family(response):
@@ -383,7 +379,7 @@ class PrometheusScraperMixin(object):
383
379
  # Set dry run off
384
380
  self._dry_run = False
385
381
  # Garbage collect unused mapping and reset active labels
386
- for metric, mapping in list(iteritems(self._label_mapping)):
382
+ for metric, mapping in self._label_mapping.items():
387
383
  for key in list(mapping):
388
384
  if key not in self._active_label_mapping[metric]:
389
385
  del self._label_mapping[metric][key]
@@ -2,11 +2,10 @@
2
2
  # All rights reserved
3
3
  # Licensed under a 3-clause BSD style license (see LICENSE)
4
4
  import time
5
+ import winreg
5
6
  from collections import defaultdict
6
7
 
7
8
  import win32pdh
8
- from six import iteritems, text_type
9
- from six.moves import winreg
10
9
 
11
10
  DATA_TYPE_INT = win32pdh.PDH_FMT_LONG
12
11
  DATA_TYPE_DOUBLE = win32pdh.PDH_FMT_DOUBLE
@@ -98,7 +97,7 @@ class WinPDHCounter(object):
98
97
  # names in the class "network interface"
99
98
  win32pdh.CollectQueryData(self.hq)
100
99
 
101
- for inst, counter_handle in iteritems(self.counterdict):
100
+ for inst, counter_handle in self.counterdict.items():
102
101
  try:
103
102
  t, val = win32pdh.GetFormattedCounterValue(counter_handle, self._precision)
104
103
  ret[inst] = val
@@ -183,7 +182,7 @@ class WinPDHCounter(object):
183
182
  # check to see if this counter is in the list of counters for this class
184
183
  if c not in counters:
185
184
  try:
186
- self.logger.debug("Index %s counter %s not in counter list", index, text_type(c))
185
+ self.logger.debug("Index %s counter %s not in counter list", index, str(c))
187
186
  except: # noqa: E722, B001
188
187
  # some unicode characters are not translatable here. Don't fail just
189
188
  # because we couldn't log
@@ -197,7 +196,7 @@ class WinPDHCounter(object):
197
196
  break
198
197
  except: # noqa: E722, B001
199
198
  try:
200
- self.logger.info("Unable to make path with counter %s, trying next available", text_type(c))
199
+ self.logger.info("Unable to make path with counter %s, trying next available", str(c))
201
200
  except: # noqa: E722, B001
202
201
  self.logger.info("Unable to make path with counter index %s, trying next available", index)
203
202
  return path
@@ -5,7 +5,6 @@ from collections import defaultdict
5
5
  from typing import Callable, Dict, List, Optional, Tuple # noqa: F401
6
6
 
7
7
  import win32wnet
8
- from six import iteritems
9
8
 
10
9
  from ... import AgentCheck, is_affirmative
11
10
  from ...utils.containers import hash_mutable
@@ -171,7 +170,7 @@ class PDHBaseCheck(AgentCheck):
171
170
  def do_refresh_counters(self):
172
171
  if self.refresh_counters:
173
172
  self.log.debug('Refreshing counters')
174
- for counter, values in list(iteritems(self._missing_counters)):
173
+ for counter, values in self._missing_counters.items():
175
174
  self._make_counters(counter_data=([counter], values))
176
175
 
177
176
  def get_counter_values(self, counterobj):
@@ -187,7 +186,7 @@ class PDHBaseCheck(AgentCheck):
187
186
  for inst_name, dd_name, metric_func, counterobj in self._metrics[self.instance_hash]:
188
187
  try:
189
188
  vals = self.get_counter_values(counterobj)
190
- for instance_name, val in iteritems(vals):
189
+ for instance_name, val in vals.items():
191
190
  tags = list(self._tags.get(self.instance_hash, [])) # type: List[str]
192
191
 
193
192
  if not counterobj.is_single_instance():
@@ -3,8 +3,6 @@
3
3
  # Licensed under a 3-clause BSD style license (see LICENSE)
4
4
  from typing import Any, Dict, List, Optional, Tuple
5
5
 
6
- from six import iteritems
7
-
8
6
  from ... import AgentCheck
9
7
  from .sampler import WMISampler
10
8
  from .types import TagQuery, WMIFilter, WMIMetric, WMIObject, WMIProperties
@@ -177,7 +175,7 @@ class WinWMICheck(AgentCheck):
177
175
  except TagQueryUniquenessFailure:
178
176
  continue
179
177
 
180
- for wmi_property, wmi_value in iteritems(wmi_obj):
178
+ for wmi_property, wmi_value in wmi_obj.items():
181
179
  # skips any property not in arguments since SWbemServices.ExecQuery will return key prop properties
182
180
  # https://msdn.microsoft.com/en-us/library/aa393866(v=vs.85).aspx
183
181
 
@@ -28,8 +28,6 @@ from threading import Event, Thread
28
28
 
29
29
  import pythoncom
30
30
  import pywintypes
31
- from six import iteritems, string_types, with_metaclass
32
- from six.moves import zip
33
31
  from win32com.client import Dispatch
34
32
 
35
33
  from .counter_type import UndefinedCalculator, get_calculator, get_raw
@@ -67,7 +65,7 @@ class ProviderArchitectureMeta(type):
67
65
  return provider in cls._AVAILABLE_PROVIDER_ARCHITECTURES
68
66
 
69
67
 
70
- class ProviderArchitecture(with_metaclass(ProviderArchitectureMeta, object)):
68
+ class ProviderArchitecture(metaclass=ProviderArchitectureMeta):
71
69
  """
72
70
  Enumerate WMI Provider Architectures.
73
71
  """
@@ -349,7 +347,7 @@ class WMISampler(object):
349
347
  """
350
348
  formatted_wmi_object = CaseInsensitiveDict()
351
349
 
352
- for property_name, property_raw_value in iteritems(current):
350
+ for property_name, property_raw_value in current.items():
353
351
  counter_type = self._property_counter_types.get(property_name)
354
352
  property_formatted_value = property_raw_value
355
353
 
@@ -429,7 +427,7 @@ class WMISampler(object):
429
427
  def build_where_clause(fltr):
430
428
  def add_to_bool_ops(k, v):
431
429
  if isinstance(v, (tuple, list)):
432
- if len(v) == 2 and isinstance(v[0], string_types) and v[0].upper() in WQL_OPERATORS:
430
+ if len(v) == 2 and isinstance(v[0], str) and v[0].upper() in WQL_OPERATORS:
433
431
  # Append if: [WQL_OP, value]
434
432
  # PROPERTY: ['<WQL_OP>', '%bar']
435
433
  # PROPERTY: { <BOOL_OP>: ['<WQL_OP>', 'foo']}
@@ -473,7 +471,7 @@ class WMISampler(object):
473
471
  # - [WQL_OP, val]
474
472
  # - foo
475
473
  # - bar
476
- for k, v in iteritems(value):
474
+ for k, v in value.items():
477
475
  bool_op = default_bool_op
478
476
  if k.upper() in BOOL_OPERATORS:
479
477
  bool_op = k.upper()
@@ -481,7 +479,7 @@ class WMISampler(object):
481
479
  # map NOT to NOR or NAND
482
480
  bool_op = 'N{}'.format(default_bool_op)
483
481
  add_to_bool_ops(bool_op, v)
484
- elif isinstance(value, string_types) and '%' in value:
482
+ elif isinstance(value, str) and '%' in value:
485
483
  # Override operator to LIKE if wildcard detected
486
484
  # e.g.
487
485
  # PROPERTY: 'foo%' -> PROPERTY LIKE 'foo%'
@@ -492,7 +490,7 @@ class WMISampler(object):
492
490
  # PROPERTY: 'bar' -> PROPERTY = 'foo'
493
491
  add_to_bool_ops(default_bool_op, [default_wql_op, value])
494
492
 
495
- for bool_op, value in iteritems(bool_ops):
493
+ for bool_op, value in bool_ops.items():
496
494
  if not len(value):
497
495
  continue
498
496
 
@@ -501,9 +499,7 @@ class WMISampler(object):
501
499
  (prop, x)
502
500
  if isinstance(x, (tuple, list))
503
501
  else (
504
- (prop, ('LIKE', x))
505
- if isinstance(x, string_types) and '%' in x
506
- else (prop, (default_wql_op, x))
502
+ (prop, ('LIKE', x)) if isinstance(x, str) and '%' in x else (prop, (default_wql_op, x))
507
503
  )
508
504
  ),
509
505
  value,