Class MonitorProvider
- java.lang.Object
-
- org.opends.server.api.MonitorProvider
-
- All Implemented Interfaces:
MeterBinder
- Direct Known Subclasses:
EntryCache
,HealthStatusMonitorProvider
,JvmMonitorProvider
,KeyManagerProvider.CertificateMonitor
,LocalBackendMonitor
,ReplicationServerDomain
@PublicAPI(stability=VOLATILE, mayExtend=true) public abstract class MonitorProvider extends Object implements MeterBinder
This class defines the set of methods and structures that must be implemented by a Directory Server module that can provide usage, performance, availability, or other kinds of monitor information to clients.
-
-
Field Summary
Fields Modifier and Type Field Description protected MeterRegistryHolder
registry
The possibly null meter registry holder.
-
Constructor Summary
Constructors Constructor Description MonitorProvider()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract void
addMonitorObjectClassNames(Attribute objectClassAttribute)
Adds to the provided attribute the objectclass names that should be included in the monitor entry created from this monitor provider.abstract void
bindTo(MeterRegistry registry)
.protected abstract Dn
computeMonitorInstanceDn()
Returns the monitor instance DN for this monitor provider.static Dn
configurationDnToMonitorDn(Dn configDn)
Convenience method for mapping a component's configuration DN to its equivalent monitoring DN.void
deregisterAll()
Deregisters all the meters registered by this monitor provider.Entry
getMonitorEntry(Schema schema)
Generates and returns a monitor entry based on the contents of this monitor provider.Dn
getMonitorInstanceDn()
Returns the DN of this monitor provider.String
toString()
-
-
-
Field Detail
-
registry
protected MeterRegistryHolder registry
The possibly null meter registry holder. When not-null, subclasses must set this field in thebindTo(MeterRegistry)
method.
-
-
Method Detail
-
configurationDnToMonitorDn
public static Dn configurationDnToMonitorDn(Dn configDn)
Convenience method for mapping a component's configuration DN to its equivalent monitoring DN.For example, a component with the name
cn=LDAP,cn=Connection Handlers,cn=config
will be mapped tocn=LDAP,cn=Connection Handlers,cn=monitor
.- Parameters:
configDn
- The component's configuration DN.- Returns:
- The equivalent monitor DN.
-
getMonitorInstanceDn
public final Dn getMonitorInstanceDn()
Returns the DN of this monitor provider. It should be unique among all monitor providers, including all instances of the same monitor provider.- Returns:
- The DN of this monitor provider.
-
computeMonitorInstanceDn
protected abstract Dn computeMonitorInstanceDn()
Returns the monitor instance DN for this monitor provider.- Returns:
- the monitor instance DN.
-
addMonitorObjectClassNames
protected abstract void addMonitorObjectClassNames(Attribute objectClassAttribute)
Adds to the provided attribute the objectclass names that should be included in the monitor entry created from this monitor provider. This method should be implemented by child classes to make it easier to search for monitor entries of a specific type.- Parameters:
objectClassAttribute
- the objectClass attribute where to add the object class names
-
bindTo
public abstract void bindTo(MeterRegistry registry)
.Implementation considerations
Implementations MUST set the
registry
field by creating a newMeterRegistryHolder
, and specifying the appropriate prefix for the dimensional model and also the hierarchical model if they are different. This can be done using a parameter on the constructor, or theMeterRegistryHolder.hierarchicalNamePrefix(String)
method. Tags common to all metrics for this monitor provider can also be set using theMeterRegistryHolder.tag(String, String)
method.Attribute names are then registered by calling factory methods on the
registry
field.Sample dummy implementation
(Please remove the comments when using this code as a template)
public void bindTo(final MeterRegistry parent) { // create the MeterRegistryHolder wrapping OpenDJ's MeterRegistry registry = new MeterRegistryHolder("dimensional-name-prefix", parent) .tag("label", "dimension") .hierarchicalNamePrefix("hierarchical-name-prefix.dimension"); // register the metrics against the wrapper registry.numberGauge("gauge", numberSupplier); // use lambdas or method references here timer = registry.timer("requests-submitted"); // set a different name for the metric in cn=monitor, dimensional model and hierarchical model Gauge.doubleGauge(dimensionalName, supplier) .hierarchicalName(hierarchicalName) .tag(MeterRegistryHolder.TAG_ATTRIBUTE_NAME, "cn-monitor-name") // drop the "ds-mon-" prefix here .register(registry); // this gauge will only output to cn=monitor based monitoring endpoints registry.monitoringGauge("only-visible-in-cn-monitor", supplier); }
- Specified by:
bindTo
in interfaceMeterBinder
-
deregisterAll
public void deregisterAll()
Deregisters all the meters registered by this monitor provider.
-
getMonitorEntry
public Entry getMonitorEntry(Schema schema)
Generates and returns a monitor entry based on the contents of this monitor provider.- Parameters:
schema
- the schema- Returns:
- The monitor entry generated from the information of this provided monitor provider.
-
-