@@ -34,11 +34,12 @@ def __init__(
34
34
rsession : Optional [requests .Session ] = None ,
35
35
):
36
36
37
- # Represents the region of the CloudWatch OTLP endpoint to send the traces to.
38
- # If the endpoint has been verified to be valid, this should not be None
39
-
40
37
self ._aws_region = None
41
38
39
+ # Requires botocore to be installed to sign the headers. However,
40
+ # some users might not need to use this exporter. In order not conflict
41
+ # with existing behavior, we check for botocore before initializing this exporter.
42
+
42
43
if endpoint and is_xray_otlp_endpoint (endpoint ):
43
44
44
45
if is_installed ("botocore" ):
@@ -67,7 +68,11 @@ def __init__(
67
68
session = rsession ,
68
69
)
69
70
71
+ # Overrides upstream's private implementation of _export. All behaviors are
72
+ # the same except if the endpoint is an XRay OTLP endpoint, we will sign the request
73
+ # with SigV4 in headers before sending it to the endpoint. Otherwise, we will skip signing.
70
74
def _export (self , serialized_data : bytes ):
75
+
71
76
if self ._aws_region :
72
77
request = self .boto_aws_request .AWSRequest (
73
78
method = "POST" ,
@@ -85,7 +90,7 @@ def _export(self, serialized_data: bytes):
85
90
signer .add_auth (request )
86
91
self ._session .headers .update (dict (request .headers ))
87
92
88
- except self . boto_auth . NoCredentialsError as signing_error :
93
+ except Exception as signing_error : # pylint: disable=broad-except
89
94
_logger .error ("Failed to sign request: %s" , signing_error )
90
95
91
96
else :
0 commit comments