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

Fix warnings usage related to RequestsWrapper, Openmetrics and Prometheus #5080

Merged
merged 11 commits into from
Nov 27, 2019
15 changes: 4 additions & 11 deletions datadog_checks_base/datadog_checks/base/utils/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
# Licensed under a 3-clause BSD style license (see LICENSE)
import logging
import os
import threading
import warnings
from contextlib import contextmanager

Expand Down Expand Up @@ -94,10 +93,6 @@ class RequestsWrapper(object):
'request_hooks',
)

# For modifying the warnings filter since the context
# manager that is provided changes module constants
warning_lock = threading.Lock()

def __init__(self, instance, init_config, remapper=None, logger=None):
self.logger = logger or LOGGER
default_fields = dict(STANDARD_FIELDS)
Expand Down Expand Up @@ -339,13 +334,11 @@ def populate_options(self, options):

@contextmanager
def handle_tls_warning(self):
with self.warning_lock:

with warnings.catch_warnings():
if self.ignore_tls_warning:
warnings.simplefilter('ignore', InsecureRequestWarning)
with warnings.catch_warnings():
if self.ignore_tls_warning:
warnings.simplefilter('ignore', InsecureRequestWarning)

yield
yield

@property
def session(self):
Expand Down