diff --git a/datadog_checks_dev/CHANGELOG.md b/datadog_checks_dev/CHANGELOG.md index dc55aed849566..07ab9476a489e 100644 --- a/datadog_checks_dev/CHANGELOG.md +++ b/datadog_checks_dev/CHANGELOG.md @@ -2,6 +2,10 @@ ## Unreleased +***Removed***: + +* Migrate `validate http` to ddev ([#15526](https://github.com/DataDog/integrations-core/pull/15526)) + ***Fixed***: * Stop using the TOX_ENV_NAME variable ([#15528](https://github.com/DataDog/integrations-core/pull/15528)) diff --git a/datadog_checks_dev/datadog_checks/dev/tooling/commands/validate/__init__.py b/datadog_checks_dev/datadog_checks/dev/tooling/commands/validate/__init__.py index a2e13b989155f..118ddb53cf034 100644 --- a/datadog_checks_dev/datadog_checks/dev/tooling/commands/validate/__init__.py +++ b/datadog_checks_dev/datadog_checks/dev/tooling/commands/validate/__init__.py @@ -13,7 +13,6 @@ from .dashboards import dashboards from .dep import dep from .eula import eula -from .http import http from .imports import imports from .integration_style import integration_style from .jmx_metrics import jmx_metrics @@ -38,7 +37,6 @@ dashboards, dep, eula, - http, imports, integration_style, jmx_metrics, diff --git a/datadog_checks_dev/datadog_checks/dev/tooling/commands/validate/all_validations.py b/datadog_checks_dev/datadog_checks/dev/tooling/commands/validate/all_validations.py index 8574b2bac1474..0b0a1855de59c 100644 --- a/datadog_checks_dev/datadog_checks/dev/tooling/commands/validate/all_validations.py +++ b/datadog_checks_dev/datadog_checks/dev/tooling/commands/validate/all_validations.py @@ -12,7 +12,6 @@ from .dashboards import dashboards from .dep import dep from .eula import eula -from .http import http from .imports import imports from .jmx_metrics import jmx_metrics from .manifest import manifest @@ -34,7 +33,6 @@ (dep, ('core',)), (eula, ('marketplace',)), (jmx_metrics, (None,)), - (http, ('core',)), (imports, (None,)), (manifest, (None,)), (metadata, (None,)), diff --git a/datadog_checks_dev/datadog_checks/dev/tooling/commands/validate/http.py b/datadog_checks_dev/datadog_checks/dev/tooling/commands/validate/http.py deleted file mode 100644 index 5662f4335fcde..0000000000000 --- a/datadog_checks_dev/datadog_checks/dev/tooling/commands/validate/http.py +++ /dev/null @@ -1,145 +0,0 @@ -# (C) Datadog, Inc. 2020-present -# All rights reserved -# Licensed under a 3-clause BSD style license (see LICENSE) -import os -import re - -import click - -from ...testing import process_checks_option -from ...utils import complete_valid_checks, get_check_files, get_default_config_spec -from ..console import CONTEXT_SETTINGS, abort, annotate_error, echo_failure, echo_info, echo_success, echo_warning - -# Integrations that are not fully updated to http wrapper class but is owned partially by a different organization - -EXCLUDED_INTEGRATIONS = {'kubelet', 'openstack'} - -REQUEST_LIBRARY_FUNC_RE = r"requests.[get|post|head|put|patch|delete]*\(" -HTTP_WRAPPER_INIT_CONFIG_RE = r"init_config\/[http|openmetrics_legacy|openmetrics]*" -HTTP_WRAPPER_INSTANCE_RE = r"instances\/[http|openmetrics_legacy|openmetrics]*" - - -def validate_config_http(file, check): - """Determines if integration with http wrapper class - uses the http template in its spec.yaml file. - - file -- filepath of file to validate - check -- name of the check that file belongs to - """ - - if not os.path.exists(file): - return - - has_failed = False - with open(file, 'r', encoding='utf-8') as f: - read_file = f.read() - has_init_config_http = re.search(HTTP_WRAPPER_INIT_CONFIG_RE, read_file) - has_instance_http = re.search(HTTP_WRAPPER_INSTANCE_RE, read_file) - if has_init_config_http and has_instance_http: - return - - if not has_instance_http: - message = ( - f"Detected {check} is missing `instances/http` or `instances/openmetrics_legacy` template in spec.yaml" - ) - echo_failure(message) - annotate_error(file, message) - has_failed = True - - if not has_init_config_http: - message = ( - f"Detected {check} is missing `init_config/http` or `init_config/openmetrics_legacy` template in spec.yaml" - ) - echo_failure(message) - annotate_error(file, message) - has_failed = True - - return has_failed - - -def validate_use_http_wrapper_file(file, check): - """Return true if the file uses the http wrapper class. - Also outputs every instance of deprecated request library function use - - file -- filepath of file to validate - check -- name of the check - """ - file_uses_http_wrapper = False - has_failed = False - with open(file, 'r', encoding='utf-8') as f: - read_file = f.read() - found_match_arg = re.search(r"auth=|header=", read_file) - found_http = re.search(r"self.http|OpenMetricsBaseCheck", read_file) - skip_validation = re.search(r"SKIP_HTTP_VALIDATION", read_file) - if found_http and not skip_validation: - return found_http, has_failed, found_match_arg - - http_func = re.search(REQUEST_LIBRARY_FUNC_RE, read_file) - if http_func: - echo_failure( - f'Check `{check}` uses `{http_func}` in `{os.path.basename(file)}`, ' - f'please use the HTTP wrapper instead' - ) - annotate_error( - file, - "Detected use of `{}`, please use the HTTP wrapper instead".format(http_func), - ) - return False, True, None - - return file_uses_http_wrapper, has_failed, None - - -def validate_use_http_wrapper(check): - """Return true if the check uses the http wrapper class in any of its files. - If any of the check's files uses the request library, abort. - - check -- name of the check - """ - has_failed = False - check_uses_http_wrapper = False - for file in get_check_files(check, include_tests=False): - if file.endswith('.py'): - file_uses_http_wrapper, file_uses_request_lib, has_arg_warning = validate_use_http_wrapper_file(file, check) - has_failed = has_failed or file_uses_request_lib - check_uses_http_wrapper = check_uses_http_wrapper or file_uses_http_wrapper - if check_uses_http_wrapper and has_arg_warning: - # Check for headers= or auth= - echo_warning( - f"{check}: \n" - f" The HTTP wrapper contains parameter `{has_arg_warning.group().replace('=', '')}`, " - f"this configuration is handled by the wrapper automatically.\n" - f" If this a genuine usage of the parameters, " - f"please inline comment `# SKIP_HTTP_VALIDATION`" - ) - pass - - if has_failed: - abort() - return check_uses_http_wrapper - - -@click.command(context_settings=CONTEXT_SETTINGS, short_help='Validate usage of http wrapper') -@click.argument('check', shell_complete=complete_valid_checks, required=False) -def http(check): - """Validate all integrations for usage of http wrapper.""" - - has_failed = False - - checks = process_checks_option(check, source='integrations') - echo_info(f"Validating {len(checks)} integrations for usage of http wrapper...") - - for check in checks: - check_uses_http_wrapper = False - - # Validate use of http wrapper (self.http.[...]) in check's .py files - if check not in EXCLUDED_INTEGRATIONS: - check_uses_http_wrapper = validate_use_http_wrapper(check) - - # Validate use of http template in check's spec.yaml (if exists) - if check_uses_http_wrapper: - has_failed = validate_config_http(get_default_config_spec(check), check) or has_failed - - if has_failed: - abort() - - echo_success('Completed http validation!') diff --git a/ddev/CHANGELOG.md b/ddev/CHANGELOG.md index 3de75f33475c1..bb1fd57b7159f 100644 --- a/ddev/CHANGELOG.md +++ b/ddev/CHANGELOG.md @@ -2,6 +2,10 @@ ## Unreleased +***Added***: + +* Migrate `validate http` to ddev ([#15526](https://github.com/DataDog/integrations-core/pull/15526)) + ***Fixed***: * Output changelog to stdout instead of stderr on `ddev release agent changelog` ([#15548](https://github.com/DataDog/integrations-core/pull/15548)) diff --git a/ddev/pyproject.toml b/ddev/pyproject.toml index 0bea955e00e23..4922848843da1 100644 --- a/ddev/pyproject.toml +++ b/ddev/pyproject.toml @@ -104,7 +104,7 @@ unfixable = [ ] [tool.ruff.isort] -known-first-party = ["{template_config['package_name']}"] +known-first-party = ["ddev"] [tool.ruff.flake8-tidy-imports] ban-relative-imports = "all" diff --git a/ddev/src/ddev/cli/validate/__init__.py b/ddev/src/ddev/cli/validate/__init__.py index c968920c9a8a2..f904bdd3ea07a 100644 --- a/ddev/src/ddev/cli/validate/__init__.py +++ b/ddev/src/ddev/cli/validate/__init__.py @@ -10,7 +10,6 @@ from datadog_checks.dev.tooling.commands.validate.dashboards import dashboards from datadog_checks.dev.tooling.commands.validate.dep import dep from datadog_checks.dev.tooling.commands.validate.eula import eula -from datadog_checks.dev.tooling.commands.validate.http import http from datadog_checks.dev.tooling.commands.validate.imports import imports from datadog_checks.dev.tooling.commands.validate.integration_style import integration_style from datadog_checks.dev.tooling.commands.validate.jmx_metrics import jmx_metrics @@ -24,6 +23,7 @@ from datadog_checks.dev.tooling.commands.validate.typos import typos from ddev.cli.validate.ci import ci +from ddev.cli.validate.http import http from ddev.cli.validate.licenses import licenses from ddev.cli.validate.manifest import manifest from ddev.cli.validate.metadata import metadata diff --git a/ddev/src/ddev/cli/validate/http.py b/ddev/src/ddev/cli/validate/http.py new file mode 100644 index 0000000000000..a6daec6f552c5 --- /dev/null +++ b/ddev/src/ddev/cli/validate/http.py @@ -0,0 +1,159 @@ +# (C) Datadog, Inc. 2023-present +# All rights reserved +# Licensed under a 3-clause BSD style license (see LICENSE) +from __future__ import annotations + +import os +import re +from typing import TYPE_CHECKING + +import click + +if TYPE_CHECKING: + from ddev.cli.application import Application + +REQUEST_LIBRARY_FUNC_RE = r'requests.[get|post|head|put|patch|delete]*\(' +HTTP_WRAPPER_INIT_CONFIG_RE = r'init_config\/[http|openmetrics_legacy|openmetrics]*' +HTTP_WRAPPER_INSTANCE_RE = r'instances\/[http|openmetrics_legacy|openmetrics]*' + + +def validate_config_http(file, check): + """Determines if integration with http wrapper class + uses the http template in its spec.yaml file. + + file -- filepath of file to validate + check -- name of the check that file belongs to + """ + error_message = [] + if not os.path.exists(file): + return + + has_failed = False + with open(file, 'r', encoding='utf-8') as f: + read_file = f.read() + has_init_config_http = re.search(HTTP_WRAPPER_INIT_CONFIG_RE, read_file) + has_instance_http = re.search(HTTP_WRAPPER_INSTANCE_RE, read_file) + + if has_init_config_http and has_instance_http: + return + + if not has_instance_http: + message = ( + f'Detected {check} is missing `instances/http` or `instances/openmetrics_legacy` template in spec.yaml' + ) + error_message.append(message) + + has_failed = True + + if not has_init_config_http: + message = ( + f'Detected {check} is missing `init_config/http` or `init_config/openmetrics_legacy` template in spec.yaml' + ) + + error_message.append(message) + has_failed = True + + return has_failed, error_message + + +def validate_use_http_wrapper_file(file, check): + """Return true if the file uses the http wrapper class. + Also outputs every instance of deprecated request library function use + + file -- filepath of file to validate + check -- name of the check + """ + file_uses_http_wrapper = False + has_failed = False + error_message = '' + with open(file, 'r', encoding='utf-8') as f: + read_file = f.read() + found_match_arg = re.search(r'auth=|header=', read_file) + found_http = re.search(r'self.http|OpenMetricsBaseCheck', read_file) + skip_validation = re.search(r'SKIP_HTTP_VALIDATION', read_file) + http_func = re.search(REQUEST_LIBRARY_FUNC_RE, read_file) + if http_func and not skip_validation: + error_message += ( + f'Check `{check}` uses `{http_func.group(0)}` in `{os.path.basename(file)}`, ' + f'please use the HTTP wrapper instead\n' + f'If this a genuine usage of the parameters, ' + f'please inline comment `# SKIP_HTTP_VALIDATION`' + ) + return False, True, None, error_message + if found_http and not skip_validation: + return found_http, has_failed, found_match_arg, error_message + + return file_uses_http_wrapper, has_failed, None, error_message + + +def validate_use_http_wrapper(check, app): + """Return true if the check uses the http wrapper class in any of its files. + If any of the check's files uses the request library, abort. + + check -- name of the check + """ + has_failed = False + check_uses_http_wrapper = False + warning_message = '' + error_message = '' + for file in app.repo.integrations.get(check).package_files(): + file_str = str(file) + if file_str.endswith('.py'): + file_uses_http_wrapper, file_uses_request_lib, has_arg_warning, error = validate_use_http_wrapper_file( + file_str, check + ) + has_failed = has_failed or file_uses_request_lib + error_message += error + check_uses_http_wrapper = check_uses_http_wrapper or file_uses_http_wrapper + if check_uses_http_wrapper and has_arg_warning: + # Check for headers= or auth= + warning_message += ( + f'The HTTP wrapper contains parameter `{has_arg_warning.group().replace("=", "")}`, ' + f'this configuration is handled by the wrapper automatically.\n' + f'If this a genuine usage of the parameters, ' + f'please inline comment `# SKIP_HTTP_VALIDATION`' + ) + pass + + if has_failed: + return check_uses_http_wrapper, warning_message, error_message + return check_uses_http_wrapper, warning_message, error_message + + +@click.command(short_help='Validate HTTP usage') +@click.argument('integrations', nargs=-1) +@click.pass_obj +def http(app: Application, integrations: tuple[str, ...]): + """Validate all integrations for usage of HTTP wrapper. + + If `integrations` is specified, only those will be validated, + an 'all' `check` value will validate all checks. + """ + validation_tracker = app.create_validation_tracker('HTTP wrapper validation') + + excluded = set(app.repo.config.get('/overrides/validate/http/exclude', [])) + for integration in app.repo.integrations.iter(integrations): + if integration.name in excluded or not integration.is_integration: + continue + + check_uses_http_wrapper, warning_message, error_message = validate_use_http_wrapper(integration.name, app) + + if warning_message: + validation_tracker.warning((integration.display_name,), message=warning_message) + if error_message: + validation_tracker.error((integration.display_name,), message=error_message) + # Validate use of http template in check's spec.yaml (if exists) + if check_uses_http_wrapper: + validate_config_result = validate_config_http(str(integration.config_spec), integration.name) + if validate_config_result: + _, config_http_msg = validate_config_result + validation_tracker.error((integration.display_name,), message='\n'.join(config_http_msg)) + else: + validation_tracker.success() + else: + if not error_message: + validation_tracker.success() + + validation_tracker.display() + if validation_tracker.errors: + app.abort() diff --git a/ddev/src/ddev/integration/core.py b/ddev/src/ddev/integration/core.py index 766efa7ec17b0..8eca1d899c437 100644 --- a/ddev/src/ddev/integration/core.py +++ b/ddev/src/ddev/integration/core.py @@ -104,6 +104,11 @@ def metrics_file(self) -> Path: relative_path = self.manifest.get('/assets/integration/metrics/metadata_path', 'metadata.csv') return self.path / relative_path + @cached_property + def config_spec(self) -> Path: + relative_path = self.manifest.get('/assets/integration/configuration/spec', 'assets/configuration/spec.yaml') + return self.path / relative_path + @cached_property def is_valid(self) -> bool: return self.is_integration or self.is_package diff --git a/ddev/tests/cli/release/agent/test_changelog.py b/ddev/tests/cli/release/agent/test_changelog.py index 79118d131ec15..c0206845fd13f 100644 --- a/ddev/tests/cli/release/agent/test_changelog.py +++ b/ddev/tests/cli/release/agent/test_changelog.py @@ -4,6 +4,7 @@ import re import pytest + from ddev.repo.core import Repository diff --git a/ddev/tests/cli/status/test_status.py b/ddev/tests/cli/status/test_status.py index c9e157db5d0c6..50faae80960b0 100644 --- a/ddev/tests/cli/status/test_status.py +++ b/ddev/tests/cli/status/test_status.py @@ -2,6 +2,7 @@ # All rights reserved # Licensed under a 3-clause BSD style license (see LICENSE) import pytest + from ddev.config.constants import AppEnvVars from ddev.utils.structures import EnvVars diff --git a/ddev/tests/cli/validate/test_http.py b/ddev/tests/cli/validate/test_http.py new file mode 100644 index 0000000000000..d518db74a13ca --- /dev/null +++ b/ddev/tests/cli/validate/test_http.py @@ -0,0 +1,139 @@ +# (C) Datadog, Inc. 2023-present +# All rights reserved +# Licensed under a 3-clause BSD style license (see LICENSE) +import pytest + +from ddev.utils.structures import EnvVars + + +@pytest.fixture(scope='module', autouse=True) +def terminal_width(): + with EnvVars({'COLUMNS': '200'}): + yield + + +def test_warn_headers_auth(ddev, repository, helpers): + check = 'apache' + file_path = repository.path / check / 'datadog_checks' / check / 'apache.py' + with file_path.open(encoding='utf-8') as file: + file_contents = file.readlines() + + file_contents[16] = " auth='test'" + + with file_path.open(mode='w', encoding='utf-8') as file: + file.writelines(file_contents) + + result = ddev('validate', 'http', check) + + assert result.exit_code == 0, result.output + assert helpers.remove_trailing_spaces(result.output) == helpers.dedent( + """ + HTTP wrapper validation + └── Apache + + The HTTP wrapper contains parameter `auth`, this configuration is handled by the wrapper automatically. + If this a genuine usage of the parameters, please inline comment `# SKIP_HTTP_VALIDATION` + + Passed: 1 + Warnings: 1 + """ + ) + + +def test_uses_requests(ddev, repository, helpers): + check = 'apache' + file_path = repository.path / check / 'datadog_checks' / check / 'apache.py' + with file_path.open(encoding='utf-8') as file: + file_contents = file.readlines() + + file_contents[16] = " test=requests.get()" + + with file_path.open(mode='w', encoding='utf-8') as file: + file.writelines(file_contents) + + result = ddev('validate', 'http', check) + + assert result.exit_code == 1, result.output + assert helpers.remove_trailing_spaces(result.output) == helpers.dedent( + """ + HTTP wrapper validation + └── Apache + + Check `apache` uses `requests.get(` in `apache.py`, please use the HTTP wrapper instead + If this a genuine usage of the parameters, please inline comment `# SKIP_HTTP_VALIDATION` + + Errors: 1 + """ + ) + + +def test_spec_missing_init_config(ddev, repository, helpers): + import yaml + + check = 'apache' + + spec_yaml = repository.path / check / 'assets' / 'configuration' / 'spec.yaml' + with spec_yaml.open(encoding='utf-8') as file: + spec_info = yaml.safe_load(file) + + spec_info['files'][0]['options'][0]['options'] = [] + + output = yaml.safe_dump(spec_info, default_flow_style=False, sort_keys=False) + with spec_yaml.open(mode='w', encoding='utf-8') as file: + file.write(output) + + result = ddev('validate', 'http', check) + + assert result.exit_code == 1, result.output + assert helpers.remove_trailing_spaces(result.output) == helpers.dedent( + """ + HTTP wrapper validation + └── Apache + + Detected apache is missing `init_config/http` or `init_config/openmetrics_legacy` template in spec.yaml + + Errors: 1 + """ + ) + + +def test_spec_missing_instance(ddev, repository, helpers): + import yaml + + check = 'apache' + + spec_yaml = repository.path / check / 'assets' / 'configuration' / 'spec.yaml' + with spec_yaml.open(encoding='utf-8') as file: + spec_info = yaml.safe_load(file) + + spec_info['files'][0]['options'][1]['options'] = spec_info['files'][0]['options'][1]['options'][0] + + output = yaml.safe_dump(spec_info, default_flow_style=False, sort_keys=False) + with spec_yaml.open(mode='w', encoding='utf-8') as file: + file.write(output) + + result = ddev('validate', 'http', check) + + assert result.exit_code == 1, result.output + assert helpers.remove_trailing_spaces(result.output) == helpers.dedent( + """ + HTTP wrapper validation + └── Apache + + Detected apache is missing `instances/http` or `instances/openmetrics_legacy` template in spec.yaml + + Errors: 1 + """ + ) + + +def test_validate_http_success(ddev, repository, helpers): + result = ddev('validate', 'http', 'apache', 'arangodb', 'zk') + assert result.exit_code == 0, result.output + assert helpers.remove_trailing_spaces(result.output) == helpers.dedent( + """ + HTTP wrapper validation + + Passed: 3 + """ + ) diff --git a/ddev/tests/cli/validate/test_licenses.py b/ddev/tests/cli/validate/test_licenses.py index 963d8025c64e5..5a0ea053d3251 100644 --- a/ddev/tests/cli/validate/test_licenses.py +++ b/ddev/tests/cli/validate/test_licenses.py @@ -6,6 +6,7 @@ import os import pytest + from ddev.utils.toml import dump_toml_data, load_toml_file diff --git a/ddev/tests/cli/validate/test_manifest.py b/ddev/tests/cli/validate/test_manifest.py index 21986ffb21313..b0a107a97a45d 100644 --- a/ddev/tests/cli/validate/test_manifest.py +++ b/ddev/tests/cli/validate/test_manifest.py @@ -4,6 +4,7 @@ import json import pytest + from ddev.utils.structures import EnvVars diff --git a/ddev/tests/config/test_model.py b/ddev/tests/config/test_model.py index d423fc20a6caf..44e31e3803284 100644 --- a/ddev/tests/config/test_model.py +++ b/ddev/tests/config/test_model.py @@ -4,6 +4,7 @@ import os import pytest + from ddev.config.model import ConfigurationError, RootConfig, get_github_token, get_github_user diff --git a/ddev/tests/conftest.py b/ddev/tests/conftest.py index d943121f5a1a1..91ed9df0bfb3c 100644 --- a/ddev/tests/conftest.py +++ b/ddev/tests/conftest.py @@ -12,6 +12,7 @@ import vcr from click.testing import CliRunner as __CliRunner from datadog_checks.dev.tooling.utils import set_root + from ddev.cli.terminal import Terminal from ddev.config.constants import AppEnvVars, ConfigEnvVars from ddev.config.file import ConfigFile diff --git a/ddev/tests/repo/test_core.py b/ddev/tests/repo/test_core.py index 722892675b3ff..fa546756af9e4 100644 --- a/ddev/tests/repo/test_core.py +++ b/ddev/tests/repo/test_core.py @@ -4,6 +4,7 @@ import os import pytest + from ddev.integration.core import Integration from ddev.repo.config import RepositoryConfig from ddev.repo.constants import NOT_SHIPPABLE diff --git a/ddev/tests/utils/test_platform.py b/ddev/tests/utils/test_platform.py index 62c74ecf2fd5f..ae37767355f2c 100644 --- a/ddev/tests/utils/test_platform.py +++ b/ddev/tests/utils/test_platform.py @@ -2,6 +2,7 @@ # All rights reserved # Licensed under a 3-clause BSD style license (see LICENSE) import pytest + from ddev.utils.platform import Platform diff --git a/ddev/tests/validation/test_tracker.py b/ddev/tests/validation/test_tracker.py index 2eae9338c6214..39b662769236e 100644 --- a/ddev/tests/validation/test_tracker.py +++ b/ddev/tests/validation/test_tracker.py @@ -2,11 +2,12 @@ # All rights reserved # Licensed under a 3-clause BSD style license (see LICENSE) import pytest -from ddev.validation.tracker import ValidationTracker from rich.console import Console from rich.style import Style from rich.tree import Tree +from ddev.validation.tracker import ValidationTracker + def get_tracker(): return ValidationTracker( diff --git a/kube_apiserver_metrics/datadog_checks/kube_apiserver_metrics/kube_apiserver_metrics.py b/kube_apiserver_metrics/datadog_checks/kube_apiserver_metrics/kube_apiserver_metrics.py index b5e1fcfa7bb67..a19577c9d2e50 100644 --- a/kube_apiserver_metrics/datadog_checks/kube_apiserver_metrics/kube_apiserver_metrics.py +++ b/kube_apiserver_metrics/datadog_checks/kube_apiserver_metrics/kube_apiserver_metrics.py @@ -193,7 +193,7 @@ def apiserver_audit_event_total(self, metric, scraper_config): def rest_client_requests_total(self, metric, scraper_config): self.submit_metric('.rest_client_requests_total', metric, scraper_config) - def http_requests_total(self, metric, scraper_config): + def http_requests_total(self, metric, scraper_config): # SKIP_HTTP_VALIDATION self.submit_metric('.http_requests_total', metric, scraper_config) def apiserver_request_count(self, metric, scraper_config): diff --git a/kubelet/datadog_checks/kubelet/cadvisor.py b/kubelet/datadog_checks/kubelet/cadvisor.py index 8e7fa1f787b22..9e7572016053a 100644 --- a/kubelet/datadog_checks/kubelet/cadvisor.py +++ b/kubelet/datadog_checks/kubelet/cadvisor.py @@ -51,7 +51,7 @@ def detect_cadvisor(kubelet_url, cadvisor_port): url = "http://{}:{}{}".format(kubelet_hostname, cadvisor_port, LEGACY_CADVISOR_METRICS_PATH) # Test the endpoint is present - r = requests.head(url, timeout=1) + r = requests.head(url, timeout=1) # SKIP_HTTP_VALIDATION r.raise_for_status() return url diff --git a/marklogic/datadog_checks/marklogic/api.py b/marklogic/datadog_checks/marklogic/api.py index f17d492e04dd2..a9fb2827d8ac7 100644 --- a/marklogic/datadog_checks/marklogic/api.py +++ b/marklogic/datadog_checks/marklogic/api.py @@ -43,7 +43,7 @@ def get_status_data(self, resource=None): return self.http_get(route, params) - def get_requests_data(self, resource=None, name=None, group=None): + def get_requests_data(self, resource=None, name=None, group=None): # SKIP_HTTP_VALIDATION # type: (str, str, str) -> Dict[str, Any] """ https://docs.marklogic.com/REST/GET/manage/v2/requests diff --git a/marklogic/datadog_checks/marklogic/check.py b/marklogic/datadog_checks/marklogic/check.py index 9d8770070b9a0..d3ce3971c7e23 100644 --- a/marklogic/datadog_checks/marklogic/check.py +++ b/marklogic/datadog_checks/marklogic/check.py @@ -178,7 +178,7 @@ def _collect_resource_storage_metrics(self, resource_type, name, group, tags): def _collect_resource_request_metrics(self, resource_type, name, group, tags): # type: (str, str, str, List[str]) -> None """Collect request metrics of a specific resource""" - data = self.api.get_requests_data(resource=resource_type, name=name, group=group) + data = self.api.get_requests_data(resource=resource_type, name=name, group=group) # SKIP_HTTP_VALIDATION metrics = parse_per_resource_request_metrics(data, tags) self.submit_metrics(metrics) diff --git a/openstack/datadog_checks/openstack/openstack.py b/openstack/datadog_checks/openstack/openstack.py index 2d2602d75b842..b7d9952e55114 100644 --- a/openstack/datadog_checks/openstack/openstack.py +++ b/openstack/datadog_checks/openstack/openstack.py @@ -144,7 +144,7 @@ def request_auth_token(cls, auth_scope, identity, keystone_server_url, ssl_verif auth_url = urljoin(keystone_server_url, "{0}/auth/tokens".format(DEFAULT_KEYSTONE_API_VERSION)) headers = {'Content-Type': 'application/json'} - resp = requests.post( + resp = requests.post( # SKIP_HTTP_VALIDATION auth_url, headers=headers, data=json.dumps(payload),