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, String failureReason) Records a single failed execution.voidrecordSuccess(C context) Records a single success execution.voidrecordTime(C context, long startTimeNano) Records a time in nanoseconds.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.failureReason- The optional failure reason which is stored as an attributed with recorded failure metric.
-
recordTime
Records a time in nanoseconds. This method should be called after the execution with provided start time. TherelativeTimeInNanos()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.
-