From e62f0c5c66898decf63e980d6ab647335f042d3f Mon Sep 17 00:00:00 2001 From: Mahad Janjua Date: Wed, 29 May 2024 09:26:00 -0700 Subject: [PATCH] Fix warning message condition for subsegment ending --- aws_xray_sdk/core/context.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/aws_xray_sdk/core/context.py b/aws_xray_sdk/core/context.py index 553c85a2..0a2f395e 100644 --- a/aws_xray_sdk/core/context.py +++ b/aws_xray_sdk/core/context.py @@ -78,11 +78,13 @@ def end_subsegment(self, end_time=None): :param float end_time: epoch in seconds. If not specified the current system time will be used. """ - subsegment = self.get_trace_entity() - if self._is_subsegment(subsegment): - subsegment.close(end_time) + entity = self.get_trace_entity() + if self._is_subsegment(entity): + entity.close(end_time) self._local.entities.pop() return True + elif isinstance(entity, DummySegment): + return False else: log.warning("No subsegment to end.") return False