Skip to content

Commit e501b45

Browse files
authored
Filter urllib3 messages correctly
1 parent ef8a635 commit e501b45

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

pytest_reportportal/rp_logging.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
import logging
55
from contextlib import contextmanager
66
from functools import wraps
7+
78
from six import PY2
9+
from six.moves.urllib.parse import urlparse
810

911

1012
class RPLogger(logging.getLoggerClass()):
@@ -102,21 +104,21 @@ def __init__(self, py_test_service,
102104
self.endpoint = endpoint
103105

104106
def filter(self, record):
105-
"""
106-
Filter the reportportal_client messages.
107+
"""Filter specific records to avoid sending those to RP.
107108
108-
:param record: a log record to filter
109-
:return: bool - False if it is an agent or client log and
110-
'filter_client_logs' attribute is True, other way always True
109+
:param record: A log record to be filtered
110+
:return: False if the given record does no fit for sending
111+
to RP, otherwise True.
111112
"""
112113
if not self.filter_client_logs:
113114
return True
114115
if record.name.startswith(self.ignored_record_names):
115116
return False
116-
if record.name == 'urllib3.connectionpool':
117+
if record.name.startswith('urllib3.connectionpool'):
117118
# Filter the reportportal_client requests instance
118119
# urllib3 usage
119-
if self.endpoint.rstrip('/') in self.format(record):
120+
hostname = urlparse(self.endpoint).hostname
121+
if hostname in self.format(record):
120122
return False
121123
return True
122124

0 commit comments

Comments
 (0)