public interface InstrumentRegistry
Instrument's.
It can create new Instrument objects directly via is pull() methods. This makes it easier to manage the
creation of performance statistics.
Names of instruments MUST be unique. For example you cannot have a Counter and a Gauge with the same
name. If an Instrument exists with the a specified name and its not of the requested type, then an
IllegalStateException will be thrown.
THREAD SAFETY : ConcurrentHashMap is sued under the covers to ensure that @{link Instrument}s are created once and only once.
| Modifier and Type | Method and Description |
|---|---|
Instrument |
getInstrument(String name)
Returns an
Instrument from the registry with the specified name |
int |
getNumberOfInstruments()
Returns the number of instruments that exist.
|
RegistryConfiguration |
getRegistryConfiguration() |
AbsoluteCounter |
pullAbsoluteCounter(String name)
This is a pull through operation that guarantees to ATOMICALLY create a AbsoluteCounter under the name if its not
present OR return the previously created one if its there.
|
CacheCollector |
pullCacheCollector(String name)
This is a pull through operation that guarantees to ATOMICALLY create a
CacheCounter under the name if its not present
OR return the previously created one if its there. |
CacheCollector |
pullCacheCollector(String name,
CacheCollector.Sizer sizer)
This is a pull through operation that guarantees to ATOMICALLY create a
CacheCollector under the name if its not present
OR return the previously created one if its there. |
CacheCounter |
pullCacheCounter(String name)
This is a pull through operation that guarantees to ATOMICALLY create a
CacheCounter under the name if its not present
OR return the previously created one if its there. |
CacheCounter |
pullCacheCounter(String name,
CacheCounter.Sizer sizer)
This is a pull through operation that guarantees to ATOMICALLY create a
CacheCounter under the name if its not present
OR return the previously created one if its there. |
Counter |
pullCounter(String name)
This is a pull through operation that guarantees to ATOMICALLY create a Counter under the name if its not present
OR return the previously created one if its there.
|
DerivedCounter |
pullDerivedCounter(String name)
This is a pull through operation that guarantees to ATOMICALLY create a DerivedCounter under the name if its not
present OR return the previously created one if its there.
|
Gauge |
pullGauge(String name)
This is a pull through operation that guarantees to ATOMICALLY create a Gauge under the name if its not present
OR return the previously created one if its there.
|
OpCounter |
pullOpCounter(String name)
This is a pull through operation that guarantees to ATOMICALLY create an
OpCounter under the name if its
not present OR return the previously created one if its there. |
OpTimer |
pullTimer(String name)
This is a pull through operation that guarantees to ATOMICALLY create a OpCounter under the name if its not
present OR use the previously created one if its there.
|
Instrument |
putInstrument(Instrument instrument)
This will put an
Instrument into the registry, atomically overwriting any previous Instrument
value. |
List<Instrument> |
snapshotInstruments()
This returns a snapshot list of
Instrument objects in the InstrumentRegistry at the time the method was
called. |
RegistryConfiguration getRegistryConfiguration()
Instrument putInstrument(Instrument instrument)
Instrument into the registry, atomically overwriting any previous Instrument
value.instrument - the NON NULL instrument to addInstrument getInstrument(String name)
Instrument from the registry with the specified namename - the name of the Instrument to returnAbsoluteCounter pullAbsoluteCounter(String name)
THREAD-SAFE - Uses ConcurrentHashMap under the covers
name - the name of the DerivedCounter to pullIllegalArgumentException - if there is already a named Instrument in the registry but is not a
DerivedCounterCounter pullCounter(String name)
THREAD-SAFE - Uses ConcurrentHashMap under the covers
name - the name of the Counter to pullIllegalArgumentException - if there is already a named Instrument in the registry but is not a CounterDerivedCounter pullDerivedCounter(String name)
THREAD-SAFE - Uses ConcurrentHashMap under the covers
name - the name of the DerivedCounter to pullIllegalArgumentException - if there is already a named Instrument in the registry but is not a
DerivedCounterGauge pullGauge(String name)
THREAD-SAFE - Uses ConcurrentHashMap under the covers
name - the name of the Gauge to pullIllegalArgumentException - if there is already a named Instrument in the registry but is not a GaugeCacheCollector pullCacheCollector(String name, CacheCollector.Sizer sizer)
CacheCollector under the name if its not present
OR return the previously created one if its there.
THREAD-SAFE - Uses ConcurrentHashMap under the covers
name - the name of the CacheCounter to pullsizer - the CacheCollector.Sizer to use that can work out the size of the cacheIllegalArgumentException - if there is already a named Instrument in the registry but is not a CacheCounterCacheCollector pullCacheCollector(String name)
CacheCounter under the name if its not present
OR return the previously created one if its there.
THREAD-SAFE - Uses ConcurrentHashMap under the covers
name - the name of the CacheCounter to pullIllegalArgumentException - if there is already a named Instrument in the registry but is not a CacheCounterCacheCounter pullCacheCounter(String name, CacheCounter.Sizer sizer)
CacheCounter under the name if its not present
OR return the previously created one if its there.
THREAD-SAFE - Uses ConcurrentHashMap under the covers
name - the name of the CacheCounter to pullsizer - the CacheCounter.Sizer to use that can work out the size of the cacheIllegalArgumentException - if there is already a named Instrument in the registry but is not a CacheCounterCacheCounter pullCacheCounter(String name)
CacheCounter under the name if its not present
OR return the previously created one if its there.
THREAD-SAFE - Uses ConcurrentHashMap under the covers
name - the name of the CacheCounter to pullIllegalArgumentException - if there is already a named Instrument in the registry but is not a CacheCounterOpCounter pullOpCounter(String name)
OpCounter under the name if its
not present OR return the previously created one if its there.
THREAD-SAFE - Uses ConcurrentHashMap under the covers
name - the name of the OpCounter to pullIllegalArgumentException - if there is already a named Instrument in the registry but is not a OpCounterOpTimer pullTimer(String name)
OpTimer.end()
is called, the value of the timer will be placed inside the named OpCounter.
You code can use it something like this
OpTimer timer = registry.pullOpTimer("some.operation");
try {
..
.. do some operation
..
} finally {
opTimer.end()
// and OpCounter will now exist
OpCounter opCounter = (OpCounter) registry.getInstrument("some.operation");
}
THREAD-SAFE - Uses ConcurrentHashMap under the covers
name - the name of the OpTimer to pullIllegalArgumentException - if there is already a named Instrument in the registry but is not a OpCounterList<Instrument> snapshotInstruments()
Instrument objects in the InstrumentRegistry at the time the method was
called.
The list is MUTABLE and a copy of the underlying values. So feel free to mutate it by sorting it and filtering it.
int getNumberOfInstruments()
snapshotInstruments().size()
but more efficient.Copyright © 2016 Atlassian. All rights reserved.