Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix docstring in Entity.close() #424

Closed
roger-zhangg opened this issue Mar 25, 2024 · 1 comment
Closed

Fix docstring in Entity.close() #424

roger-zhangg opened this issue Mar 25, 2024 · 1 comment

Comments

@roger-zhangg
Copy link
Member

The problem

Wrong typehints

The docstring for end_time in the following sections seems to be wrong, it should be in float but docstring says int

def close(self, end_time=None):
"""
Close the trace entity by setting `end_time`
and flip the in progress flag to False.
:param int end_time: Epoch in seconds. If not specified
current time will be used.
"""
self._check_ended()
if end_time:
self.end_time = end_time
else:
self.end_time = time.time()
self.in_progress = False

def close(self, end_time=None):
"""
Close the trace entity by setting `end_time`
and flip the in progress flag to False. Also decrement
parent segment's ref counter by 1.
:param int end_time: Epoch in seconds. If not specified
current time will be used.
"""
super().close(end_time)
self.parent_segment.decrement_ref_counter()

def end_segment(self, end_time=None):
"""
End the current active segment.
:param int end_time: epoch in seconds. If not specified the current
system time will be used.
"""
entity = self.get_trace_entity()
if not entity:
log.warning("No segment to end")
return
if self._is_subsegment(entity):
entity.parent_segment.close(end_time)
else:
entity.close(end_time)

def end_subsegment(self, end_time=None):
"""
End the current active segment. Return False if there is no
subsegment to end.
:param int 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)
self._local.entities.pop()
return True
else:
log.warning("No subsegment to end.")
return False

Correct typehints (on top of wrong ones)

And you can find the following code calling the function above using the correct type hint float

def end_subsegment(self, end_time=None):
"""
End the current active subsegment. If this is the last one open
under its parent segment, the entire segment will be sent.
:param float end_time: subsegment compeletion in unix epoch in seconds.

def end_segment(self, end_time=None):
"""
End the current segment and send it to X-Ray daemon
if it is ready to send. Ready means segment and
all its subsegments are closed.
:param float end_time: segment completion in unix epoch in seconds.
"""

Fix

Verify this issue and Change typehint for end_time in Wrong typehints section from int to float

@srprash
Copy link
Contributor

srprash commented Apr 22, 2024

@roger-zhangg Thanks for bringing this to our attention. The docstrings have been fixed.

@srprash srprash closed this as completed Apr 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants