Class SecurityMetrics<C>

java.lang.Object
org.elasticsearch.xpack.security.metric.SecurityMetrics<C>
Type Parameters:
C - The type of context object which is used to attach additional attributes to collected metrics.

public final class SecurityMetrics<C> extends Object
This class provides a common way for registering and collecting different types of security metrics. It allows for recoding the number of successful and failed executions as well as to record the execution time.
  • Constructor Details

  • Method Details

    • type

      public SecurityMetricType type()
    • relativeTimeInNanos

      public long relativeTimeInNanos()
      Returns a value of nanoseconds that may be used for relative time calculations. This method should only be used for calculating time deltas.
    • recordSuccess

      public void recordSuccess(C context)
      Records a single success execution.
      Parameters:
      context - The context object which is used to attach additional attributes to success metric.
    • recordFailure

      public void recordFailure(C context, String failureReason)
      Records a single failed execution.
      Parameters:
      context - The context object which is used to attach additional attributes to failed metric.
      failureReason - The optional failure reason which is stored as an attributed with recorded failure metric.
    • recordTime

      public void recordTime(C context, long startTimeNano)
      Records a time in nanoseconds. This method should be called after the execution with provided start time. The relativeTimeInNanos() should be used to record the start time.
      Parameters:
      context - The context object which is used to attach additional attributes to collected metric.
      startTimeNano - The start time (in nanoseconds) before the execution.