Package org.linuxforhealth.fhir.config
Class MetricHandle
- java.lang.Object
-
- org.linuxforhealth.fhir.config.MetricHandle
-
- All Implemented Interfaces:
java.lang.AutoCloseable
public class MetricHandle extends java.lang.Object implements java.lang.AutoCloseable
Measure the time of a call and accumulate that time in the attachedCallTimeMetric
when this handle is closed.
-
-
Field Summary
Fields Modifier and Type Field Description (package private) FHIRRequestContext
context
(package private) CallTimeMetric
metric
(package private) MetricHandle
parent
(package private) long
start
-
Constructor Summary
Constructors Modifier Constructor Description protected
MetricHandle(FHIRRequestContext context, CallTimeMetric metric, MetricHandle parent)
Protected constructor for a root-level metric
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
accumulateItems(int count)
Add count to the number of items associated with this metric and also add this count to all the parents of this metricvoid
close()
CallTimeMetric
getMetric()
The shared metric value represented by this handleMetricHandle
getMetricHandle(java.lang.String name)
Convenience method to get a child MetricHandle by calling through to our parent request contextMetricHandle
getParent()
Get the parent of this handlejava.lang.String
getParentPath()
Get the full path of the parent of thisjava.lang.String
getPath()
Convenience method to get the path name of the metric we are wrapping
-
-
-
Field Detail
-
context
final FHIRRequestContext context
-
metric
final CallTimeMetric metric
-
start
final long start
-
parent
final MetricHandle parent
-
-
Constructor Detail
-
MetricHandle
protected MetricHandle(FHIRRequestContext context, CallTimeMetric metric, MetricHandle parent)
Protected constructor for a root-level metric- Parameters:
context
-metric
-parent
-
-
-
Method Detail
-
getMetric
public CallTimeMetric getMetric()
The shared metric value represented by this handle- Returns:
-
getParent
public MetricHandle getParent()
Get the parent of this handle- Returns:
-
getParentPath
public java.lang.String getParentPath()
Get the full path of the parent of this- Returns:
-
getPath
public java.lang.String getPath()
Convenience method to get the path name of the metric we are wrapping- Returns:
-
close
public void close()
- Specified by:
close
in interfacejava.lang.AutoCloseable
-
accumulateItems
public void accumulateItems(int count)
Add count to the number of items associated with this metric and also add this count to all the parents of this metric- Parameters:
count
-
-
getMetricHandle
public MetricHandle getMetricHandle(java.lang.String name)
Convenience method to get a child MetricHandle by calling through to our parent request context- Parameters:
name
-- Returns:
-
-