Interface MeterConfigBuilder
- All Known Subinterfaces:
ProductMeterConfigBuilder
- All Known Implementing Classes:
MeterConfigBuilderImpl
MeterConfig.- Since:
- 5.0.0
-
Method Summary
Modifier and TypeMethodDescriptionaddEnabledCheck(Predicate<MeterConfig> enabledCheck) Adds a check to the MeterConfigBuilder that will be used to determine if the MeterConfig is enabled.Makes the meter to be logged only if it was updated in the last minute.logOnceEveryInterval(int interval) Makes the meter to be logged once every 'interval' times.Adds additional condition for logging the meter.Meter will be logged only when this condition is met.setCustomLogger(org.slf4j.Logger logger) Sets a custom logger for the meter.setIntervalLogging(boolean enabled) Sets the meter to log at regular intervals.setLogOnUpdate(boolean logOnUpdate) Sets the meter to be logged when it's updated.setProperty(String key, Object value) Sets a property on the MeterConfigBuilder.setUpdateListener(Consumer<IpdMeter> updateListener) Sets the listener that will be called when the meter value is updated andsetLogOnUpdate(boolean)is enabled.setWorkInProgress(boolean workInProgress) Sets meter as "work in progress".
-
Method Details
-
addEnabledCheck
Adds a check to the MeterConfigBuilder that will be used to determine if the MeterConfig is enabled.Adding a new check will not remove the previous checks. All checks must pass for the MeterConfig to be enabled.
- Parameters:
enabledCheck- predicate returning true if the Meter should be enabled- Returns:
- this MeterConfigBuilder
-
setWorkInProgress
Sets meter as "work in progress". Work in progress meters require additional feature flag to be enabled. It is intended for meter we want to test on internal instances before enabling them on production.- Parameters:
workInProgress- true if the meter is work in progress- Returns:
- this MeterConfigBuilder
-
setProperty
Sets a property on the MeterConfigBuilder. Properties can be accessed later on for individual meters throughMeterConfig.getProperties().- Parameters:
key- property keyvalue- property value- Returns:
- this MeterConfigBuilder
-
logOnceEveryInterval
Makes the meter to be logged once every 'interval' times.By default, the 'interval' is set to 1, which usually means the meter will be logged every minute.
If product logs meters every minute, setting the 'interval' value to 5 will make the meter to be logged every 5 minutes.
- Parameters:
interval- how often the meter should be logged. Is a positive integer.- Returns:
- this MeterConfigBuilder
-
logIfUpdatedInLastMinute
MeterConfigBuilder logIfUpdatedInLastMinute()Makes the meter to be logged only if it was updated in the last minute.- Returns:
- this MeterConfigBuilder
-
setCustomLogger
Sets a custom logger for the meter. This logger will be used to log the meter values.By default, the meter is logged to ipd log file using default logger defined in
IpdConstants.DEFAULT_DATA_LOGGER.- Parameters:
logger- custom logger- Returns:
- this MeterConfigBuilder
-
setIntervalLogging
Sets the meter to log at regular intervals.By default, the meters are automatically logged in a regular interval.
Setting the 'enabled' value to false, doesn't disable all logging, but only the regular interval logging. If the meter hassetLogOnUpdate(boolean)enabled, it will still be logged when updated.- Parameters:
enabled- true if the meter should be logged at regular intervals- Returns:
- this MeterConfigBuilder
-
setLogOnUpdate
Sets the meter to be logged when it's updated.Meter will still be logged at regular intervals if
setIntervalLogging(boolean)is enabled.- Parameters:
logOnUpdate- true if the meter should be logged when updated- Returns:
- this MeterConfigBuilder
-
logWhen
Adds additional condition for logging the meter.Meter will be logged only when this condition is met.All conditions must be met to log the meter.
- Parameters:
shouldLog- predicate returning true if the meter should be logged- Returns:
- this MeterConfigBuilder
-
setUpdateListener
Sets the listener that will be called when the meter value is updated andsetLogOnUpdate(boolean)is enabled.By default this value is set to
IpdConstants.NO_OP.
However, products should set this value for all meters toIpdLoggingService.logMetric(IpdMeter).- Parameters:
updateListener- listener that is called when the meter value is updated- Returns:
- this MeterConfigBuilder
-