Skip to content

Commit 394dd8f

Browse files
committed
feat: remove xray sdk patch of already patched boto clients
1 parent 07f22ca commit 394dd8f

File tree

1 file changed

+5
-18
lines changed
  • localstack-core/localstack/services/events

1 file changed

+5
-18
lines changed

localstack-core/localstack/services/events/target.py

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
from urllib.parse import urlencode
99

1010
import requests
11-
from aws_xray_sdk.core import patch
1211
from botocore.client import BaseClient
1312

1413
from localstack import config
@@ -472,9 +471,6 @@ def send_event(self, event):
472471
):
473472
entries[0]["TraceHeader"] = encoded_original_id
474473

475-
# Patch the boto3 client to automatically include X-Ray trace headers
476-
patch(["botocore"])
477-
478474
self.client.put_events(Entries=entries)
479475

480476
def _get_source(self, event: FormattedEvent | TransformedEvent) -> str:
@@ -549,8 +545,7 @@ def send_event(self, event):
549545
class FirehoseTargetSender(TargetSender):
550546
def send_event(self, event):
551547
delivery_stream_name = firehose_name(self.target["Arn"])
552-
# Patch the boto3 client to automatically include X-Ray trace headers
553-
patch(["botocore"])
548+
554549
self.client.put_record(
555550
DeliveryStreamName=delivery_stream_name,
556551
Record={"Data": to_bytes(to_json_str(event))},
@@ -566,8 +561,7 @@ def send_event(self, event):
566561
)
567562
stream_name = self.target["Arn"].split("/")[-1]
568563
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+
571565
self.client.put_record(
572566
StreamName=stream_name,
573567
Data=to_bytes(to_json_str(event)),
@@ -585,8 +579,6 @@ def _validate_input(self, target: Target):
585579

586580
class LambdaTargetSender(TargetSender):
587581
def send_event(self, event):
588-
# Patch the boto3 client to automatically include X-Ray trace headers
589-
patch(["botocore"])
590582
self.client.invoke(
591583
FunctionName=self.target["Arn"],
592584
Payload=to_bytes(to_json_str(event)),
@@ -598,8 +590,7 @@ class LogsTargetSender(TargetSender):
598590
def send_event(self, event):
599591
log_group_name = self.target["Arn"].split(":")[6]
600592
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+
603594
self.client.create_log_stream(logGroupName=log_group_name, logStreamName=log_stream_name)
604595
self.client.put_log_events(
605596
logGroupName=log_group_name,
@@ -631,8 +622,6 @@ def send_event(self, event):
631622

632623
class SnsTargetSender(TargetSender):
633624
def send_event(self, event):
634-
# Patch the boto3 client to automatically include X-Ray trace headers
635-
patch(["botocore"])
636625
self.client.publish(TopicArn=self.target["Arn"], Message=to_json_str(event))
637626

638627

@@ -641,8 +630,7 @@ def send_event(self, event):
641630
queue_url = sqs_queue_url_for_arn(self.target["Arn"])
642631
msg_group_id = self.target.get("SqsParameters", {}).get("MessageGroupId", None)
643632
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+
646634
self.client.send_message(
647635
QueueUrl=queue_url,
648636
MessageBody=to_json_str(event),
@@ -655,8 +643,7 @@ class StatesTargetSender(TargetSender):
655643

656644
def send_event(self, event):
657645
self.service = "stepfunctions"
658-
# Patch the boto3 client to automatically include X-Ray trace headers
659-
patch(["botocore"])
646+
660647
self.client.start_execution(
661648
stateMachineArn=self.target["Arn"], name=event["id"], input=to_json_str(event)
662649
)

0 commit comments

Comments
 (0)