datadog-checks-base 37.7.0__py2.py3-none-any.whl → 37.9.0__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.
- datadog_checks/base/__about__.py +1 -1
- datadog_checks/base/__init__.py +3 -43
- datadog_checks/base/__init__.pyi +31 -0
- datadog_checks/base/checks/__init__.py +2 -4
- datadog_checks/base/checks/__init__.pyi +7 -0
- datadog_checks/base/checks/base.py +80 -40
- datadog_checks/base/checks/kube_leader/__init__.py +2 -5
- datadog_checks/base/checks/kube_leader/__init__.pyi +8 -0
- datadog_checks/base/checks/kubelet_base/__init__.py +6 -0
- datadog_checks/base/checks/kubelet_base/__init__.pyi +6 -0
- datadog_checks/base/checks/openmetrics/__init__.py +2 -4
- datadog_checks/base/checks/openmetrics/__init__.pyi +6 -0
- datadog_checks/base/checks/openmetrics/v2/scraper.py +0 -2
- datadog_checks/base/checks/openmetrics/v2/transformers/__init__.py +3 -10
- datadog_checks/base/checks/openmetrics/v2/transformers/__init__.pyi +26 -0
- datadog_checks/base/checks/prometheus/__init__.py +2 -5
- datadog_checks/base/checks/prometheus/__init__.pyi +8 -0
- datadog_checks/base/checks/prometheus/mixins.py +1 -1
- datadog_checks/base/checks/win/__init__.py +2 -4
- datadog_checks/base/checks/win/__init__.pyi +7 -0
- datadog_checks/base/checks/win/wmi/__init__.py +2 -386
- datadog_checks/base/checks/win/wmi/__init__.pyi +32 -0
- datadog_checks/base/checks/win/wmi/base.py +390 -0
- datadog_checks/base/log.py +10 -8
- datadog_checks/base/stubs/aggregator.py +2 -0
- datadog_checks/base/stubs/datadog_agent.py +6 -7
- datadog_checks/base/utils/_http_utils.py +51 -0
- datadog_checks/base/utils/db/__init__.py +3 -2
- datadog_checks/base/utils/db/__init__.pyi +7 -0
- datadog_checks/base/utils/db/sql.py +2 -2
- datadog_checks/base/utils/db/utils.py +3 -3
- datadog_checks/base/utils/discovery/__init__.py +3 -1
- datadog_checks/base/utils/discovery/__init__.pyi +6 -0
- datadog_checks/base/utils/format/__init__.py +3 -0
- datadog_checks/base/utils/format/_json.py +43 -0
- datadog_checks/base/utils/format/json.py +30 -0
- datadog_checks/base/utils/http.py +37 -66
- datadog_checks/base/utils/metadata/__init__.py +3 -1
- datadog_checks/base/utils/metadata/__init__.pyi +6 -0
- datadog_checks/base/utils/prometheus/__init__.py +2 -1
- datadog_checks/base/utils/prometheus/__init__.pyi +6 -0
- datadog_checks/base/utils/replay/execute.py +6 -5
- datadog_checks/base/utils/replay/redirect.py +8 -7
- datadog_checks/base/utils/serialization.py +5 -0
- datadog_checks/base/utils/tracing.py +10 -1
- {datadog_checks_base-37.7.0.dist-info → datadog_checks_base-37.9.0.dist-info}/METADATA +18 -8
- {datadog_checks_base-37.7.0.dist-info → datadog_checks_base-37.9.0.dist-info}/RECORD +48 -31
- datadog_checks/base/ddyaml.py +0 -171
- {datadog_checks_base-37.7.0.dist-info → datadog_checks_base-37.9.0.dist-info}/WHEEL +0 -0
datadog_checks/base/__about__.py
CHANGED
datadog_checks/base/__init__.py
CHANGED
|
@@ -1,51 +1,11 @@
|
|
|
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
|
-
|
|
4
|
+
import lazy_loader
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
from .checks import AgentCheck
|
|
8
|
-
from .checks.openmetrics import OpenMetricsBaseCheck
|
|
9
|
-
from .checks.openmetrics.v2.base import OpenMetricsBaseCheckV2
|
|
10
|
-
from .config import is_affirmative
|
|
11
|
-
from .errors import ConfigurationError
|
|
12
|
-
from .utils.common import ensure_bytes, ensure_unicode, to_native_string, to_string
|
|
6
|
+
__getattr__, __dir__, __all__ = lazy_loader.attach_stub(__name__, __file__)
|
|
13
7
|
|
|
14
|
-
if datadog_agent.get_config('use_boringssl'):
|
|
8
|
+
if __getattr__('datadog_agent').get_config('use_boringssl'):
|
|
15
9
|
import urllib3.contrib.pyopenssl
|
|
16
10
|
|
|
17
11
|
urllib3.contrib.pyopenssl.inject_into_urllib3()
|
|
18
|
-
|
|
19
|
-
# Windows-only
|
|
20
|
-
try:
|
|
21
|
-
from .checks.win import PDHBaseCheck
|
|
22
|
-
except ImportError:
|
|
23
|
-
PDHBaseCheck = None
|
|
24
|
-
|
|
25
|
-
# Windows-only and Python 3+
|
|
26
|
-
try:
|
|
27
|
-
from .checks.windows.perf_counters import PerfCountersBaseCheck
|
|
28
|
-
except Exception:
|
|
29
|
-
PerfCountersBaseCheck = None
|
|
30
|
-
|
|
31
|
-
# Kubernetes dep will not always be installed
|
|
32
|
-
try:
|
|
33
|
-
from .checks.kube_leader import KubeLeaderElectionBaseCheck
|
|
34
|
-
except ImportError:
|
|
35
|
-
KubeLeaderElectionBaseCheck = None
|
|
36
|
-
|
|
37
|
-
__all__ = [
|
|
38
|
-
'__version__',
|
|
39
|
-
'AgentCheck',
|
|
40
|
-
'KubeLeaderElectionBaseCheck',
|
|
41
|
-
'OpenMetricsBaseCheck',
|
|
42
|
-
'OpenMetricsBaseCheckV2',
|
|
43
|
-
'PDHBaseCheck',
|
|
44
|
-
'PerfCountersBaseCheck',
|
|
45
|
-
'ConfigurationError',
|
|
46
|
-
'ensure_bytes',
|
|
47
|
-
'ensure_unicode',
|
|
48
|
-
'is_affirmative',
|
|
49
|
-
'to_native_string',
|
|
50
|
-
'to_string', # For backwards compat (was renamed to `to_native_string`).
|
|
51
|
-
]
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# (C) Datadog, Inc. 2025-present
|
|
2
|
+
# All rights reserved
|
|
3
|
+
# Licensed under a 3-clause BSD style license (see LICENSE)
|
|
4
|
+
from .__about__ import __version__
|
|
5
|
+
from .agent import datadog_agent
|
|
6
|
+
from .checks import AgentCheck
|
|
7
|
+
from .checks.kube_leader import KubeLeaderElectionBaseCheck
|
|
8
|
+
from .checks.openmetrics import OpenMetricsBaseCheck
|
|
9
|
+
from .checks.openmetrics.v2.base import OpenMetricsBaseCheckV2
|
|
10
|
+
from .checks.win import PDHBaseCheck
|
|
11
|
+
from .checks.windows.perf_counters import PerfCountersBaseCheck
|
|
12
|
+
from .config import is_affirmative
|
|
13
|
+
from .errors import ConfigurationError
|
|
14
|
+
from .utils.common import ensure_bytes, ensure_unicode, to_native_string, to_string
|
|
15
|
+
|
|
16
|
+
__all__ = [
|
|
17
|
+
'__version__',
|
|
18
|
+
'AgentCheck',
|
|
19
|
+
'ConfigurationError',
|
|
20
|
+
'KubeLeaderElectionBaseCheck',
|
|
21
|
+
'OpenMetricsBaseCheck',
|
|
22
|
+
'OpenMetricsBaseCheckV2',
|
|
23
|
+
'PDHBaseCheck',
|
|
24
|
+
'PerfCountersBaseCheck',
|
|
25
|
+
'datadog_agent',
|
|
26
|
+
'ensure_bytes',
|
|
27
|
+
'ensure_unicode',
|
|
28
|
+
'is_affirmative',
|
|
29
|
+
'to_native_string',
|
|
30
|
+
'to_string',
|
|
31
|
+
]
|
|
@@ -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
|
+
import lazy_loader
|
|
4
5
|
|
|
5
|
-
|
|
6
|
-
from .network import EventType, NetworkCheck, Status
|
|
7
|
-
|
|
8
|
-
__all__ = ['AgentCheck', 'NetworkCheck', 'Status', 'EventType']
|
|
6
|
+
__getattr__, __dir__, __all__ = lazy_loader.attach_stub(__name__, __file__)
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
# (C) Datadog, Inc. 2025-present
|
|
2
|
+
# All rights reserved
|
|
3
|
+
# Licensed under a 3-clause BSD style license (see LICENSE)
|
|
4
|
+
from .base import AgentCheck
|
|
5
|
+
from .network import EventType, NetworkCheck, Status
|
|
6
|
+
|
|
7
|
+
__all__ = ['AgentCheck', 'EventType', 'NetworkCheck', 'Status']
|
|
@@ -1,15 +1,14 @@
|
|
|
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 __future__ import annotations
|
|
5
|
+
|
|
4
6
|
import copy
|
|
5
7
|
import functools
|
|
6
8
|
import importlib
|
|
7
|
-
import inspect
|
|
8
9
|
import logging
|
|
9
10
|
import os
|
|
10
11
|
import re
|
|
11
|
-
import traceback
|
|
12
|
-
import unicodedata
|
|
13
12
|
from collections import deque
|
|
14
13
|
from os.path import basename
|
|
15
14
|
from typing import ( # noqa: F401
|
|
@@ -27,10 +26,10 @@ from typing import ( # noqa: F401
|
|
|
27
26
|
Union,
|
|
28
27
|
)
|
|
29
28
|
|
|
30
|
-
import
|
|
31
|
-
from pydantic import BaseModel, ValidationError
|
|
29
|
+
import lazy_loader
|
|
32
30
|
|
|
33
31
|
from datadog_checks.base.agent import AGENT_RUNNING, aggregator, datadog_agent
|
|
32
|
+
from datadog_checks.base.utils.format import json
|
|
34
33
|
|
|
35
34
|
from ..config import is_affirmative
|
|
36
35
|
from ..constants import ServiceCheck
|
|
@@ -46,15 +45,8 @@ from ..types import (
|
|
|
46
45
|
)
|
|
47
46
|
from ..utils.agent.utils import should_profile_memory
|
|
48
47
|
from ..utils.common import ensure_bytes, to_native_string
|
|
49
|
-
from ..utils.diagnose import Diagnosis
|
|
50
48
|
from ..utils.fips import enable_fips
|
|
51
|
-
from ..utils.http import RequestsWrapper
|
|
52
|
-
from ..utils.limiter import Limiter
|
|
53
|
-
from ..utils.metadata import MetadataManager
|
|
54
|
-
from ..utils.secrets import SecretsSanitizer
|
|
55
|
-
from ..utils.serialization import from_json, to_json
|
|
56
49
|
from ..utils.tagging import GENERIC_TAGS
|
|
57
|
-
from ..utils.tls import TlsContextWrapper
|
|
58
50
|
from ..utils.tracing import traced_class
|
|
59
51
|
|
|
60
52
|
if AGENT_RUNNING:
|
|
@@ -65,11 +57,6 @@ else:
|
|
|
65
57
|
|
|
66
58
|
init_logging()
|
|
67
59
|
|
|
68
|
-
if datadog_agent.get_config('disable_unsafe_yaml'):
|
|
69
|
-
from ..ddyaml import monkey_patch_pyyaml
|
|
70
|
-
|
|
71
|
-
monkey_patch_pyyaml()
|
|
72
|
-
|
|
73
60
|
if datadog_agent.get_config('integration_tracing'):
|
|
74
61
|
from ddtrace import patch
|
|
75
62
|
|
|
@@ -87,7 +74,18 @@ if is_affirmative(datadog_agent.get_config('integration_profiling')):
|
|
|
87
74
|
prof.start()
|
|
88
75
|
|
|
89
76
|
if TYPE_CHECKING:
|
|
77
|
+
import inspect as _module_inspect
|
|
90
78
|
import ssl # noqa: F401
|
|
79
|
+
import traceback as _module_traceback
|
|
80
|
+
import unicodedata as _module_unicodedata
|
|
81
|
+
|
|
82
|
+
from datadog_checks.base.utils.diagnose import Diagnosis
|
|
83
|
+
from datadog_checks.base.utils.http import RequestsWrapper
|
|
84
|
+
from datadog_checks.base.utils.metadata import MetadataManager
|
|
85
|
+
|
|
86
|
+
inspect: _module_inspect = lazy_loader.load('inspect')
|
|
87
|
+
traceback: _module_traceback = lazy_loader.load('traceback')
|
|
88
|
+
unicodedata: _module_unicodedata = lazy_loader.load('unicodedata')
|
|
91
89
|
|
|
92
90
|
# Metric types for which it's only useful to submit once per set of tags
|
|
93
91
|
ONE_PER_CONTEXT_METRIC_TYPES = [aggregator.GAUGE, aggregator.RATE, aggregator.MONOTONIC_COUNT]
|
|
@@ -342,6 +340,9 @@ class AgentCheck(object):
|
|
|
342
340
|
limit = self._get_metric_limit(instance=instance)
|
|
343
341
|
|
|
344
342
|
if limit > 0:
|
|
343
|
+
# See Performance Optimizations in this package's README.md.
|
|
344
|
+
from datadog_checks.base.utils.limiter import Limiter
|
|
345
|
+
|
|
345
346
|
return Limiter(name, 'metrics', limit, self.warning)
|
|
346
347
|
|
|
347
348
|
return None
|
|
@@ -380,23 +381,17 @@ class AgentCheck(object):
|
|
|
380
381
|
|
|
381
382
|
return limit
|
|
382
383
|
|
|
383
|
-
@staticmethod
|
|
384
|
-
def load_config(yaml_str):
|
|
385
|
-
# type: (str) -> Any
|
|
386
|
-
"""
|
|
387
|
-
Convenience wrapper to ease programmatic use of this class from the C API.
|
|
388
|
-
"""
|
|
389
|
-
return yaml.safe_load(yaml_str)
|
|
390
|
-
|
|
391
384
|
@property
|
|
392
|
-
def http(self):
|
|
393
|
-
# type: () -> RequestsWrapper
|
|
385
|
+
def http(self) -> RequestsWrapper:
|
|
394
386
|
"""
|
|
395
387
|
Provides logic to yield consistent network behavior based on user configuration.
|
|
396
388
|
|
|
397
389
|
Only new checks or checks on Agent 6.13+ can and should use this for HTTP requests.
|
|
398
390
|
"""
|
|
399
391
|
if not hasattr(self, '_http'):
|
|
392
|
+
# See Performance Optimizations in this package's README.md.
|
|
393
|
+
from datadog_checks.base.utils.http import RequestsWrapper
|
|
394
|
+
|
|
400
395
|
self._http = RequestsWrapper(self.instance or {}, self.init_config, self.HTTP_CONFIG_REMAPPER, self.log)
|
|
401
396
|
|
|
402
397
|
return self._http
|
|
@@ -432,12 +427,14 @@ class AgentCheck(object):
|
|
|
432
427
|
return self.__formatted_tags
|
|
433
428
|
|
|
434
429
|
@property
|
|
435
|
-
def diagnosis(self):
|
|
436
|
-
# type: () -> Diagnosis
|
|
430
|
+
def diagnosis(self) -> Diagnosis:
|
|
437
431
|
"""
|
|
438
432
|
A Diagnosis object to register explicit diagnostics and record diagnoses.
|
|
439
433
|
"""
|
|
440
434
|
if not hasattr(self, '_diagnosis'):
|
|
435
|
+
# See Performance Optimizations in this package's README.md.
|
|
436
|
+
from datadog_checks.base.utils.diagnose import Diagnosis
|
|
437
|
+
|
|
441
438
|
self._diagnosis = Diagnosis(sanitize=self.sanitize)
|
|
442
439
|
return self._diagnosis
|
|
443
440
|
|
|
@@ -451,6 +448,9 @@ class AgentCheck(object):
|
|
|
451
448
|
Since: Agent 7.24
|
|
452
449
|
"""
|
|
453
450
|
if not hasattr(self, '_tls_context_wrapper'):
|
|
451
|
+
# See Performance Optimizations in this package's README.md.
|
|
452
|
+
from datadog_checks.base.utils.tls import TlsContextWrapper
|
|
453
|
+
|
|
454
454
|
self._tls_context_wrapper = TlsContextWrapper(
|
|
455
455
|
self.instance or {}, self.TLS_CONFIG_REMAPPER, overrides=overrides
|
|
456
456
|
)
|
|
@@ -461,8 +461,7 @@ class AgentCheck(object):
|
|
|
461
461
|
return self._tls_context_wrapper.tls_context
|
|
462
462
|
|
|
463
463
|
@property
|
|
464
|
-
def metadata_manager(self):
|
|
465
|
-
# type: () -> MetadataManager
|
|
464
|
+
def metadata_manager(self) -> MetadataManager:
|
|
466
465
|
"""
|
|
467
466
|
Used for sending metadata via Go bindings.
|
|
468
467
|
"""
|
|
@@ -470,6 +469,9 @@ class AgentCheck(object):
|
|
|
470
469
|
if not self.check_id and AGENT_RUNNING:
|
|
471
470
|
raise RuntimeError('Attribute `check_id` must be set')
|
|
472
471
|
|
|
472
|
+
# See Performance Optimizations in this package's README.md.
|
|
473
|
+
from datadog_checks.base.utils.metadata import MetadataManager
|
|
474
|
+
|
|
473
475
|
self._metadata_manager = MetadataManager(self.name, self.check_id, self.log, self.METADATA_TRANSFORMERS)
|
|
474
476
|
|
|
475
477
|
return self._metadata_manager
|
|
@@ -498,8 +500,9 @@ class AgentCheck(object):
|
|
|
498
500
|
return False
|
|
499
501
|
|
|
500
502
|
def log_typos_in_options(self, user_config, models_config, level):
|
|
501
|
-
#
|
|
503
|
+
# See Performance Optimizations in this package's README.md.
|
|
502
504
|
from jellyfish import jaro_winkler_similarity
|
|
505
|
+
from pydantic import BaseModel
|
|
503
506
|
|
|
504
507
|
user_configs = user_config or {} # type: Dict[str, Any]
|
|
505
508
|
models_config = models_config or {}
|
|
@@ -570,6 +573,8 @@ class AgentCheck(object):
|
|
|
570
573
|
|
|
571
574
|
model = getattr(package, model_name, None)
|
|
572
575
|
if model is not None:
|
|
576
|
+
from pydantic import ValidationError
|
|
577
|
+
|
|
573
578
|
try:
|
|
574
579
|
config_model = model.model_validate(config, context=context)
|
|
575
580
|
except ValidationError as e:
|
|
@@ -598,12 +603,14 @@ class AgentCheck(object):
|
|
|
598
603
|
def _get_config_model_context(self, config):
|
|
599
604
|
return {'logger': self.log, 'warning': self.warning, 'configured_fields': frozenset(config)}
|
|
600
605
|
|
|
601
|
-
def register_secret(self, secret):
|
|
602
|
-
# type: (str) -> None
|
|
606
|
+
def register_secret(self, secret: str) -> None:
|
|
603
607
|
"""
|
|
604
608
|
Register a secret to be scrubbed by `.sanitize()`.
|
|
605
609
|
"""
|
|
606
610
|
if not hasattr(self, '_sanitizer'):
|
|
611
|
+
# See Performance Optimizations in this package's README.md.
|
|
612
|
+
from datadog_checks.base.utils.secrets import SecretsSanitizer
|
|
613
|
+
|
|
607
614
|
# Configure lazily so that checks that don't use sanitization aren't affected.
|
|
608
615
|
self._sanitizer = SecretsSanitizer()
|
|
609
616
|
self.log.setup_sanitization(sanitize=self.sanitize)
|
|
@@ -953,6 +960,10 @@ class AgentCheck(object):
|
|
|
953
960
|
# type: (str, ServiceCheckStatus, Sequence[str], str, str, bool) -> None
|
|
954
961
|
"""Send the status of a service.
|
|
955
962
|
|
|
963
|
+
!!! warning "Soft Deprecation"
|
|
964
|
+
When building new checks avoid submitting service checks.
|
|
965
|
+
**Checks that already submit service checks will continue to do so.**
|
|
966
|
+
|
|
956
967
|
Parameters:
|
|
957
968
|
name (str):
|
|
958
969
|
the name of the service check
|
|
@@ -1005,15 +1016,15 @@ class AgentCheck(object):
|
|
|
1005
1016
|
# convert seconds to milliseconds
|
|
1006
1017
|
attributes['timestamp'] = int(timestamp * 1000)
|
|
1007
1018
|
|
|
1008
|
-
datadog_agent.send_log(
|
|
1019
|
+
datadog_agent.send_log(json.encode(attributes), self.check_id)
|
|
1009
1020
|
if cursor is not None:
|
|
1010
|
-
self.write_persistent_cache('log_cursor_{}'.format(stream),
|
|
1021
|
+
self.write_persistent_cache('log_cursor_{}'.format(stream), json.encode(cursor))
|
|
1011
1022
|
|
|
1012
1023
|
def get_log_cursor(self, stream='default'):
|
|
1013
1024
|
# type: (str) -> dict[str, Any] | None
|
|
1014
1025
|
"""Returns the most recent log cursor from disk."""
|
|
1015
1026
|
data = self.read_persistent_cache('log_cursor_{}'.format(stream))
|
|
1016
|
-
return
|
|
1027
|
+
return json.decode(data) if data else None
|
|
1017
1028
|
|
|
1018
1029
|
def _log_deprecation(self, deprecation_key, *args):
|
|
1019
1030
|
# type: (str, *str) -> None
|
|
@@ -1184,7 +1195,11 @@ class AgentCheck(object):
|
|
|
1184
1195
|
The agent calls this method to retrieve diagnostics from integrations. This method
|
|
1185
1196
|
runs explicit diagnostics if available.
|
|
1186
1197
|
"""
|
|
1187
|
-
return
|
|
1198
|
+
return json.encode([d._asdict() for d in (self.diagnosis.diagnoses + self.diagnosis.run_explicit())])
|
|
1199
|
+
|
|
1200
|
+
def _clear_diagnosis(self) -> None:
|
|
1201
|
+
if hasattr(self, '_diagnosis'):
|
|
1202
|
+
self._diagnosis.clear()
|
|
1188
1203
|
|
|
1189
1204
|
def _get_requests_proxy(self):
|
|
1190
1205
|
# type: () -> ProxySettings
|
|
@@ -1268,7 +1283,7 @@ class AgentCheck(object):
|
|
|
1268
1283
|
def run(self):
|
|
1269
1284
|
# type: () -> str
|
|
1270
1285
|
try:
|
|
1271
|
-
self.
|
|
1286
|
+
self._clear_diagnosis()
|
|
1272
1287
|
# Ignore check initializations if running in a separate process
|
|
1273
1288
|
if is_affirmative(self.instance.get('process_isolation', self.init_config.get('process_isolation', False))):
|
|
1274
1289
|
from ..utils.replay.execute import run_with_isolation
|
|
@@ -1304,7 +1319,7 @@ class AgentCheck(object):
|
|
|
1304
1319
|
except Exception as e:
|
|
1305
1320
|
message = self.sanitize(str(e))
|
|
1306
1321
|
tb = self.sanitize(traceback.format_exc())
|
|
1307
|
-
error_report =
|
|
1322
|
+
error_report = json.encode([{'message': message, 'traceback': tb}])
|
|
1308
1323
|
finally:
|
|
1309
1324
|
if self.metric_limiter:
|
|
1310
1325
|
if is_affirmative(self.debug_metrics.get('metric_contexts', False)):
|
|
@@ -1454,3 +1469,28 @@ class AgentCheck(object):
|
|
|
1454
1469
|
|
|
1455
1470
|
for m in metrics:
|
|
1456
1471
|
self.gauge(m.name, m.value, tags=tags, raw=True)
|
|
1472
|
+
|
|
1473
|
+
@staticmethod
|
|
1474
|
+
def load_config(yaml_str: str) -> Any:
|
|
1475
|
+
"""
|
|
1476
|
+
Convenience wrapper to ease programmatic use of this class from the C API.
|
|
1477
|
+
"""
|
|
1478
|
+
import subprocess
|
|
1479
|
+
import sys
|
|
1480
|
+
|
|
1481
|
+
process = subprocess.Popen(
|
|
1482
|
+
[sys.executable, '-c', 'import sys, yaml; print(yaml.safe_load(sys.stdin.read()))'],
|
|
1483
|
+
stdin=subprocess.PIPE,
|
|
1484
|
+
stdout=subprocess.PIPE,
|
|
1485
|
+
stderr=subprocess.PIPE,
|
|
1486
|
+
)
|
|
1487
|
+
stdout, stderr = process.communicate(yaml_str.encode())
|
|
1488
|
+
if process.returncode != 0:
|
|
1489
|
+
raise ValueError(f'Failed to load config: {stderr.decode()}')
|
|
1490
|
+
|
|
1491
|
+
decoded = stdout.strip().decode()
|
|
1492
|
+
try:
|
|
1493
|
+
return eval(decoded)
|
|
1494
|
+
# a single, literal unquoted string
|
|
1495
|
+
except Exception:
|
|
1496
|
+
return decoded
|
|
@@ -1,9 +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
|
+
import lazy_loader
|
|
4
5
|
|
|
5
|
-
|
|
6
|
-
from .mixins import KubeLeaderElectionMixin
|
|
7
|
-
from .record import ElectionRecordAnnotation, ElectionRecordLease
|
|
8
|
-
|
|
9
|
-
__all__ = ['KubeLeaderElectionMixin', 'ElectionRecordAnnotation', 'ElectionRecordLease', 'KubeLeaderElectionBaseCheck']
|
|
6
|
+
__getattr__, __dir__, __all__ = lazy_loader.attach_stub(__name__, __file__)
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
# (C) Datadog, Inc. 2025-present
|
|
2
|
+
# All rights reserved
|
|
3
|
+
# Licensed under a 3-clause BSD style license (see LICENSE)
|
|
4
|
+
from .base_check import KubeLeaderElectionBaseCheck
|
|
5
|
+
from .mixins import KubeLeaderElectionMixin
|
|
6
|
+
from .record import ElectionRecordAnnotation, ElectionRecordLease
|
|
7
|
+
|
|
8
|
+
__all__ = ['ElectionRecordAnnotation', 'ElectionRecordLease', 'KubeLeaderElectionBaseCheck', 'KubeLeaderElectionMixin']
|
|
@@ -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
|
+
import lazy_loader
|
|
4
5
|
|
|
5
|
-
|
|
6
|
-
from .base_check import OpenMetricsBaseCheck
|
|
7
|
-
|
|
8
|
-
__all__ = ['OpenMetricsBaseCheck']
|
|
6
|
+
__getattr__, __dir__, __all__ = lazy_loader.attach_stub(__name__, __file__)
|
|
@@ -50,7 +50,6 @@ class OpenMetricsScraper:
|
|
|
50
50
|
"""
|
|
51
51
|
The base class for any scraper overrides.
|
|
52
52
|
"""
|
|
53
|
-
|
|
54
53
|
self.config = config
|
|
55
54
|
|
|
56
55
|
# Save a reference to the check instance
|
|
@@ -393,7 +392,6 @@ class OpenMetricsScraper:
|
|
|
393
392
|
"""
|
|
394
393
|
Yield the connection line.
|
|
395
394
|
"""
|
|
396
|
-
|
|
397
395
|
try:
|
|
398
396
|
with self.get_connection() as connection:
|
|
399
397
|
# Media type will be used to select parser dynamically
|
|
@@ -1,13 +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
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
from .histogram import get_histogram
|
|
8
|
-
from .metadata import get_metadata
|
|
9
|
-
from .rate import get_rate
|
|
10
|
-
from .service_check import get_service_check
|
|
11
|
-
from .summary import get_summary
|
|
12
|
-
from .temporal_percent import get_temporal_percent
|
|
13
|
-
from .time_elapsed import get_time_elapsed
|
|
4
|
+
import lazy_loader
|
|
5
|
+
|
|
6
|
+
__getattr__, __dir__, __all__ = lazy_loader.attach_stub(__name__, __file__)
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# (C) Datadog, Inc. 2025-present
|
|
2
|
+
# All rights reserved
|
|
3
|
+
# Licensed under a 3-clause BSD style license (see LICENSE)
|
|
4
|
+
from .counter import get_counter
|
|
5
|
+
from .counter_gauge import get_counter_gauge
|
|
6
|
+
from .gauge import get_gauge
|
|
7
|
+
from .histogram import get_histogram
|
|
8
|
+
from .metadata import get_metadata
|
|
9
|
+
from .rate import get_rate
|
|
10
|
+
from .service_check import get_service_check
|
|
11
|
+
from .summary import get_summary
|
|
12
|
+
from .temporal_percent import get_temporal_percent
|
|
13
|
+
from .time_elapsed import get_time_elapsed
|
|
14
|
+
|
|
15
|
+
__all__ = [
|
|
16
|
+
'get_counter',
|
|
17
|
+
'get_counter_gauge',
|
|
18
|
+
'get_gauge',
|
|
19
|
+
'get_histogram',
|
|
20
|
+
'get_metadata',
|
|
21
|
+
'get_rate',
|
|
22
|
+
'get_service_check',
|
|
23
|
+
'get_summary',
|
|
24
|
+
'get_temporal_percent',
|
|
25
|
+
'get_time_elapsed',
|
|
26
|
+
]
|
|
@@ -1,9 +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
|
+
import lazy_loader
|
|
4
5
|
|
|
5
|
-
|
|
6
|
-
from .mixins import PrometheusFormat, UnknownFormatError
|
|
7
|
-
from .prometheus_base import PrometheusCheck
|
|
8
|
-
|
|
9
|
-
__all__ = ['PrometheusFormat', 'UnknownFormatError', 'PrometheusCheck', 'GenericPrometheusCheck', 'PrometheusScraper']
|
|
6
|
+
__getattr__, __dir__, __all__ = lazy_loader.attach_stub(__name__, __file__)
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
# (C) Datadog, Inc. 2025-present
|
|
2
|
+
# All rights reserved
|
|
3
|
+
# Licensed under a 3-clause BSD style license (see LICENSE)
|
|
4
|
+
from .base_check import GenericPrometheusCheck, PrometheusScraper
|
|
5
|
+
from .mixins import PrometheusFormat, UnknownFormatError
|
|
6
|
+
from .prometheus_base import PrometheusCheck
|
|
7
|
+
|
|
8
|
+
__all__ = ['GenericPrometheusCheck', 'PrometheusCheck', 'PrometheusFormat', 'PrometheusScraper', 'UnknownFormatError']
|
|
@@ -569,7 +569,7 @@ class PrometheusScraperMixin(object):
|
|
|
569
569
|
and not handler.ignore_tls_warning
|
|
570
570
|
and not is_affirmative(handler.options.get('ssl_verify', True))
|
|
571
571
|
):
|
|
572
|
-
self.log.
|
|
572
|
+
self.log.debug(u'An unverified HTTPS request is being made to %s', endpoint)
|
|
573
573
|
|
|
574
574
|
try:
|
|
575
575
|
response = handler.get(endpoint, extra_headers=headers, stream=False)
|
|
@@ -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
|
+
import lazy_loader
|
|
4
5
|
|
|
5
|
-
|
|
6
|
-
from .winpdh_base import PDHBaseCheck
|
|
7
|
-
|
|
8
|
-
__all__ = ['PDHBaseCheck', 'WinPDHCounter']
|
|
6
|
+
__getattr__, __dir__, __all__ = lazy_loader.attach_stub(__name__, __file__)
|