55import logging
66import numbers
77import os
8- from typing import Any , Callable , Dict , Optional , Sequence , Union , cast , overload
8+ from typing import Any , Callable , Dict , List , Optional , Sequence , Union , cast , overload
99
1010from ..shared import constants
1111from ..shared .functions import resolve_env_var_choice , resolve_truthy_env_var_choice
@@ -758,7 +758,7 @@ def _patch_xray_provider(self):
758758 # Due to Lazy Import, we need to activate `core` attrib via import
759759 # we also need to include `patch`, `patch_all` methods
760760 # to ensure patch calls are done via the provider
761- from aws_xray_sdk .core import xray_recorder
761+ from aws_xray_sdk .core import xray_recorder # type: ignore
762762
763763 provider = xray_recorder
764764 provider .patch = aws_xray_sdk .core .patch
@@ -778,3 +778,27 @@ def _disable_xray_trace_batching(self):
778778
779779 def _is_xray_provider (self ):
780780 return "aws_xray_sdk" in self .provider .__module__
781+
782+ def ignore_endpoint (self , hostname : Optional [str ] = None , urls : Optional [List [str ]] = None ):
783+ """If you want to ignore certain httplib requests you can do so based on the hostname or URL that is being
784+ requested.
785+
786+ > NOTE: If the provider is not xray, nothing will be added to ignore list
787+
788+ Documentation
789+ --------------
790+ - https://github.com/aws/aws-xray-sdk-python#ignoring-httplib-requests
791+
792+ Parameters
793+ ----------
794+ hostname : Optional, str
795+ The hostname is matched using the Python fnmatch library which does Unix glob style matching.
796+ urls: Optional, List[str]
797+ List of urls to ignore. Example `tracer.ignore_endpoint(urls=["/ignored-url"])`
798+ """
799+ if not self ._is_xray_provider ():
800+ return
801+
802+ from aws_xray_sdk .ext .httplib import add_ignored # type: ignore
803+
804+ add_ignored (hostname = hostname , urls = urls )
0 commit comments