8
8
from urllib .parse import urlencode
9
9
10
10
import requests
11
- from aws_xray_sdk .core import patch
12
11
from botocore .client import BaseClient
13
12
14
13
from localstack import config
@@ -472,9 +471,6 @@ def send_event(self, event):
472
471
):
473
472
entries [0 ]["TraceHeader" ] = encoded_original_id
474
473
475
- # Patch the boto3 client to automatically include X-Ray trace headers
476
- patch (["botocore" ])
477
-
478
474
self .client .put_events (Entries = entries )
479
475
480
476
def _get_source (self , event : FormattedEvent | TransformedEvent ) -> str :
@@ -549,8 +545,7 @@ def send_event(self, event):
549
545
class FirehoseTargetSender (TargetSender ):
550
546
def send_event (self , event ):
551
547
delivery_stream_name = firehose_name (self .target ["Arn" ])
552
- # Patch the boto3 client to automatically include X-Ray trace headers
553
- patch (["botocore" ])
548
+
554
549
self .client .put_record (
555
550
DeliveryStreamName = delivery_stream_name ,
556
551
Record = {"Data" : to_bytes (to_json_str (event ))},
@@ -566,8 +561,7 @@ def send_event(self, event):
566
561
)
567
562
stream_name = self .target ["Arn" ].split ("/" )[- 1 ]
568
563
partition_key = collections .get_safe (event , partition_key_path , event ["id" ])
569
- # Patch the boto3 client to automatically include X-Ray trace headers
570
- patch (["botocore" ])
564
+
571
565
self .client .put_record (
572
566
StreamName = stream_name ,
573
567
Data = to_bytes (to_json_str (event )),
@@ -585,8 +579,6 @@ def _validate_input(self, target: Target):
585
579
586
580
class LambdaTargetSender (TargetSender ):
587
581
def send_event (self , event ):
588
- # Patch the boto3 client to automatically include X-Ray trace headers
589
- patch (["botocore" ])
590
582
self .client .invoke (
591
583
FunctionName = self .target ["Arn" ],
592
584
Payload = to_bytes (to_json_str (event )),
@@ -598,8 +590,7 @@ class LogsTargetSender(TargetSender):
598
590
def send_event (self , event ):
599
591
log_group_name = self .target ["Arn" ].split (":" )[6 ]
600
592
log_stream_name = str (uuid .uuid4 ()) # Unique log stream name
601
- # Patch the boto3 client to automatically include X-Ray trace headers
602
- patch (["botocore" ])
593
+
603
594
self .client .create_log_stream (logGroupName = log_group_name , logStreamName = log_stream_name )
604
595
self .client .put_log_events (
605
596
logGroupName = log_group_name ,
@@ -631,8 +622,6 @@ def send_event(self, event):
631
622
632
623
class SnsTargetSender (TargetSender ):
633
624
def send_event (self , event ):
634
- # Patch the boto3 client to automatically include X-Ray trace headers
635
- patch (["botocore" ])
636
625
self .client .publish (TopicArn = self .target ["Arn" ], Message = to_json_str (event ))
637
626
638
627
@@ -641,8 +630,7 @@ def send_event(self, event):
641
630
queue_url = sqs_queue_url_for_arn (self .target ["Arn" ])
642
631
msg_group_id = self .target .get ("SqsParameters" , {}).get ("MessageGroupId" , None )
643
632
kwargs = {"MessageGroupId" : msg_group_id } if msg_group_id else {}
644
- # Patch the boto3 client to automatically include X-Ray trace headers
645
- patch (["botocore" ])
633
+
646
634
self .client .send_message (
647
635
QueueUrl = queue_url ,
648
636
MessageBody = to_json_str (event ),
@@ -655,8 +643,7 @@ class StatesTargetSender(TargetSender):
655
643
656
644
def send_event (self , event ):
657
645
self .service = "stepfunctions"
658
- # Patch the boto3 client to automatically include X-Ray trace headers
659
- patch (["botocore" ])
646
+
660
647
self .client .start_execution (
661
648
stateMachineArn = self .target ["Arn" ], name = event ["id" ], input = to_json_str (event )
662
649
)
0 commit comments