Class MeterConfigurationsImpl
- All Implemented Interfaces:
MeterConfigurations
- Since:
- 5.0.0
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddMeterConfig(String prefixMatcher, Consumer<MeterConfigBuilder> meterConfig) Adds a configuration for a specific meter key prefix.voidevaluateConfig(MeterKey meterKey, ProductMeterConfigBuilder configBuilder) Evaluates the configuration for the given MeterKey and applies it to the provided ProductMeterConfigBuilder.
-
Constructor Details
-
MeterConfigurationsImpl
-
-
Method Details
-
addMeterConfig
public MeterConfigurations addMeterConfig(String prefixMatcher, Consumer<MeterConfigBuilder> meterConfig) Description copied from interface:MeterConfigurationsAdds a configuration for a specific meter key prefix. The key prefix must be made of full meter segments it wants to match. Matching prefix as `String.startsWith()` is not supported.For example, a meter "issue.created" will apply configurations with prefix "issue" and "issue.created". However, it won't apply configuration with prefix "iss". Such configuration would apply to meters like "iss" and "iss.created".
The configuration is applied to all meters whose key starts with the provided prefix. The configuration is applied after the default configuration.
Configuration added with prefix "" (empty string) will apply to all meters.
Important Note: The configuration is applied only on meter creation. Changing the configuration after the meter is created will not affect the meter. It is recommended to declare all configurations before creating any meters, otherwise meters may not have the expected configuration.- Specified by:
addMeterConfigin interfaceMeterConfigurations- Parameters:
prefixMatcher- the prefix of the meter key to matchmeterConfig- the configuration that will be applied to meters with keys matching the prefix- Returns:
- this MeterConfigurations instance
-
evaluateConfig
Description copied from interface:MeterConfigurationsEvaluates the configuration for the given MeterKey and applies it to the provided ProductMeterConfigBuilder. The default configuration is applied first, followed by any specific configurations that match the MeterKey.This method applies configurations for each segment of the meter key, starting from the most generic to the most specific. For example, if the meter key is "issue.created" and there are configurations for "issue" and "issue.created", the configuration for "issue" will be applied first, followed by the configuration for "issue.created".
- Specified by:
evaluateConfigin interfaceMeterConfigurations- Parameters:
meterKey- the key of the meter to evaluate the configuration forconfigBuilder- the builder to apply the configuration to
-