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)
End the current active segment.

        :param int end_time: epoch in seconds. If not specified the current
            system time will be used.