예제 #1
0
 void maybeScheduleUserProfiling(Transaction transaction, String user) {
   UserRecordingConfig userRecordingConfig = configService.getUserRecordingConfig();
   if (!userRecordingConfig.enabled()) {
     return;
   }
   if (!user.equalsIgnoreCase(userRecordingConfig.user())) {
     return;
   }
   // schedule the first stack collection for configured interval after transaction start (or
   // immediately, if the transaction's total time already exceeds configured collection
   // interval)
   int intervalMillis = userRecordingConfig.profileIntervalMillis();
   ScheduledRunnable userProfileRunnable = new UserProfileRunnable(transaction, configService);
   long initialDelay =
       Math.max(0, intervalMillis - NANOSECONDS.toMillis(transaction.getDurationNanos()));
   userProfileRunnable.scheduleWithFixedDelay(
       scheduledExecutor, initialDelay, intervalMillis, MILLISECONDS);
   transaction.setUserProfileRunnable(userProfileRunnable);
 }