5
5
import logging
6
6
import numbers
7
7
import 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
9
9
10
10
from ..shared import constants
11
11
from ..shared .functions import resolve_env_var_choice , resolve_truthy_env_var_choice
@@ -758,7 +758,7 @@ def _patch_xray_provider(self):
758
758
# Due to Lazy Import, we need to activate `core` attrib via import
759
759
# we also need to include `patch`, `patch_all` methods
760
760
# 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
762
762
763
763
provider = xray_recorder
764
764
provider .patch = aws_xray_sdk .core .patch
@@ -778,3 +778,27 @@ def _disable_xray_trace_batching(self):
778
778
779
779
def _is_xray_provider (self ):
780
780
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