Module org.elasticsearch.security
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.
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 Summary
ConstructorsConstructorDescriptionSecurityMetrics(SecurityMetricType metricType, MeterRegistry meterRegistry, SecurityMetricAttributesBuilder<C> attributesBuilder, LongSupplier nanoTimeSupplier) -
Method Summary
Modifier and TypeMethodDescriptionvoidrecordFailure(C context) Records a single failed execution.voidrecordSuccess(C context) Records a single success execution.voidrecordTime(C context, long startTimeNano) Records the elapsed execution time in milliseconds.longReturns a value of nanoseconds that may be used for relative time calculations.type()
-
Constructor Details
-
SecurityMetrics
public SecurityMetrics(SecurityMetricType metricType, MeterRegistry meterRegistry, SecurityMetricAttributesBuilder<C> attributesBuilder, LongSupplier nanoTimeSupplier)
-
-
Method Details
-
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
Records a single success execution.- Parameters:
context- The context object which is used to attach additional attributes to success metric.
-
recordFailure
Records a single failed execution.- Parameters:
context- The context object which is used to attach additional attributes to failed metric.
-
recordTime
Records the elapsed execution time in milliseconds. The start time is captured in nanoseconds (viarelativeTimeInNanos()) 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.
-