Package io.smallrye.metrics
Class SharedMetricRegistries
- java.lang.Object
-
- io.smallrye.metrics.SharedMetricRegistries
-
public class SharedMetricRegistries extends Object
SharedMetricRegistries is used to create/retrieve a MicroProfile Metric's MetricRegistry instance of a provided scope. For each "scope" there exists an individual MicroProfile Metric MetricRegistry which is associated to an "underlying" Micrometer Prometheus MeterRegistry. Each of these Prometheus Meter Registries are registered under the default Micrometer global composite meter registry. With this implementation any creation/retrieval is negotiated with the global composite meter registry. To ensure that the different "scoped" MetricRegistry to MeterRegistry contain their own appropriate metrics/meters a Meter Filter is provided to each Prometheus MeterRegistry. This filter makes use of aThreadLocal<Boolean>to ensure that appropriate metrics/meters are registered/retrieved from the appropriate registry. TheThreadLocal<Boolean>will be set to false to gate registration/retrieval. And it will be set to true before interacting with the global registry. AMap<String, ThreadLocal<Boolean>>holds a mapping between the scope and ThreadLocal. This map is interrogated when the MP MetricRegistry shim interacts with the global registry.
-
-
Field Summary
Fields Modifier and Type Field Description protected static StringGLOBAL_TAG_MALFORMED_EXCEPTIONprotected static StringGLOBAL_TAGS_VARIABLEprotected static io.micrometer.core.instrument.Tag[]SERVER_LEVEL_MPCONFIG_GLOBAL_TAGSThis static Tag[] represents the server level global tags retrieved from MP Config for mp.metrics.tags.
-
Constructor Summary
Constructors Constructor Description SharedMetricRegistries()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static booleandoesScopeExist(String scope)Returns true/false if registry with this scope existsstatic voiddrop(String scope)Drops a particular registry.static voiddropAll()Drops all registries.static org.eclipse.microprofile.metrics.MetricRegistrygetOrCreate(String scope)static org.eclipse.microprofile.metrics.MetricRegistrygetOrCreate(String scope, ApplicationNameResolver appNameResolver)static ThreadLocal<Boolean>getThreadLocal(String scope)
-
-
-
Field Detail
-
GLOBAL_TAG_MALFORMED_EXCEPTION
protected static final String GLOBAL_TAG_MALFORMED_EXCEPTION
- See Also:
- Constant Field Values
-
GLOBAL_TAGS_VARIABLE
protected static final String GLOBAL_TAGS_VARIABLE
- See Also:
- Constant Field Values
-
SERVER_LEVEL_MPCONFIG_GLOBAL_TAGS
protected static io.micrometer.core.instrument.Tag[] SERVER_LEVEL_MPCONFIG_GLOBAL_TAGS
This static Tag[] represents the server level global tags retrieved from MP Config for mp.metrics.tags. This value will be 'null' when not initialized. If during initialization and no global tag has been resolved this will be to an array of size 0. Using an array of size 0 is to represent that an attempt on start up was made to resolve the value, but none was found. This prevents later instantiations of MetricRegistry to avoid attempting to resolve the MP Config value for the slight performance boon. This server level value will not change at all throughout the life time of the server as it is defined by env vars or sys props.
-
-
Method Detail
-
getOrCreate
public static org.eclipse.microprofile.metrics.MetricRegistry getOrCreate(String scope)
-
getOrCreate
public static org.eclipse.microprofile.metrics.MetricRegistry getOrCreate(String scope, ApplicationNameResolver appNameResolver)
-
getThreadLocal
public static ThreadLocal<Boolean> getThreadLocal(String scope)
-
drop
public static void drop(String scope)
Drops a particular registry. If a reference to the same registry type is requested later, a new empty registry will be created for that purpose.- Parameters:
scope- The scope of registry that should be dropped.
-
dropAll
public static void dropAll()
Drops all registries. If a reference to a registry is requested later, a new empty registry will be created for that purpose.
-
doesScopeExist
public static boolean doesScopeExist(String scope)
Returns true/false if registry with this scope exists- Parameters:
scope- name of scope- Returns:
- true/false if registry with this scope exists
-
-