in skywalking/profile/profile_service.py [0:0]
def _check_profile_task(self, task: ProfileTask) -> Tuple[bool, str]:
try:
# endpoint name
if len(task.first_span_op_name) == 0:
return (False, f'endpoint name [{task.first_span_op_name}] error, '
f'should be str and not empty')
# duration
if task.duration < ProfileConstants.TASK_DURATION_MIN_MINUTE:
return (False, f'monitor duration must be greater '
f'than {ProfileConstants.TASK_DURATION_MIN_MINUTE} minutes')
if task.duration > ProfileConstants.TASK_DURATION_MAX_MINUTE:
return (False, f'monitor duration must be less '
f'than {ProfileConstants.TASK_DURATION_MAX_MINUTE} minutes')
# min duration threshold
if task.min_duration_threshold < 0:
return False, 'min duration threshold must be greater than or equals zero'
# dump period
if task.thread_dump_period < ProfileConstants.TASK_DUMP_PERIOD_MIN_MILLIS:
return (False,
f'dump period must be greater than or equals to '
f'{ProfileConstants.TASK_DUMP_PERIOD_MIN_MILLIS} milliseconds')
# max sampling count
if task.max_sampling_count <= 0:
return False, 'max sampling count must be greater than zero'
if task.max_sampling_count >= ProfileConstants.TASK_MAX_SAMPLING_COUNT:
return (False, f'max sampling count must be less than '
f'{ProfileConstants.TASK_MAX_SAMPLING_COUNT}')
# check task queue
task_finish_time = self._cal_profile_task_finish_time(task)
# lock the self._profile_task_list.queue when check the item in it, avoid concurrency errors
with self._profile_task_list.mutex:
for profile_task in self._profile_task_list.queue: # type: ProfileTask
# if the end time of the task to be added is during the execution of any data, means is a error data
if task.start_time <= task_finish_time <= self._cal_profile_task_finish_time(profile_task):
return (False,
f'there already have processing task in time range, '
f'could not add a new task again. processing task '
f'monitor endpoint name: {profile_task.first_span_op_name}')
return True, ''
except TypeError:
return False, 'ProfileTask attributes have a type error'