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)
      Records a single failed execution.
      Parameters:
      context - The context object which is used to attach additional attributes to failed metric.
    • recordTime

      public void recordTime(C context, long startTimeNano)
      Records the elapsed execution time in milliseconds. The start time is captured in nanoseconds (via relativeTimeInNanos()) for precision, but the recorded value is converted to milliseconds so that it falls within the finite bucket range.
      Parameters:
      context - The context object which is used to attach additional attributes to collected metric.
      startTimeNano - The start time (in nanoseconds) before the execution.