Пример #1
0
  public boolean shouldStoreSlow(Transaction transaction) {
    if (transaction.isPartiallyStored()) {
      return true;
    }
    // check if trace-specific store threshold was set
    long slowThresholdMillis = transaction.getSlowThresholdMillisOverride();
    if (slowThresholdMillis != Transaction.USE_GENERAL_STORE_THRESHOLD) {
      return transaction.getDurationNanos() >= MILLISECONDS.toNanos(slowThresholdMillis);
    }
    // fall back to default slow trace threshold
    slowThresholdMillis = configService.getTransactionConfig().slowThresholdMillis();
    if (transaction.getDurationNanos() >= MILLISECONDS.toNanos(slowThresholdMillis)) {
      return true;
    }

    // for now lumping user recording into slow traces tab
    //
    // check if should store for user recording
    if (configService.getUserRecordingConfig().enabled()) {
      String user = transaction.getUser();
      if (!Strings.isNullOrEmpty(user)
          && user.equalsIgnoreCase(configService.getUserRecordingConfig().user())) {
        return true;
      }
    }
    return false;
  }
Пример #2
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);
 }